Method GLCanvas3D::update_sequential_clearance() modified to use frontend data to calculate sequential print clearance contours
This commit is contained in:
parent
6974962dd0
commit
9da788eae1
1 changed files with 15 additions and 8 deletions
|
@ -4445,6 +4445,15 @@ void GLCanvas3D::update_sequential_clearance()
|
||||||
if (m_layers_editing.is_enabled() || m_gizmos.is_dragging())
|
if (m_layers_editing.is_enabled() || m_gizmos.is_dragging())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto instance_transform_from_volumes = [this](int object_idx, int instance_idx) {
|
||||||
|
for (const GLVolume* v : m_volumes.volumes) {
|
||||||
|
if (v->object_idx() == object_idx && v->instance_idx() == instance_idx)
|
||||||
|
return v->get_instance_transformation();
|
||||||
|
}
|
||||||
|
assert(false);
|
||||||
|
return Geometry::Transformation();
|
||||||
|
};
|
||||||
|
|
||||||
// collects instance transformations from volumes
|
// collects instance transformations from volumes
|
||||||
// first: define temporary cache
|
// first: define temporary cache
|
||||||
unsigned int instances_count = 0;
|
unsigned int instances_count = 0;
|
||||||
|
@ -4463,12 +4472,11 @@ void GLCanvas3D::update_sequential_clearance()
|
||||||
|
|
||||||
// second: fill temporary cache with data from volumes
|
// second: fill temporary cache with data from volumes
|
||||||
for (const GLVolume* v : m_volumes.volumes) {
|
for (const GLVolume* v : m_volumes.volumes) {
|
||||||
if (v->is_modifier || v->is_wipe_tower)
|
const int object_idx = v->object_idx();
|
||||||
continue;
|
const int instance_idx = v->instance_idx();
|
||||||
|
auto& transform = instance_transforms[object_idx][instance_idx];
|
||||||
auto& transform = instance_transforms[v->object_idx()][v->instance_idx()];
|
|
||||||
if (!transform.has_value())
|
if (!transform.has_value())
|
||||||
transform = v->get_instance_transformation();
|
transform = instance_transform_from_volumes(object_idx, instance_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function to calculate the transformation to be applied to the sequential print clearance contours
|
// helper function to calculate the transformation to be applied to the sequential print clearance contours
|
||||||
|
@ -4491,9 +4499,8 @@ void GLCanvas3D::update_sequential_clearance()
|
||||||
m_sequential_print_clearance.m_hulls_2d_cache.reserve(m_model->objects.size());
|
m_sequential_print_clearance.m_hulls_2d_cache.reserve(m_model->objects.size());
|
||||||
for (size_t i = 0; i < m_model->objects.size(); ++i) {
|
for (size_t i = 0; i < m_model->objects.size(); ++i) {
|
||||||
ModelObject* model_object = m_model->objects[i];
|
ModelObject* model_object = m_model->objects[i];
|
||||||
ModelInstance* model_instance0 = model_object->instances.front();
|
Geometry::Transformation trafo = instance_transform_from_volumes((int)i, 0);
|
||||||
Geometry::Transformation trafo = model_instance0->get_transformation();
|
trafo.set_offset({ 0.0, 0.0, trafo.get_offset().z() });
|
||||||
trafo.set_offset({ 0.0, 0.0, model_instance0->get_offset().z() });
|
|
||||||
const Polygon hull_2d = offset(model_object->convex_hull_2d(trafo.get_matrix()),
|
const Polygon hull_2d = offset(model_object->convex_hull_2d(trafo.get_matrix()),
|
||||||
// Shrink the extruder_clearance_radius a tiny bit, so that if the object arrangement algorithm placed the objects
|
// Shrink the extruder_clearance_radius a tiny bit, so that if the object arrangement algorithm placed the objects
|
||||||
// exactly by satisfying the extruder_clearance_radius, this test will not trigger collision.
|
// exactly by satisfying the extruder_clearance_radius, this test will not trigger collision.
|
||||||
|
|
Loading…
Add table
Reference in a new issue