From d29e3be0a0c3f0755f781e3db5433fe71a0c61d5 Mon Sep 17 00:00:00 2001 From: harrierpigeon Date: Thu, 8 Oct 2026 13:40:52 -0500 Subject: [PATCH] Belt G-code: drop the empty layers in one place The by-layer collect_layers_to_print() dropped every merged layer group in which nothing prints, and the per-object overload drops every belt entry that prints nothing. The merged groups are built only from the per-object entries, so after the second drop every group holds at least one entry that prints and the first never removed anything. Remove it and keep its explanation at the drop that does the work. No output changes. Reported by raistlin7447 in the review of #14394. Co-Authored-By: Claude Opus 5.5 --- src/libslic3r/GCode.cpp | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 453317ef2c..c2db414fc5 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2370,8 +2370,13 @@ std::vector GCode::collect_layers_to_print(const PrintObjec PrintStateBase::WarningLevel::CRITICAL, warning, PrintStateBase::SlicingEmptyGcodeLayers); } - // Belt printers: drop the layers that print nothing (see the by-layer overload), so - // the by-object export writes the same layer changes as the by-layer one. + // Belt printers: drop the layers that print nothing at all. An object's slicing + // frame starts at the belt below its leading end, so its first layers are empty, + // and with several objects along the belt those empty layers fall between other + // objects' printing layers. A layer change with no moves is noise in the file, and + // the preview (libvgcode) numbers its layers from the moves it sees, so a gap folds + // every later layer into the one before it. Both print sequences collect their + // layers here, so neither writes such a layer. if (object.print()->config().belt_printer.value) layers_to_print.erase( std::remove_if(layers_to_print.begin(), layers_to_print.end(), [&object](const LayerToPrint <p) { @@ -2446,31 +2451,6 @@ std::vector>> GCode::collec layers_to_print.emplace_back(std::move(merged)); } - // Belt printers: drop the layers that print nothing at all. An object's - // slicing frame starts at the belt below its leading end, so its first layers - // are empty, and with several objects along the belt those empty layers fall - // between other objects' printing layers. A layer change with no moves is - // noise in the file, and the preview (libvgcode) numbers its layers from the - // moves it sees, so a gap folds every later layer into the one before it. - if (print.config().belt_printer.value) { - auto prints_something = [](const LayerToPrint <p) { - if (ltp.object_layer != nullptr && ltp.original_object != nullptr && - belt_object_layer_prints_something(*ltp.original_object, *ltp.object_layer)) - return true; - if (ltp.support_layer != nullptr && ltp.support_layer->has_extrusions()) - return true; - if (ltp.belt_brim_band != nullptr && ! ltp.belt_brim_band->fills.empty()) - return true; - return false; - }; - layers_to_print.erase( - std::remove_if(layers_to_print.begin(), layers_to_print.end(), - [&prints_something](const std::pair> &group) { - return std::none_of(group.second.begin(), group.second.end(), prints_something); - }), - layers_to_print.end()); - } - return layers_to_print; }