SPE-1606: Fixed sla geometry type shown when object has holes

This commit is contained in:
enricoturri1966 2023-06-01 12:00:21 +02:00
parent 1e7cb4b920
commit 7059adc6b8
5 changed files with 19 additions and 1 deletions

View File

@ -509,6 +509,8 @@ public:
bool has_solid_mesh() const; bool has_solid_mesh() const;
// Detect if object has at least one negative volume mash // Detect if object has at least one negative volume mash
bool has_negative_volume_mesh() const; bool has_negative_volume_mesh() const;
// Detect if object has at least one sla drain hole
bool has_sla_drain_holes() const { return !sla_drain_holes.empty(); }
bool is_cut() const { return cut_id.id().valid(); } bool is_cut() const { return cut_id.id().valid(); }
bool has_connectors() const; bool has_connectors() const;

View File

@ -1162,6 +1162,10 @@ static bool object_contains_negative_volumes(const Model& model, int obj_id) {
return (0 <= obj_id && obj_id < (int)model.objects.size()) ? model.objects[obj_id]->has_negative_volume_mesh() : false; return (0 <= obj_id && obj_id < (int)model.objects.size()) ? model.objects[obj_id]->has_negative_volume_mesh() : false;
} }
static bool object_has_sla_drain_holes(const Model& model, int obj_id) {
return (0 <= obj_id && obj_id < (int)model.objects.size()) ? model.objects[obj_id]->has_sla_drain_holes() : false;
}
void GLCanvas3D::SLAView::detect_type_from_volumes(const GLVolumePtrs& volumes) void GLCanvas3D::SLAView::detect_type_from_volumes(const GLVolumePtrs& volumes)
{ {
for (auto& [id, type] : m_instances_cache) { for (auto& [id, type] : m_instances_cache) {
@ -1170,7 +1174,8 @@ void GLCanvas3D::SLAView::detect_type_from_volumes(const GLVolumePtrs& volumes)
for (const GLVolume* v : volumes) { for (const GLVolume* v : volumes) {
if (v->volume_idx() == -(int)slaposDrillHoles) { if (v->volume_idx() == -(int)slaposDrillHoles) {
if (object_contains_negative_volumes(*m_parent.get_model(), v->composite_id.object_id)) { if (object_contains_negative_volumes(*m_parent.get_model(), v->composite_id.object_id) ||
object_has_sla_drain_holes(*m_parent.get_model(), v->composite_id.object_id)) {
const InstancesCacheItem* instance = find_instance_item(v->composite_id); const InstancesCacheItem* instance = find_instance_item(v->composite_id);
assert(instance != nullptr); assert(instance != nullptr);
set_type(instance->first, ESLAViewType::Processed); set_type(instance->first, ESLAViewType::Processed);
@ -4686,6 +4691,13 @@ std::pair<SlicingParameters, const std::vector<double>> GLCanvas3D::get_layers_h
return ret; return ret;
} }
void GLCanvas3D::detect_sla_view_type()
{
m_sla_view.detect_type_from_volumes(m_volumes.volumes);
m_sla_view.update_volumes_visibility(m_volumes.volumes);
m_dirty = true;
}
void GLCanvas3D::set_sla_view_type(ESLAViewType type) void GLCanvas3D::set_sla_view_type(ESLAViewType type)
{ {
m_sla_view.set_type(type); m_sla_view.set_type(type);

View File

@ -1005,6 +1005,7 @@ public:
std::pair<SlicingParameters, const std::vector<double>> get_layers_height_data(int object_id); std::pair<SlicingParameters, const std::vector<double>> get_layers_height_data(int object_id);
void detect_sla_view_type();
void set_sla_view_type(ESLAViewType type); void set_sla_view_type(ESLAViewType type);
void set_sla_view_type(const GLVolume::CompositeID& id, ESLAViewType type); void set_sla_view_type(const GLVolume::CompositeID& id, ESLAViewType type);
void enable_sla_view_type_detection() { m_sla_view_type_detection_active = true; } void enable_sla_view_type_detection() { m_sla_view_type_detection_active = true; }

View File

@ -855,6 +855,7 @@ void GLGizmoSlaSupports::on_set_state()
m_old_mo_id = -1; m_old_mo_id = -1;
} }
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_FORCE_UPDATE));
m_c->instances_hider()->set_hide_full_scene(false); m_c->instances_hider()->set_hide_full_scene(false);
m_c->selection_info()->set_use_shift(false); // see top of on_render for details m_c->selection_info()->set_use_shift(false); // see top of on_render for details

View File

@ -960,6 +960,8 @@ bool GLGizmosManager::activate_gizmo(EType type)
if (type == Undefined) { if (type == Undefined) {
// it is deactivation of gizmo // it is deactivation of gizmo
m_current = Undefined; m_current = Undefined;
if (m_parent.current_printer_technology() == ptSLA)
m_parent.detect_sla_view_type();
return true; return true;
} }