From 89a31f9308285b09a602c3d5749a0f8ae6acb371 Mon Sep 17 00:00:00 2001 From: Hanif Koh Date: Wed, 9 Sep 2026 23:22:32 +0800 Subject: [PATCH] Update Visualization --- src/slic3r/GUI/PartPlate.cpp | 25 ++++++++++++++++++++----- src/slic3r/GUI/PartPlate.hpp | 2 ++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 849aa4e31a..87eb800719 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -1549,7 +1550,7 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode) const glb_support |= glb_config.opt_int("raft_layers") > 0; for (int obj_idx = 0; obj_idx < m_model->objects.size(); obj_idx++) { - if (!contain_instance_totally(obj_idx, 0)) + if (!contain_any_instance_totally(obj_idx)) continue; ModelObject* mo = m_model->objects[obj_idx]; @@ -1899,7 +1900,7 @@ std::vector PartPlate::get_extruders_without_support(bool conside_custom_gc const DynamicPrintConfig& glb_config = wxGetApp().preset_bundle->prints.get_edited_preset().config; for (int obj_idx = 0; obj_idx < m_model->objects.size(); obj_idx++) { - if (!contain_instance_totally(obj_idx, 0)) + if (!contain_any_instance_totally(obj_idx)) continue; ModelObject* mo = m_model->objects[obj_idx]; @@ -2070,7 +2071,7 @@ bool PartPlate::check_single_extruder_mixed_filament_risk(const DynamicPrintConf "which may significantly increase waste and the risk of nozzle / waste-chute clogging."); for (int obj_idx = 0; obj_idx < (int)m_model->objects.size(); ++obj_idx) { - if (!contain_instance_totally(obj_idx, 0)) + if (!contain_any_instance_totally(obj_idx)) continue; ModelObject *mo = m_model->objects[obj_idx]; int obj_ext = mo->config.has("extruder") ? mo->config.extruder() : 1; @@ -2289,7 +2290,7 @@ bool PartPlate::check_compatible_of_nozzle_and_filament(const DynamicPrintConfig return wipe_tower_size; for (int obj_idx = 0; obj_idx < m_model->objects.size(); obj_idx++) { - if (!use_global_objects && !contain_instance_totally(obj_idx, 0)) + if (!use_global_objects && !contain_any_instance_totally(obj_idx)) continue; BoundingBoxf3 bbox = m_model->objects[obj_idx]->bounding_box(); @@ -2332,7 +2333,7 @@ Vec3d PartPlate::estimate_wipe_tower_size(const DynamicPrintConfig & config, con return wipe_tower_size; for (int obj_idx = 0; obj_idx < m_model->objects.size(); obj_idx++) { - if (!use_global_objects && !contain_instance_totally(obj_idx, 0)) + if (!use_global_objects && !contain_any_instance_totally(obj_idx)) continue; BoundingBoxf3 bbox = m_model->objects[obj_idx]->bounding_box_exact(); @@ -2755,6 +2756,20 @@ bool PartPlate::contain_instance_totally(int obj_id, int instance_id) const return result; } +//judge whether any instance of the object is totally included in plate or not +bool PartPlate::contain_any_instance_totally(int obj_id) const +{ + // obj_to_instance_set is ordered by (obj_id, instance_id), so the object's entries are contiguous. + for (auto it = obj_to_instance_set.lower_bound(std::pair(obj_id, std::numeric_limits::min())); + it != obj_to_instance_set.end() && it->first == obj_id; ++it) + { + if (instance_outside_set.find(*it) == instance_outside_set.end()) + return true; + } + + return false; +} + //check whether instance is outside the plate or not bool PartPlate::check_outside(int obj_id, int instance_id, BoundingBoxf3* bounding_box) { diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index 8ad2f4a7d1..1fca00ecd6 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -366,6 +366,8 @@ public: bool contain_instance_totally(ModelObject* object, int instance_id) const; //judge whether instance is totally included in plate or not bool contain_instance_totally(int obj_id, int instance_id) const; + //judge whether any instance of the object is totally included in plate or not + bool contain_any_instance_totally(int obj_id) const; //judge whether the plate's origin is at the left of instance or not bool is_left_top_of(int obj_id, int instance_id);