FIX: auto arranging gets wrong object height
obj->bounding_box().size() is not the real object size if the object has been rotated. jira: STUDIO-5999 Change-Id: I6553d4c990696efd674e3e57063802127d5d5282 (cherry picked from commit 479ea9fb02f55d24f27c94633f3d852bd5c62c83)
This commit is contained in:
parent
5a63200c02
commit
eb50f3ee58
|
@ -1436,11 +1436,15 @@ BoundingBoxf3 ModelObject::instance_bounding_box(const ModelInstance& instance,
|
||||||
|
|
||||||
//BBS: add convex bounding box
|
//BBS: add convex bounding box
|
||||||
BoundingBoxf3 ModelObject::instance_convex_hull_bounding_box(size_t instance_idx, bool dont_translate) const
|
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;
|
BoundingBoxf3 bb;
|
||||||
const Transform3d& inst_matrix = this->instances[instance_idx]->get_transformation().get_matrix(dont_translate);
|
const Transform3d& inst_matrix = instance->get_transformation().get_matrix(dont_translate);
|
||||||
for (ModelVolume *v : this->volumes)
|
for (ModelVolume* v : this->volumes) {
|
||||||
{
|
|
||||||
if (v->is_model_part())
|
if (v->is_model_part())
|
||||||
bb.merge(v->get_convex_hull().transformed_bounding_box(inst_matrix * v->get_matrix()));
|
bb.merge(v->get_convex_hull().transformed_bounding_box(inst_matrix * v->get_matrix()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,6 +449,7 @@ public:
|
||||||
|
|
||||||
//BBS: add instance convex hull bounding box
|
//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(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.
|
// 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.
|
// This method is cheap in that it does not make any unnecessary copy of the volume meshes.
|
||||||
|
|
|
@ -176,7 +176,8 @@ ArrangePolygon get_instance_arrange_poly(ModelInstance* instance, const Slic3r::
|
||||||
ap.has_tree_support = true;
|
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;
|
ap.name = obj->name;
|
||||||
return ap;
|
return ap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,18 +502,17 @@ void ArrangeJob::check_unprintable()
|
||||||
if (it->poly.area() < 0.001 || it->height>params.printable_height)
|
if (it->poly.area() < 0.001 || it->height>params.printable_height)
|
||||||
{
|
{
|
||||||
#if SAVE_ARRANGE_POLY
|
#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())
|
if (svg.is_opened())
|
||||||
svg.draw_outline(it->poly);
|
svg.draw_outline(it->poly);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_unprintable.push_back(*it);
|
|
||||||
it = m_selected.erase(it);
|
|
||||||
if (it->poly.area() < 0.001) {
|
if (it->poly.area() < 0.001) {
|
||||||
auto msg = (boost::format(_u8L("Object %1% has zero size and can't be arranged.")) % it->name).str();
|
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,
|
m_plater->get_notification_manager()->push_notification(NotificationType::BBLPlateInfo,
|
||||||
NotificationManager::NotificationLevel::WarningNotificationLevel, msg);
|
NotificationManager::NotificationLevel::WarningNotificationLevel, msg);
|
||||||
}
|
}
|
||||||
|
m_unprintable.push_back(*it);
|
||||||
|
it = m_selected.erase(it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
it++;
|
it++;
|
||||||
|
|
|
@ -2987,7 +2987,7 @@ void Selection::paste_objects_from_clipboard()
|
||||||
if (src_objects.size() > 1) {
|
if (src_objects.size() > 1) {
|
||||||
BoundingBoxf3 bbox_all;
|
BoundingBoxf3 bbox_all;
|
||||||
for (const ModelObject *src_object : src_objects) {
|
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);
|
bbox_all.merge(bbox);
|
||||||
}
|
}
|
||||||
auto bsize = bbox_all.size();
|
auto bsize = bbox_all.size();
|
||||||
|
@ -3003,7 +3003,7 @@ void Selection::paste_objects_from_clipboard()
|
||||||
ModelObject* dst_object = m_model->add_object(*src_object);
|
ModelObject* dst_object = m_model->add_object(*src_object);
|
||||||
|
|
||||||
// BBS: find an empty cell to put the copied 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;
|
Vec3d displacement;
|
||||||
bool in_current = plate->intersects(bbox);
|
bool in_current = plate->intersects(bbox);
|
||||||
|
|
Loading…
Reference in New Issue