FIX:Repair calculation process of plate_box

Jira: STUDIO-5520
Change-Id: I4c3f9597542ad2dfec4d7849e75fa28272fa4ea3
This commit is contained in:
zhou.xu 2023-12-07 15:17:45 +08:00 committed by Lane.Wei
parent 3401ba89db
commit fd4c025134
2 changed files with 16 additions and 12 deletions

View File

@ -2044,10 +2044,9 @@ bool PartPlate::check_outside(int obj_id, int instance_id, BoundingBoxf3* boundi
BoundingBoxf3 instance_box = bounding_box? *bounding_box: object->instance_convex_hull_bounding_box(instance_id); BoundingBoxf3 instance_box = bounding_box? *bounding_box: object->instance_convex_hull_bounding_box(instance_id);
Polygon hull = instance->convex_hull_2d(); Polygon hull = instance->convex_hull_2d();
Vec3d up_point(m_origin.x() + m_width + Slic3r::BuildVolume::SceneEpsilon, m_origin.y() + m_depth + Slic3r::BuildVolume::SceneEpsilon, m_origin.z() + m_height + Slic3r::BuildVolume::SceneEpsilon); BoundingBoxf3 plate_box = get_plate_box();
Vec3d low_point(m_origin.x() - Slic3r::BuildVolume::SceneEpsilon, m_origin.y() - Slic3r::BuildVolume::SceneEpsilon, m_origin.z() - Slic3r::BuildVolume::SceneEpsilon); if (instance_box.max.z() > plate_box.min.z())
if (instance_box.max.z() > low_point.z()) low_point.z() += instance_box.min.z(); // not considering outsize if sinking plate_box.min.z() += instance_box.min.z(); // not considering outsize if sinking
BoundingBoxf3 plate_box(low_point, up_point);
if (plate_box.contains(instance_box)) if (plate_box.contains(instance_box))
{ {
@ -2089,11 +2088,7 @@ bool PartPlate::intersect_instance(int obj_id, int instance_id, BoundingBoxf3* b
ModelObject* object = m_model->objects[obj_id]; ModelObject* object = m_model->objects[obj_id];
ModelInstance* instance = object->instances[instance_id]; ModelInstance* instance = object->instances[instance_id];
BoundingBoxf3 instance_box = bounding_box? *bounding_box: object->instance_convex_hull_bounding_box(instance_id); BoundingBoxf3 instance_box = bounding_box? *bounding_box: object->instance_convex_hull_bounding_box(instance_id);
Vec3d up_point(m_origin.x() + m_width, m_origin.y() + m_depth, m_origin.z() + m_height); result = get_plate_box().intersects(instance_box);
Vec3d low_point(m_origin.x(), m_origin.y(), m_origin.z() - 5.0f);
BoundingBoxf3 plate_box(low_point, up_point);
result = plate_box.intersects(instance_box);
} }
else else
{ {
@ -2572,7 +2567,7 @@ void PartPlate::generate_exclude_polygon(ExPolygon &exclude_polygon)
bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Vec2d position, float height_to_lid, float height_to_rod) bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Vec2d position, float height_to_lid, float height_to_rod)
{ {
Pointfs new_shape, new_exclude_areas; Pointfs new_shape, new_exclude_areas;
m_raw_shape = shape;
for (const Vec2d& p : shape) { for (const Vec2d& p : shape) {
new_shape.push_back(Vec2d(p.x() + position.x(), p.y() + position.y())); new_shape.push_back(Vec2d(p.x() + position.x(), p.y() + position.y()));
} }

View File

@ -115,6 +115,7 @@ private:
friend class PartPlateList; friend class PartPlateList;
Pointfs m_raw_shape;
Pointfs m_shape; Pointfs m_shape;
Pointfs m_exclude_area; Pointfs m_exclude_area;
BoundingBoxf3 m_bounding_box; BoundingBoxf3 m_bounding_box;
@ -370,10 +371,18 @@ public:
void set_hover_id(int id) { m_hover_id = id; } void set_hover_id(int id) { m_hover_id = id; }
const BoundingBoxf3& get_bounding_box(bool extended = false) { return extended ? m_extended_bounding_box : m_bounding_box; } const BoundingBoxf3& get_bounding_box(bool extended = false) { return extended ? m_extended_bounding_box : m_bounding_box; }
const BoundingBox get_bounding_box_crd(); const BoundingBox get_bounding_box_crd();
BoundingBoxf3 get_plate_box() {return get_build_volume();}
BoundingBoxf3 get_build_volume() BoundingBoxf3 get_build_volume()
{ {
Vec3d up_point(m_origin.x() + m_width, m_origin.y() + m_depth, m_origin.z() + m_height); auto eps=Slic3r::BuildVolume::SceneEpsilon;
Vec3d low_point(m_origin.x(), m_origin.y(), m_origin.z()); Vec3d up_point = Vec3d(m_origin.x() + m_width + eps, m_origin.y() + m_depth + eps, m_origin.z() + m_height + eps);
Vec3d low_point = Vec3d(m_origin.x() - eps, m_origin.y() - eps, m_origin.z() - eps);
if (m_raw_shape.size() > 0) {
up_point.x() += m_raw_shape[0].x();
up_point.y() += m_raw_shape[0].y();
low_point.x() += m_raw_shape[0].x();
low_point.y() += m_raw_shape[0].y();
}
BoundingBoxf3 plate_box(low_point, up_point); BoundingBoxf3 plate_box(low_point, up_point);
return plate_box; return plate_box;
} }