From 7ea51fc07c7e9c0cf30a8af9723f1ae924b183d9 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 28 Mar 2023 08:55:22 +0200 Subject: [PATCH] Cut: when parts are selected, the result shall have only one parts with the combined meshes --- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 92a38f9ec..a4f2f975b 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -2418,6 +2418,26 @@ void GLGizmoCut3D::perform_cut(const Selection& selection) for (size_t id = 2; id < cut_connectors_obj.size(); id++) cut_object_ptrs.push_back(cut_connectors_obj[id]); } + + // Now merge all model parts together: + { + for (ModelObject* mo : cut_object_ptrs) { + TriangleMesh mesh; + for (const ModelVolume* mv : mo->volumes) { + if (mv->is_model_part()) { + TriangleMesh m = mv->mesh(); + m.transform(mv->get_matrix()); + mesh.merge(m); + } + } + if (! mesh.empty()) { + ModelVolume* new_volume = mo->add_volume(mesh); + for (int i=int(mo->volumes.size())-2; i>=0; --i) + if (mo->volumes[i]->type() == ModelVolumeType::MODEL_PART) + mo->delete_volume(i); + } + } + } } else cut_object_ptrs = mo->cut(instance_idx, cut_matrix, attributes);