From 3ea602091e6c02930ea562667eb947093fe47589 Mon Sep 17 00:00:00 2001 From: "salt.wei" Date: Mon, 29 May 2023 10:15:57 +0800 Subject: [PATCH] ENH: add back infill anchor for special case These two settings is necessary for some specific user case. Signed-off-by: salt.wei Change-Id: I9d70679932ac90c34296393d0e8bb8aebd8ebe48 --- src/libslic3r/Fill/Fill.cpp | 8 +++- src/libslic3r/Fill/FillBase.cpp | 5 --- src/libslic3r/Fill/FillBase.hpp | 3 -- src/libslic3r/Preset.cpp | 4 +- src/libslic3r/PrintConfig.cpp | 60 +++++++++++++++++++++++++++ src/libslic3r/PrintConfig.hpp | 3 +- src/libslic3r/PrintObject.cpp | 2 + src/slic3r/GUI/ConfigManipulation.cpp | 5 ++- src/slic3r/GUI/GUI_Factories.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 2 + 10 files changed, 79 insertions(+), 15 deletions(-) diff --git a/src/libslic3r/Fill/Fill.cpp b/src/libslic3r/Fill/Fill.cpp index 556b3f008..f1af208ea 100644 --- a/src/libslic3r/Fill/Fill.cpp +++ b/src/libslic3r/Fill/Fill.cpp @@ -190,8 +190,12 @@ std::vector group_fills(const Layer &layer) // so that internall infill will be aligned over all layers of the current region. params.spacing = layerm.region().flow(*layer.object(), frInfill, layer.object()->config().layer_height, false).spacing(); // Anchor a sparse infill to inner perimeters with the following anchor length: - params.anchor_length = float(Fill::infill_anchor * 0.01 * params.spacing); - params.anchor_length_max = Fill::infill_anchor_max; + params.anchor_length = float(region_config.sparse_infill_anchor); + if (region_config.sparse_infill_anchor.percent) + params.anchor_length = float(params.anchor_length * 0.01 * params.spacing); + params.anchor_length_max = float(region_config.sparse_infill_anchor_max); + if (region_config.sparse_infill_anchor_max.percent) + params.anchor_length_max = float(params.anchor_length_max * 0.01 * params.spacing); params.anchor_length = std::min(params.anchor_length, params.anchor_length_max); } diff --git a/src/libslic3r/Fill/FillBase.cpp b/src/libslic3r/Fill/FillBase.cpp index 8cfbd8b12..acbf8f028 100644 --- a/src/libslic3r/Fill/FillBase.cpp +++ b/src/libslic3r/Fill/FillBase.cpp @@ -28,11 +28,6 @@ namespace Slic3r { -//BBS: 0% of sparse_infill_line_width, no anchor at the start of sparse infill -float Fill::infill_anchor = 400; -//BBS: 20mm -float Fill::infill_anchor_max = 20; - Fill* Fill::new_from_type(const InfillPattern type) { switch (type) { diff --git a/src/libslic3r/Fill/FillBase.hpp b/src/libslic3r/Fill/FillBase.hpp index 4e0927077..5d0cbc2ad 100644 --- a/src/libslic3r/Fill/FillBase.hpp +++ b/src/libslic3r/Fill/FillBase.hpp @@ -108,9 +108,6 @@ public: // BBS: all no overlap expolygons in same layer ExPolygons no_overlap_expolygons; - static float infill_anchor; - static float infill_anchor_max; - public: virtual ~Fill() {} virtual Fill* clone() const = 0; diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index c8127f6c1..570ba198a 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -708,8 +708,8 @@ static std::vector s_Preset_print_options { "layer_height", "initial_layer_print_height", "wall_loops", "slice_closing_radius", "spiral_mode", "slicing_mode", "top_shell_layers", "top_shell_thickness", "bottom_shell_layers", "bottom_shell_thickness", "ensure_vertical_shell_thickness", "reduce_crossing_wall", "detect_thin_wall", "detect_overhang_wall", - "seam_position", "wall_infill_order", "sparse_infill_density", "sparse_infill_pattern", "top_surface_pattern", "bottom_surface_pattern", - "infill_direction", "bridge_angle", + "seam_position", "wall_infill_order", "sparse_infill_density", "sparse_infill_pattern", "sparse_infill_anchor", "sparse_infill_anchor_max", + "top_surface_pattern", "bottom_surface_pattern", "infill_direction", "bridge_angle", "minimum_sparse_infill_area", "reduce_infill_retraction", "ironing_pattern", "ironing_type", "ironing_flow", "ironing_speed", "ironing_spacing", "max_travel_detour_distance", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 5febc22e7..7660834f5 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1571,6 +1571,62 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionBool(false)); + auto def_infill_anchor_min = def = this->add("sparse_infill_anchor", coFloatOrPercent); + def->label = L("Length of sparse infill anchor"); + def->category = L("Strength"); + def->tooltip = L("Connect a sparse infill line to an internal perimeter with a short segment of an additional perimeter. " + "If expressed as percentage (example: 15%) it is calculated over sparse infill line width. " + "Slicer tries to connect two close infill lines to a short perimeter segment. If no such perimeter segment " + "shorter than infill_anchor_max is found, the infill line is connected to a perimeter segment at just one side " + "and the length of the perimeter segment taken is limited to this parameter, but no longer than anchor_length_max. " + "Set this parameter to zero to disable anchoring perimeters connected to a single infill line."); + def->sidetext = L("mm or %"); + def->ratio_over = "sparse_infill_line_width"; + def->max_literal = 1000; + def->gui_type = ConfigOptionDef::GUIType::f_enum_open; + def->enum_values.push_back("0"); + def->enum_values.push_back("1"); + def->enum_values.push_back("2"); + def->enum_values.push_back("5"); + def->enum_values.push_back("10"); + def->enum_values.push_back("1000"); + def->enum_labels.push_back(L("0 (no open anchors)")); + def->enum_labels.push_back("1 mm"); + def->enum_labels.push_back("2 mm"); + def->enum_labels.push_back("5 mm"); + def->enum_labels.push_back("10 mm"); + def->enum_labels.push_back(L("1000 (unlimited)")); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloatOrPercent(400, true)); + + def = this->add("sparse_infill_anchor_max", coFloatOrPercent); + def->label = L("Maximum length of sparse infill anchor"); + def->category = def_infill_anchor_min->category; + def->tooltip = L("Connect a sparse infill line to an internal perimeter with a short segment of an additional perimeter. " + "If expressed as percentage (example: 15%) it is calculated over sparse infill line width. " + "Slicer tries to connect two close infill lines to a short perimeter segment. If no such perimeter segment " + "shorter than this parameter is found, the infill line is connected to a perimeter segment at just one side " + "and the length of the perimeter segment taken is limited to infill_anchor, but no longer than this parameter. " + "Set this parameter to zero to disable anchoring."); + def->sidetext = def_infill_anchor_min->sidetext; + def->ratio_over = def_infill_anchor_min->ratio_over; + def->max_literal = def_infill_anchor_min->max_literal; + def->gui_type = def_infill_anchor_min->gui_type; + def->enum_values.push_back("0"); + def->enum_values.push_back("1"); + def->enum_values.push_back("2"); + def->enum_values.push_back("5"); + def->enum_values.push_back("10"); + def->enum_values.push_back("1000"); + def->enum_labels.push_back(L("0 (not anchored)")); + def->enum_labels.push_back("1 mm"); + def->enum_labels.push_back("2 mm"); + def->enum_labels.push_back("5 mm"); + def->enum_labels.push_back("10 mm"); + def->enum_labels.push_back(L("1000 (unlimited)")); + def->mode = def_infill_anchor_min->mode; + def->set_default_value(new ConfigOptionFloatOrPercent(20, false)); + def = this->add("sparse_infill_filament", coInt); def->label = L("Infill"); def->category = L("Extruders"); @@ -3935,6 +3991,10 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va value = "tree(auto)"; } else if (opt_key == "support_base_pattern" && value == "none") { value = "hollow"; + } else if (opt_key == "infill_anchor") { + opt_key = "sparse_infill_anchor"; + } else if (opt_key == "infill_anchor_max") { + opt_key = "sparse_infill_anchor_max"; } else if (opt_key == "different_settings_to_system") { std::string copy_value = value; copy_value.erase(std::remove(copy_value.begin(), copy_value.end(), '\"'), copy_value.end()); // remove '"' in string diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index ba3dd0d9a..191653331 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -756,7 +756,8 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloat, overhang_1_4_speed)) ((ConfigOptionFloat, overhang_2_4_speed)) ((ConfigOptionFloat, overhang_3_4_speed)) - ((ConfigOptionFloat, overhang_4_4_speed))) + ((ConfigOptionFloatOrPercent, sparse_infill_anchor)) + ((ConfigOptionFloatOrPercent, sparse_infill_anchor_max)) PRINT_CONFIG_CLASS_DEFINE( MachineEnvelopeConfig, diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 920ada240..b2f948fbd 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -813,6 +813,8 @@ bool PrintObject::invalidate_state_by_config_options( || opt_key == "bottom_surface_pattern" || opt_key == "external_fill_link_max_length" || opt_key == "infill_direction" + || opt_key == "sparse_infill_anchor" + || opt_key == "sparse_infill_anchor_max" || opt_key == "top_surface_line_width" || opt_key == "initial_layer_line_width") { steps.emplace_back(posInfill); diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index a844262e8..0782cbbef 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -539,9 +539,12 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co bool have_infill = config->option("sparse_infill_density")->value > 0; // sparse_infill_filament uses the same logic as in Print::extruders() - for (auto el : { "sparse_infill_pattern", "infill_combination", + for (auto el : { "sparse_infill_pattern", "sparse_infill_anchor_max", "infill_combination", "minimum_sparse_infill_area", "sparse_infill_filament"}) toggle_line(el, have_infill); + // Only allow configuration of open anchors if the anchoring is enabled. + bool has_infill_anchors = have_infill && config->option("sparse_infill_anchor_max")->value > 0; + toggle_line("sparse_infill_anchor", has_infill_anchors); bool has_spiral_vase = config->opt_bool("spiral_mode"); bool has_top_solid_infill = config->opt_int("top_shell_layers") > 0; diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index bfaf0977b..f40e032e2 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -95,7 +95,7 @@ std::map> SettingsFactory::PART_CAT }}, { L("Strength"), {{"wall_loops", "",1},{"top_shell_layers", L("Top Solid Layers"),1},{"top_shell_thickness", L("Top Minimum Shell Thickness"),1}, {"bottom_shell_layers", L("Bottom Solid Layers"),1}, {"bottom_shell_thickness", L("Bottom Minimum Shell Thickness"),1}, - {"sparse_infill_density", "",1},{"sparse_infill_pattern", "",1},{"top_surface_pattern", "",1},{"bottom_surface_pattern", "",1}, + {"sparse_infill_density", "",1},{"sparse_infill_pattern", "",1},{"sparse_infill_anchor", "",1},{"sparse_infill_anchor_max", "",1}, {"top_surface_pattern", "",1},{"bottom_surface_pattern", "",1}, {"infill_combination", "",1}, {"infill_wall_overlap", "",1}, {"infill_direction", "",1}, {"bridge_angle", "",1},{"minimum_sparse_infill_area", "",1} }}, { L("Speed"), {{"outer_wall_speed", "",1},{"inner_wall_speed", "",2},{"sparse_infill_speed", "",3},{"top_surface_speed", "",4}, {"internal_solid_infill_speed", "",5}, diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 2aeb6ac6f..0ec8226a7 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1892,6 +1892,8 @@ void TabPrint::build() optgroup = page->new_optgroup(L("Infill"), L"param_infill"); optgroup->append_single_option_line("sparse_infill_density"); optgroup->append_single_option_line("sparse_infill_pattern", "fill-patterns#infill types and their properties of sparse"); + optgroup->append_single_option_line("sparse_infill_anchor"); + optgroup->append_single_option_line("sparse_infill_anchor_max"); optgroup = page->new_optgroup(L("Advanced"), L"param_advanced"); optgroup->append_single_option_line("infill_wall_overlap");