diff --git a/src/admesh/stl.h b/src/admesh/stl.h index ac51ae1b68..2244aff2f2 100644 --- a/src/admesh/stl.h +++ b/src/admesh/stl.h @@ -165,6 +165,7 @@ struct indexed_triangle_set std::vector 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); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 7d710849fc..ba56acaea4 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -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)