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)
This commit is contained in:
Arthur 2023-04-06 20:48:58 +08:00 committed by Lane.Wei
parent bc0fe0c8bc
commit 87abd65ea4
2 changed files with 9 additions and 10 deletions

View file

@ -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<std::vector<TreeSupport::N
size_t support_roof_layers = config.support_interface_top_layers.value;
if (support_roof_layers > 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