diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 0837ced1e..d4b1af8be 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1436,11 +1436,15 @@ BoundingBoxf3 ModelObject::instance_bounding_box(const ModelInstance& instance, //BBS: add convex bounding box BoundingBoxf3 ModelObject::instance_convex_hull_bounding_box(size_t instance_idx, bool dont_translate) const +{ + return instance_convex_hull_bounding_box(this->instances[instance_idx], dont_translate); +} + +BoundingBoxf3 ModelObject::instance_convex_hull_bounding_box(const ModelInstance* instance, bool dont_translate) const { BoundingBoxf3 bb; - const Transform3d& inst_matrix = this->instances[instance_idx]->get_transformation().get_matrix(dont_translate); - for (ModelVolume *v : this->volumes) - { + const Transform3d& inst_matrix = instance->get_transformation().get_matrix(dont_translate); + for (ModelVolume* v : this->volumes) { if (v->is_model_part()) bb.merge(v->get_convex_hull().transformed_bounding_box(inst_matrix * v->get_matrix())); } diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 808e023fc..7d3cc1820 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -449,6 +449,7 @@ public: //BBS: add instance convex hull bounding box BoundingBoxf3 instance_convex_hull_bounding_box(size_t instance_idx, bool dont_translate = false) const; + BoundingBoxf3 instance_convex_hull_bounding_box(const ModelInstance* instance, bool dont_translate = false) const; // Calculate 2D convex hull of of a projection of the transformed printable volumes into the XY plane. // This method is cheap in that it does not make any unnecessary copy of the volume meshes. diff --git a/src/libslic3r/ModelArrange.cpp b/src/libslic3r/ModelArrange.cpp index 50622a3b5..477509e69 100644 --- a/src/libslic3r/ModelArrange.cpp +++ b/src/libslic3r/ModelArrange.cpp @@ -176,7 +176,8 @@ ArrangePolygon get_instance_arrange_poly(ModelInstance* instance, const Slic3r:: ap.has_tree_support = true; } - ap.height = obj->bounding_box().size().z(); + auto size = obj->instance_convex_hull_bounding_box(instance).size(); + ap.height = size.z(); ap.name = obj->name; return ap; } diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.cpp b/src/slic3r/GUI/Jobs/ArrangeJob.cpp index 3a5a86d88..4c6f4f373 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.cpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.cpp @@ -502,18 +502,17 @@ void ArrangeJob::check_unprintable() if (it->poly.area() < 0.001 || it->height>params.printable_height) { #if SAVE_ARRANGE_POLY - SVG svg("SVG/arrange_unprintable_"+it->name+".svg", get_extents(it->poly)); + SVG svg(data_dir() + "/SVG/arrange_unprintable_"+it->name+".svg", get_extents(it->poly)); if (svg.is_opened()) svg.draw_outline(it->poly); #endif - - m_unprintable.push_back(*it); - it = m_selected.erase(it); if (it->poly.area() < 0.001) { auto msg = (boost::format(_u8L("Object %1% has zero size and can't be arranged.")) % it->name).str(); m_plater->get_notification_manager()->push_notification(NotificationType::BBLPlateInfo, NotificationManager::NotificationLevel::WarningNotificationLevel, msg); } + m_unprintable.push_back(*it); + it = m_selected.erase(it); } else it++; diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index c0b9be2a7..9bb74d1a8 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -2987,7 +2987,7 @@ void Selection::paste_objects_from_clipboard() if (src_objects.size() > 1) { BoundingBoxf3 bbox_all; for (const ModelObject *src_object : src_objects) { - BoundingBoxf3 bbox = src_object->instance_convex_hull_bounding_box(0); + BoundingBoxf3 bbox = src_object->instance_convex_hull_bounding_box(size_t(0)); bbox_all.merge(bbox); } auto bsize = bbox_all.size(); @@ -3003,7 +3003,7 @@ void Selection::paste_objects_from_clipboard() ModelObject* dst_object = m_model->add_object(*src_object); // BBS: find an empty cell to put the copied object - BoundingBoxf3 bbox = src_object->instance_convex_hull_bounding_box(0); + BoundingBoxf3 bbox = src_object->instance_convex_hull_bounding_box(size_t(0)); Vec3d displacement; bool in_current = plate->intersects(bbox);