Fix of #11188: crash when replacing painted object with smaller stl

This commit is contained in:
Lukas Matena 2023-08-28 10:40:03 +02:00
parent c05542590d
commit 59029a04de
2 changed files with 9 additions and 3 deletions

View File

@ -165,6 +165,7 @@ struct indexed_triangle_set
std::vector<stl_vertex> vertices;
bool empty() const { return indices.empty() || vertices.empty(); }
bool operator==(const indexed_triangle_set& other) const { return this->indices == other.indices && this->vertices == other.vertices; }
};
extern bool stl_open(stl_file *stl, const char *file);

View File

@ -3567,9 +3567,14 @@ bool Plater::priv::replace_volume_with_stl(int object_idx, int volume_idx, const
new_volume->convert_from_imperial_units();
else if (old_volume->source.is_converted_from_meters)
new_volume->convert_from_meters();
new_volume->supported_facets.assign(old_volume->supported_facets);
new_volume->seam_facets.assign(old_volume->seam_facets);
new_volume->mmu_segmentation_facets.assign(old_volume->mmu_segmentation_facets);
if (old_volume->mesh().its == new_volume->mesh().its) {
// This function is called both from reload_from_disk and replace_with_stl.
// We need to make sure that the painted data point to existing triangles.
new_volume->supported_facets.assign(old_volume->supported_facets);
new_volume->seam_facets.assign(old_volume->seam_facets);
new_volume->mmu_segmentation_facets.assign(old_volume->mmu_segmentation_facets);
}
std::swap(old_model_object->volumes[volume_idx], old_model_object->volumes.back());
old_model_object->delete_volume(old_model_object->volumes.size() - 1);
if (!sinking)