From 627c2e0f39434d6648d56d1ecb9a9e091b79a140 Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 21 Feb 2024 13:56:29 +0100 Subject: [PATCH] seam notch : allow almost convex/concave, so little imprecision doesn't prevent from detection. set seam_notch_angle min value to 180, as it doesn't supermerill/SuperSlicer#4143 --- src/libslic3r/GCode.cpp | 15 +++++++++++---- src/libslic3r/PrintConfig.cpp | 7 ++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 648a9791b71..996579b4627 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -4111,9 +4111,11 @@ void GCode::seam_notch(const ExtrusionLoop& original_loop, bool is_convex = false; if (is_hole_loop) { //test if convex (as it's clockwise bc it's a hole, we have to do the opposite) - is_convex = polygon_to_test.convex_points().empty(); + // 3.07 instead of PI to allow for some convex outliers (sometimes, stl can be a bit imprecise) + is_convex = polygon_to_test.convex_points(3.07).empty(); } else { - is_convex = polygon_to_test.concave_points().empty(); + // 3.3 instead of PI to allow for some concave outliers (sometimes, stl can be a bit imprecise) + is_convex = polygon_to_test.concave_points(3.3).empty(); } if (is_convex) { // Computing circle center @@ -4196,11 +4198,16 @@ void GCode::seam_notch(const ExtrusionLoop& original_loop, //check if the current angle isn't too sharp double check_angle = 0; + // get min angle (and if at min or max value, push it a bit more to avoid not filtering outliers) + double min_angle = this->m_config.seam_notch_angle.value; + if(min_angle <= 179.9) min_angle -= 1; + if(min_angle >= 359.9) min_angle += 1; + min_angle *= PI / 180.; if (end_point.distance_to_square(start_point) < SCALED_EPSILON * SCALED_EPSILON) { check_angle = start_point.ccw_angle(prev_point, next_point); } else { check_angle = end_point.ccw_angle(prev_point, start_point); - if ((is_hole_loop ? -check_angle : check_angle) > this->m_config.seam_notch_angle.value * PI / 180.) { + if ((is_hole_loop ? -check_angle : check_angle) > min_angle) { BOOST_LOG_TRIVIAL(debug) << "notch abord: too big angle\n"; return; } @@ -4208,7 +4215,7 @@ void GCode::seam_notch(const ExtrusionLoop& original_loop, } assert(end_point != start_point); assert(end_point != next_point); - if ((is_hole_loop ? -check_angle : check_angle) > this->m_config.seam_notch_angle.value * PI / 180.) { + if ((is_hole_loop ? -check_angle : check_angle) > min_angle) { BOOST_LOG_TRIVIAL(debug) << "notch abord: too big angle\n"; return; } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 10ef313a5f4..0d9ba14d4dc 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1889,7 +1889,7 @@ void PrintConfigDef::init_fff_params() "\nA value that only takes values as 'true' or 'false' will be a boolean)" "\nEvery other value will be parsed as a string as-is." "\nThese variables will be available as an array in the custom gcode (one item per extruder), don't forget to use them with the {current_extruder} index to get the current value." - " If a filament has a typo on the variable that change its type, then the parser will convert evrything to strings." + " If a filament has a typo on the variable that change its type, then the parser will convert everything to strings." "\nAdvice: before using a variable, it's safer to use the function 'default_XXX(variable_name, default_value)'" " (enclosed in bracket as it's a script) in case it's not set. You can replace XXX by 'int' 'bool' 'double' 'string'."); def->multiline = true; @@ -4708,9 +4708,10 @@ void PrintConfigDef::init_fff_params() def->label = L("max angle"); def->full_label = L("Seam notch maximum angle"); def->category = OptionCategory::perimeter; - def->tooltip = L("If the (external) angle at the seam is higher than this value, then no notch will be set. If the angle is too high, there isn't enough room for the notch."); + def->tooltip = L("If the (external) angle at the seam is higher than this value, then no notch will be set. If the angle is too high, there isn't enough room for the notch." + "\nCan't be lower than 180° or it filters everything. At 360, it allows everything."); def->sidetext = L("°"); - def->min = 0; + def->min = 180; def->max = 360; def->mode = comExpert | comSuSi; def->set_default_value(new ConfigOptionFloat(250));