From 87abd65ea40056ad2bee34f68940e0c4fea7bd6d Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 6 Apr 2023 20:48:58 +0800 Subject: [PATCH] FIX: do not allow support thresh angle to be 90 degrees tan(90\degrees) is too large and will make detect_overhangs very slow. Jira: STUDIO-2620 Change-Id: I55901a6bc1b56216549f66e1a7e77c0da680997b (cherry picked from commit e58cc8a4665808580e84107f54661447000d64f3) --- src/libslic3r/SupportMaterial.cpp | 12 ++++-------- src/libslic3r/TreeSupport.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index 32f5f8391b..38b3a9d514 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -1549,9 +1549,10 @@ static inline ExPolygons detect_overhangs( const bool buildplate_only = ! annotations.buildplate_covered.empty(); // If user specified a custom angle threshold, convert it to radians. // Zero means automatic overhang detection. - const double threshold_rad = (object_config.support_threshold_angle.value > 0) ? - M_PI * double(object_config.support_threshold_angle.value + 1) / 180. : // +1 makes the threshold inclusive - 0.; + // +1 makes the threshold inclusive + double thresh_angle = object_config.support_threshold_angle.value > 0 ? object_config.support_threshold_angle.value + 1 : 0; + thresh_angle = std::min(thresh_angle, 89.); // BBS should be smaller than 90 + const double threshold_rad = Geometry::deg2rad(thresh_angle); const coordf_t max_bridge_length = scale_(object_config.max_bridge_length.value); const bool bridge_no_support = object_config.bridge_no_support.value; const coordf_t xy_expansion = scale_(object_config.support_expansion.value); @@ -1731,11 +1732,6 @@ static inline std::tuple detect_contacts( // BBS. const bool auto_normal_support = object_config.support_type.value == stNormalAuto; const bool buildplate_only = !annotations.buildplate_covered.empty(); - // If user specified a custom angle threshold, convert it to radians. - // Zero means automatic overhang detection. - const double threshold_rad = (object_config.support_threshold_angle.value > 0) ? - M_PI * double(object_config.support_threshold_angle.value + 1) / 180. : // +1 makes the threshold inclusive - 0.; float no_interface_offset = 0.f; if (layer_id == 0) diff --git a/src/libslic3r/TreeSupport.cpp b/src/libslic3r/TreeSupport.cpp index 8c07dc37e9..2b7c2cbfb4 100644 --- a/src/libslic3r/TreeSupport.cpp +++ b/src/libslic3r/TreeSupport.cpp @@ -752,7 +752,10 @@ void TreeSupport::detect_overhangs(bool detect_first_sharp_tail_only) // a region is considered well supported if the number of layers below it exceeds this threshold const int thresh_layers_below = 10 / config.layer_height; double obj_height = m_object->size().z(); - double threshold_rad = (config.support_threshold_angle.value < EPSILON ? 30 : config.support_threshold_angle.value + 1) * M_PI / 180.; + // +1 makes the threshold inclusive + double thresh_angle = config.support_threshold_angle.value > EPSILON ? config.support_threshold_angle.value + 1 : 30; + thresh_angle = std::min(thresh_angle, 89.); // should be smaller than 90 + const double threshold_rad = Geometry::deg2rad(thresh_angle); // for small overhang removal struct OverhangCluster { @@ -3289,7 +3292,7 @@ void TreeSupport::generate_contact_points(std::vector 0) support_roof_layers += 1; // BBS: add a normal support layer below interface (if we have interface) - coordf_t thresh_angle = config.support_threshold_angle.value < EPSILON ? 30.f : config.support_threshold_angle.value; + coordf_t thresh_angle = std::min(89.f, config.support_threshold_angle.value < EPSILON ? 30.f : config.support_threshold_angle.value); coordf_t half_overhang_distance = scale_(tan(thresh_angle * M_PI / 180.0) * layer_height / 2); // fix bug of generating support for very thin objects