From d15e82135e62b9c5389bfb3b49971711c13d6a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0ach?= Date: Tue, 5 Mar 2024 12:06:35 +0100 Subject: [PATCH] Exclude skirt and brim from 'instance' annotation --- src/libslic3r/GCode.cpp | 20 +++++++++++++------- src/libslic3r/GCode/LabelObjects.cpp | 6 +++--- src/libslic3r/GCode/LabelObjects.hpp | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 8534d37625..cebf0a59d0 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2181,12 +2181,6 @@ LayerResult GCodeGenerator::process_layer( // Either printing all copies of all objects, or just a single copy of a single object. assert(single_object_instance_idx == size_t(-1) || layers.size() == 1); - const std::vector instances_to_print{sort_print_object_instances(layers, ordering, single_object_instance_idx)}; - const PrintInstance* first_instance{instances_to_print.empty() ? nullptr : &instances_to_print.front().print_object.instances()[instances_to_print.front().instance_id]}; - if (first_instance != nullptr) { - m_label_objects.update(*first_instance); - } - // First object, support and raft layer, if available. const Layer *object_layer = nullptr; const SupportLayer *support_layer = nullptr; @@ -2212,6 +2206,11 @@ LayerResult GCodeGenerator::process_layer( bool first_layer = layer.id() == 0; unsigned int first_extruder_id = layer_tools.extruders.front(); + const std::vector instances_to_print{sort_print_object_instances(layers, ordering, single_object_instance_idx)}; + const PrintInstance* first_instance{instances_to_print.empty() ? nullptr : &instances_to_print.front().print_object.instances()[instances_to_print.front().instance_id]}; + m_label_objects.update(first_instance); + + // Initialize config with the 1st object to be printed at this layer. m_config.apply(layer.object()->config(), true); @@ -2358,6 +2357,9 @@ LayerResult GCodeGenerator::process_layer( } if (auto loops_it = skirt_loops_per_extruder.find(extruder_id); loops_it != skirt_loops_per_extruder.end()) { + gcode += this->m_label_objects.maybe_stop_instance(); + this->m_label_objects.update(nullptr); + const std::pair loops = loops_it->second; this->set_origin(0., 0.); m_avoid_crossing_perimeters.use_external_mp(); @@ -2379,6 +2381,9 @@ LayerResult GCodeGenerator::process_layer( // Extrude brim with the extruder of the 1st region. if (! m_brim_done) { + gcode += this->m_label_objects.maybe_stop_instance(); + this->m_label_objects.update(nullptr); + this->set_origin(0., 0.); m_avoid_crossing_perimeters.use_external_mp(); for (const ExtrusionEntity *ee : print.brim().entities) @@ -2388,6 +2393,7 @@ LayerResult GCodeGenerator::process_layer( // Allow a straight travel move to the first object point. m_avoid_crossing_perimeters.disable_once(); } + this->m_label_objects.update(first_instance); // We are almost ready to print. However, we must go through all the objects twice to print the the overridden extrusions first (infill/perimeter wiping feature): bool is_anything_overridden = layer_tools.wiping_extrusions().is_anything_overridden(); @@ -2523,7 +2529,7 @@ void GCodeGenerator::process_layer_single_object( // When starting a new object, use the external motion planner for the first travel move. const Point &offset = print_object.instances()[print_instance.instance_id].shift; - const bool updated{m_label_objects.update(print_instance.print_object.instances()[print_instance.instance_id])}; + const bool updated{m_label_objects.update(&print_instance.print_object.instances()[print_instance.instance_id])}; if (updated) m_avoid_crossing_perimeters.use_external_mp_once(); this->set_origin(unscale(offset)); diff --git a/src/libslic3r/GCode/LabelObjects.cpp b/src/libslic3r/GCode/LabelObjects.cpp index a3409819e7..92e3b1e29c 100644 --- a/src/libslic3r/GCode/LabelObjects.cpp +++ b/src/libslic3r/GCode/LabelObjects.cpp @@ -111,11 +111,11 @@ void LabelObjects::init(const SpanOfConstPtrs& objects, LabelObject } } -bool LabelObjects::update(const PrintInstance &instance) { - if (this->last_operation_instance == &instance) { +bool LabelObjects::update(const PrintInstance *instance) { + if (this->last_operation_instance == instance) { return false; } - this->last_operation_instance = &instance; + this->last_operation_instance = instance; return true; } diff --git a/src/libslic3r/GCode/LabelObjects.hpp b/src/libslic3r/GCode/LabelObjects.hpp index a9461ec649..e8eb2f21a4 100644 --- a/src/libslic3r/GCode/LabelObjects.hpp +++ b/src/libslic3r/GCode/LabelObjects.hpp @@ -23,7 +23,7 @@ public: std::string all_objects_header() const; std::string all_objects_header_singleline_json() const; - bool update(const PrintInstance &instance); + bool update(const PrintInstance *instance); std::string maybe_start_instance();