From 4bab300e18599a0739e5ce8fb2d6ee8ede2e06ce Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 8 Dec 2022 15:11:39 +0800 Subject: [PATCH] ENH: sync with master on sharp tail and cantilever detection Change-Id: Id514d47d868fd02a8ac02ef85ef33ef48a2bd7c7 --- src/libslic3r/SupportMaterial.cpp | 14 ++++++++++++-- src/libslic3r/TreeSupport.cpp | 16 ++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index f7c4f28692..4e1bc667cb 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -1518,6 +1518,16 @@ static inline Polygons detect_overhangs( { // Don't fill in the holes. The user may apply a higher raft_expansion if one wants a better 1st layer adhesion. overhang_polygons = to_polygons(layer.lslices); + + for (auto& slice : layer.lslices) { + auto bbox_size = get_extents(slice).size(); + if (g_config_support_sharp_tails && + !(bbox_size.x() > length_thresh_well_supported && bbox_size.y() > length_thresh_well_supported)) + { + layer.sharp_tails.push_back(slice); + layer.sharp_tails_height.insert({ &slice, layer.height }); + } + } } else if (! layer.regions().empty()) { @@ -1609,12 +1619,12 @@ static inline Polygons detect_overhangs( supported_area += temp.area(); bbox.merge(get_extents(temp)); } - +#if 0 if (supported_area > area_thresh_well_supported) { is_sharp_tail = false; break; } - +#endif if (bbox.size().x() > length_thresh_well_supported && bbox.size().y() > length_thresh_well_supported) { is_sharp_tail = false; break; diff --git a/src/libslic3r/TreeSupport.cpp b/src/libslic3r/TreeSupport.cpp index 935c5236e9..6bfc5cf2fb 100644 --- a/src/libslic3r/TreeSupport.cpp +++ b/src/libslic3r/TreeSupport.cpp @@ -844,9 +844,13 @@ void TreeSupport::detect_object_overhangs() if (layer->lower_layer == nullptr) { for (auto& slice : layer->lslices) { auto bbox_size = get_extents(slice).size(); - if (slice.area() > area_thresh_well_supported - || (bbox_size.x()>length_thresh_well_supported && bbox_size.y()>length_thresh_well_supported)) + if (/*slice.area() > area_thresh_well_supported || */ + (bbox_size.x()>length_thresh_well_supported && bbox_size.y()>length_thresh_well_supported)) regions_well_supported.emplace_back(slice); + else if(g_config_support_sharp_tails){ + layer->sharp_tails.push_back(slice); + layer->sharp_tails_height.insert({ &slice, layer->height }); + } } continue; } @@ -932,12 +936,13 @@ void TreeSupport::detect_object_overhangs() // 2.2 If sharp tail below, check whether it support this region enough. float supported_area = area(supported_by_lower); BoundingBox bbox = get_extents(supported_by_lower); - +#if 0 + // judge by area isn't reliable, failure cases include 45 degree rotated cube if (supported_area > area_thresh_well_supported) { is_sharp_tail = false; break; } - +#endif if (bbox.size().x() > length_thresh_well_supported && bbox.size().y() > length_thresh_well_supported) { is_sharp_tail = false; break; @@ -950,7 +955,6 @@ void TreeSupport::detect_object_overhangs() break; } } - if (accum_height >= sharp_tail_max_support_height) { is_sharp_tail = false; break; @@ -1061,7 +1065,7 @@ void TreeSupport::detect_object_overhangs() } dist_max = std::max(dist_max, dist_pt); } - if (dist_max > scale_(5)) { // this cluster is cantilever, add all expolygons to sharp tail + if (dist_max > scale_(3)) { // this cluster is cantilever if the farmost point is larger than 3mm away from base for (auto it = cluster.layer_overhangs.begin(); it != cluster.layer_overhangs.end(); it++) { int layer_nr = it->first; auto p_overhang = it->second;