From 2eecb1ce8a4f96b8709a5127e1304ddccdaed026 Mon Sep 17 00:00:00 2001 From: Wang YB <94800665+Gradbb@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:16:47 +0800 Subject: [PATCH] add top area threshold --- src/libslic3r/PerimeterGenerator.cpp | 11 +++++++++-- src/libslic3r/Preset.cpp | 2 ++ src/libslic3r/PrintConfig.cpp | 10 ++++++++++ src/libslic3r/PrintConfig.hpp | 2 ++ src/libslic3r/PrintObject.cpp | 6 ++++-- src/slic3r/GUI/Tab.cpp | 2 ++ 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index b951b66..0cb1f45 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -1302,9 +1302,14 @@ void PerimeterGenerator::process_arachne( out_loops.append(extrusion_coll); ExPolygons infill_contour = union_ex(wallToolPaths.getInnerContour()); + //w17 const coord_t spacing = (perimeters.size() == 1) ? ext_perimeter_spacing2 : perimeter_spacing; if (offset_ex(infill_contour, -float(spacing / 2.)).empty()) infill_contour.clear(); // Infill region is too small, so let's filter it out. + coord_t perimeter_width = params.perimeter_flow.scaled_width(); + double min_width_top_surface = (params.object_config.top_area_threshold / 100) * + std::max(double(ext_perimeter_spacing / 4 + 10), double(perimeter_width / 4)); + infill_contour = offset2_ex(infill_contour, -min_width_top_surface, min_width_top_surface + perimeter_width); // create one more offset to be used as boundary for fill // we offset by half the perimeter spacing (to get to the actual infill boundary) @@ -1440,7 +1445,8 @@ void PerimeterGenerator::process_with_one_wall_arachne( std::max(ext_perimeter_spacing, perimeter_width)); infill_contour = diff_ex(infill_contour, bridge_area); } - double min_width_top_surface = std::max(double(ext_perimeter_spacing / 4 + 10), double(perimeter_width / 4)); + //w17 + double min_width_top_surface = (params.object_config.top_area_threshold / 100) * std::max(double(ext_perimeter_spacing / 4 + 10), double(perimeter_width / 4)); infill_contour = offset2_ex(infill_contour, -min_width_top_surface, min_width_top_surface + perimeter_width); ExPolygons surface_not_export_to_top = diff_ex(the_layer_surface, infill_contour); @@ -1891,7 +1897,8 @@ void PerimeterGenerator::process_classic( 0.9 * (params.config.perimeters.value <= 1 ? 0. : (perimeter_spacing * (params.config.perimeters.value - 1)))); else offset_top_surface = 0; - double min_width_top_surface = (100) * + //w17 + double min_width_top_surface = (params.object_config.top_area_threshold/100 ) * std::max(double(ext_perimeter_spacing / 2 + 10), 1.0 * (double(perimeter_width))); BoundingBox last_box = get_extents(last); last_box.offset(SCALED_EPSILON); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index c03e1a5..8859081 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -477,6 +477,8 @@ static std::vector s_Preset_print_options { ,"seam_gap" //w16 , "top_one_wall_type" + //w17 + ,"top_area_threshold" }; static std::vector s_Preset_filament_options { diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 3bab28d..ca50339 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3550,6 +3550,16 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionEnum(TopOneWallType::Alltop)); + //w17 + def = this->add("top_area_threshold", coPercent); + def->label = L("Top area threshold"); + def->tooltip = L("This factor affects the acreage of top area. The small the number the big the top area."); + def->sidetext = L("%"); + def->min = 0; + def->max = 500; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionPercent(100)); + def = this->add("wall_transition_length", coFloatOrPercent); def->label = L("Perimeter transition length"); def->category = L("Advanced"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index bdcd6ac..c391800 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -592,6 +592,8 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionBool, detect_narrow_internal_solid_infill)) //w16 ((ConfigOptionEnum, top_one_wall_type)) + //w17 + ((ConfigOptionPercent, top_area_threshold)) ) PRINT_CONFIG_CLASS_DEFINE( diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 167fe63..d3b2193 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -865,8 +865,10 @@ bool PrintObject::invalidate_state_by_config_options( || opt_key == "wall_distribution_count" || opt_key == "min_feature_size" || opt_key == "min_bead_width" - //w15 - || opt_key == "top_one_wall_type"){ + //w16 + || opt_key == "top_one_wall_type" + //w17 + || opt_key == "top_area_threshold") { steps.emplace_back(posSlice); } else if ( opt_key == "seam_position" diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index ff4ba14..c67f0ab 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1469,6 +1469,8 @@ void TabPrint::build() optgroup->append_single_option_line("perimeter_generator"); //w16 optgroup->append_single_option_line("top_one_wall_type"); + //w17 + optgroup->append_single_option_line("top_area_threshold"); optgroup = page->new_optgroup(L("Fuzzy skin (experimental)")); category_path = "fuzzy-skin_246186/#";