From 17b9189974f2189e927e750735063aca4c92a8b0 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 12 Nov 2021 17:04:14 +0100 Subject: [PATCH] Empty layer warning is now generated once per object --- src/libslic3r/GCode.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 153682808..da5a33acb 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -490,6 +490,8 @@ std::vector GCode::collect_layers_to_print(const PrintObjec gap_over_supports += support_layer_height_min; } + std::vector> warning_ranges; + // Pair the object layers with the support layers by z. size_t idx_object_layer = 0; size_t idx_support_layer = 0; @@ -535,15 +537,8 @@ std::vector GCode::collect_layers_to_print(const PrintObjec // Negative support_contact_z is not taken into account, it can result in false positives in cases // where previous layer has object extrusions too (https://github.com/prusa3d/PrusaSlicer/issues/2752) - if (has_extrusions && layer_to_print.print_z() > maximal_print_z + 2. * EPSILON) { - const_cast(object.print())->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, - Slic3r::format(_(L("Empty layer detected between heights %1% and %2%. Make sure the object is printable.")), - (last_extrusion_layer ? last_extrusion_layer->print_z() : 0.), - layers_to_print.back().print_z()) - + "\n" + Slic3r::format(_(L("Object name: %1%")), object.model_object()->name) + "\n\n" - + _(L("This is usually caused by negligibly small extrusions or by a faulty model. " - "Try to repair the model or change its orientation on the bed."))); - } + if (has_extrusions && layer_to_print.print_z() > maximal_print_z + 2. * EPSILON) + warning_ranges.emplace_back(std::make_pair((last_extrusion_layer ? last_extrusion_layer->print_z() : 0.), layers_to_print.back().print_z())); // Remember last layer with extrusions. if (has_extrusions) @@ -551,6 +546,23 @@ std::vector GCode::collect_layers_to_print(const PrintObjec } } + if (! warning_ranges.empty()) { + std::string warning; + size_t i = 0; + for (i = 0; i < std::min(warning_ranges.size(), size_t(3)); ++i) + warning += Slic3r::format(_(L("Empty layer between %1% and %2%.")), + warning_ranges[i].first, warning_ranges[i].second) + "\n"; + if (i < warning_ranges.size()) + warning += _(L("(Some lines not shown)")) + "\n"; + warning += "\n"; + warning += Slic3r::format(_(L("Object name: %1%")), object.model_object()->name) + "\n\n" + + _(L("Make sure the object is printable. This is usually caused by negligibly small extrusions or by a faulty model. " + "Try to repair the model or change its orientation on the bed.")); + + const_cast(object.print())->active_step_add_warning( + PrintStateBase::WarningLevel::CRITICAL, warning); + } + return layers_to_print; }