diff --git a/src/libslic3r/CutUtils.cpp b/src/libslic3r/CutUtils.cpp index 8dd8fd7901f..5d3ec25c347 100644 --- a/src/libslic3r/CutUtils.cpp +++ b/src/libslic3r/CutUtils.cpp @@ -653,11 +653,5 @@ const ModelObjectPtrs& Cut::perform_with_groove(const Groove& groove, const Tran return m_model.objects; } -ModelObjectPtrs Cut::cut_horizontal(const ModelObject *object, size_t instance_idx, double z, ModelObjectCutAttributes attributes) -{ - Cut cut(object, instance_idx, Geometry::translation_transform(z * Vec3d::UnitZ()), attributes); - return cut.perform_with_plane(); -} - } // namespace Slic3r diff --git a/src/libslic3r/CutUtils.hpp b/src/libslic3r/CutUtils.hpp index d2bf88db549..4607489b277 100644 --- a/src/libslic3r/CutUtils.hpp +++ b/src/libslic3r/CutUtils.hpp @@ -63,8 +63,6 @@ class Cut { const ModelObjectPtrs& perform_by_contour(std::vector parts, int dowels_count); const ModelObjectPtrs& perform_with_groove(const Groove& groove, const Transform3d& rotation_m, bool keep_as_parts = false); - static ModelObjectPtrs cut_horizontal(const ModelObject *object, size_t instance_idx, double z, ModelObjectCutAttributes attributes); - }; // namespace Cut diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 93685502886..b3f123bfc42 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -8426,23 +8426,12 @@ void Plater::cut_horizontal(size_t obj_idx, size_t instance_idx, double z, Model return; wxBusyCursor wait; - const auto new_objects = Cut::cut_horizontal(object, instance_idx, z, attributes); - remove(obj_idx); - p->load_model_objects(new_objects); + const Vec3d instance_offset = object->instances[instance_idx]->get_offset(); + Cut cut(object, instance_idx, Geometry::translation_transform(z * Vec3d::UnitZ() - instance_offset), attributes); + const auto new_objects = cut.perform_with_plane(); - // now process all updates of the 3d scene - update(); - - // Update InfoItems in ObjectList after update() to use of a correct value of the GLCanvas3D::is_sinking(), - // which is updated after a view3D->reload_scene(false, flags & (unsigned int)UpdateParams::FORCE_FULL_SCREEN_REFRESH) call - for (size_t idx = 0; idx < p->model.objects.size(); idx++) - wxGetApp().obj_list()->update_info_items(idx); - - Selection& selection = p->get_selection(); - size_t last_id = p->model.objects.size() - 1; - for (size_t i = 0; i < new_objects.size(); ++i) - selection.add_object((unsigned int)(last_id - i), i == 0); + apply_cut_object_to_model(obj_idx, new_objects); } void Plater::_calib_pa_tower(const Calib_Params& params) { diff --git a/src/slic3r/Utils/CalibUtils.cpp b/src/slic3r/Utils/CalibUtils.cpp index f1cafadd26f..8186f4dfc20 100644 --- a/src/slic3r/Utils/CalibUtils.cpp +++ b/src/slic3r/Utils/CalibUtils.cpp @@ -143,7 +143,9 @@ static void cut_model(Model &model, double z, ModelObjectCutAttributes attribute auto* object = model.objects[0]; - const auto new_objects = Cut::cut_horizontal(object, instance_idx, z, attributes); + const Vec3d instance_offset = object->instances[instance_idx]->get_offset(); + Cut cut(object, instance_idx, Geometry::translation_transform(z * Vec3d::UnitZ() - instance_offset), attributes); + const auto new_objects = cut.perform_with_plane(); model.delete_object(obj_idx); for (ModelObject *model_object : new_objects) {