From 0c1953a9294c2e2f8564c49b64bc153a91df3680 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 21 Apr 2021 14:34:43 +0200 Subject: [PATCH] Further fixes of the first_layer_height refactoring. --- src/libslic3r/Flow.cpp | 13 +++---------- src/libslic3r/GCode.cpp | 3 ++- src/libslic3r/Print.cpp | 8 ++++---- src/libslic3r/Slicing.cpp | 4 ++-- src/slic3r/GUI/ConfigManipulation.cpp | 6 +++--- src/slic3r/GUI/PresetHints.cpp | 3 ++- 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/libslic3r/Flow.cpp b/src/libslic3r/Flow.cpp index 56d537c39..9f4730261 100644 --- a/src/libslic3r/Flow.cpp +++ b/src/libslic3r/Flow.cpp @@ -89,18 +89,11 @@ double Flow::extrusion_width(const std::string& opt_key, const ConfigOptionFloat if (opt->percent) { auto opt_key_layer_height = first_layer ? "first_layer_height" : "layer_height"; - auto opt_layer_height = config.option(opt_key_layer_height); + auto opt_layer_height = config.option(opt_key_layer_height); if (opt_layer_height == nullptr) throw_on_missing_variable(opt_key, opt_key_layer_height); - double layer_height = opt_layer_height->getFloat(); - if (first_layer && static_cast(opt_layer_height)->percent) { - // first_layer_height depends on layer_height. - opt_layer_height = config.option("layer_height"); - if (opt_layer_height == nullptr) - throw_on_missing_variable(opt_key, "layer_height"); - layer_height *= 0.01 * opt_layer_height->getFloat(); - } - return opt->get_abs_value(layer_height); + assert(! first_layer || ! static_cast(opt_layer_height)->percent); + return opt->get_abs_value(opt_layer_height->getFloat()); } if (opt->value == 0.) { diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 0d65b7124..c5b28b3a0 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1111,7 +1111,8 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu // Write some terse information on the slicing parameters. const PrintObject *first_object = print.objects().front(); const double layer_height = first_object->config().layer_height.value; - const double first_layer_height = print.config().first_layer_height.get_abs_value(layer_height); + assert(! print.config().first_layer_height.percent); + const double first_layer_height = print.config().first_layer_height.value; for (const PrintRegion* region : print.regions()) { _write_format(file, "; external perimeters extrusion width = %.2fmm\n", region->flow(*first_object, frExternalPerimeter, layer_height).width()); _write_format(file, "; perimeters extrusion width = %.2fmm\n", region->flow(*first_object, frPerimeter, layer_height).width()); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index ce5bf1b29..7fcb75297 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1464,7 +1464,8 @@ std::string Print::validate(std::string* warning) const } // validate first_layer_height - double first_layer_height = object->config().get_abs_value("first_layer_height"); + assert(! m_config.first_layer_height.percent); + double first_layer_height = m_config.first_layer_height.value; double first_layer_min_nozzle_diameter; if (object->has_raft()) { // if we have raft layers, only support material extruder is used on first layer @@ -1561,9 +1562,8 @@ BoundingBox Print::total_bounding_box() const double Print::skirt_first_layer_height() const { - if (m_objects.empty()) - throw Slic3r::InvalidArgument("skirt_first_layer_height() can't be called without PrintObjects"); - return m_objects.front()->config().get_abs_value("first_layer_height"); + assert(! m_config.first_layer_height.percent); + return m_config.first_layer_height.value; } Flow Print::brim_flow() const diff --git a/src/libslic3r/Slicing.cpp b/src/libslic3r/Slicing.cpp index 98a5923aa..82b3cf1b6 100644 --- a/src/libslic3r/Slicing.cpp +++ b/src/libslic3r/Slicing.cpp @@ -64,9 +64,9 @@ SlicingParameters SlicingParameters::create_from_config( coordf_t object_height, const std::vector &object_extruders) { + assert(! print_config.first_layer_height.percent); coordf_t first_layer_height = (print_config.first_layer_height.value <= 0) ? - object_config.layer_height.value : - print_config.first_layer_height.get_abs_value(object_config.layer_height.value); + object_config.layer_height.value : print_config.first_layer_height.value; // If object_config.support_material_extruder == 0 resp. object_config.support_material_interface_extruder == 0, // print_config.nozzle_diameter.get_at(size_t(-1)) returns the 0th nozzle diameter, // which is consistent with the requirement that if support_material_extruder == 0 resp. support_material_interface_extruder == 0, diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index cd7805a88..d55758538 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -45,7 +45,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con // layer_height shouldn't be equal to zero if (config->opt_float("layer_height") < EPSILON) { - const wxString msg_text = _(L("Zero layer height is not valid.\n\nThe layer height will be reset to 0.01.")); + const wxString msg_text = _(L("Layer height is not valid.\n\nThe layer height will be reset to 0.01.")); wxMessageDialog dialog(nullptr, msg_text, _(L("Layer height")), wxICON_WARNING | wxOK); DynamicPrintConfig new_conf = *config; is_msg_dlg_already_exist = true; @@ -55,9 +55,9 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con is_msg_dlg_already_exist = false; } - if (fabs(config->option("first_layer_height")->value - 0) < EPSILON) + if (config->option("first_layer_height")->value < EPSILON) { - const wxString msg_text = _(L("Zero first layer height is not valid.\n\nThe first layer height will be reset to 0.01.")); + const wxString msg_text = _(L("First layer height is not valid.\n\nThe first layer height will be reset to 0.01.")); wxMessageDialog dialog(nullptr, msg_text, _(L("First layer height")), wxICON_WARNING | wxOK); DynamicPrintConfig new_conf = *config; is_msg_dlg_already_exist = true; diff --git a/src/slic3r/GUI/PresetHints.cpp b/src/slic3r/GUI/PresetHints.cpp index 181dcfda4..0e2b7f836 100644 --- a/src/slic3r/GUI/PresetHints.cpp +++ b/src/slic3r/GUI/PresetHints.cpp @@ -86,7 +86,8 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle // Print config values double layer_height = print_config.opt_float("layer_height"); - double first_layer_height = print_config.get_abs_value("first_layer_height", layer_height); + assert(! print_config.option("first_layer_height")->percent); + double first_layer_height = print_config.opt_float("first_layer_height"); double support_material_speed = print_config.opt_float("support_material_speed"); double support_material_interface_speed = print_config.get_abs_value("support_material_interface_speed", support_material_speed); double bridge_speed = print_config.opt_float("bridge_speed");