From f326352cebec56c980572f0d093439def63961d2 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 16 Jul 2020 15:42:30 +0200 Subject: [PATCH] Empty layers check converted to a warning (except for the first layer) --- src/libslic3r/GCode.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 9a0c9eaa7..7fc531b92 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -617,6 +617,13 @@ std::vector GCode::collect_layers_to_print(const PrintObjec layers_to_print.emplace_back(layer_to_print); + // Check that there are extrusions on the very first layer. + if (layers_to_print.size() == 1u) { + if ((layer_to_print.object_layer && ! layer_to_print.object_layer->has_extrusions()) + || (layer_to_print.support_layer && ! layer_to_print.support_layer->has_extrusions())) + throw std::runtime_error(_(L("There is an object with no extrusions on the first layer."))); + } + // In case there are extrusions on this layer, check there is a layer to lay it on. if ((layer_to_print.object_layer && layer_to_print.object_layer->has_extrusions()) // Allow empty support layers, as the support generator may produce no extrusions for non-empty support regions. @@ -634,14 +641,18 @@ std::vector GCode::collect_layers_to_print(const PrintObjec bool has_extrusions = (layer_to_print.object_layer && layer_to_print.object_layer->has_extrusions()) || (layer_to_print.support_layer && layer_to_print.support_layer->has_extrusions()); - if (has_extrusions && layer_to_print.print_z() > maximal_print_z + 2. * EPSILON) - throw std::runtime_error(_(L("Empty layers detected, the output would not be printable.")) + "\n\n" + + if (has_extrusions && layer_to_print.print_z() > maximal_print_z + 2. * EPSILON) { + const_cast(object.print())->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, + _(L("Empty layers detected, the output would not be printable.")) + "\n\n" + _(L("Object name")) + ": " + object.model_object()->name + "\n" + _(L("Print z")) + ": " + std::to_string(layers_to_print.back().print_z()) + "\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."))); + } + // Remember last layer with extrusions. - last_extrusion_layer = &layers_to_print.back(); + if (has_extrusions) + last_extrusion_layer = &layers_to_print.back(); } } @@ -1939,7 +1950,6 @@ void GCode::process_layer( const size_t single_object_instance_idx) { assert(! layers.empty()); -// assert(! layer_tools.extruders.empty()); // 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);