From e7a21ce0e1e7aabeaf8ecfe09771deb05edf11a3 Mon Sep 17 00:00:00 2001 From: Arthur Date: Sat, 6 May 2023 14:52:49 +0800 Subject: [PATCH] FIX: support blockers in tree support not working after mirroring This is caused by the inverse-order polgyons after mirroring. Adding a union_ before offset_ex fixes this bug. Github: #1621 Jira: 2738 Change-Id: I885a3ca6af4e5fadb2158d913cf67525bfffa91e (cherry picked from commit 4ea95d89e7ec058ac21218e1839cfe16b486893a) --- src/libslic3r/TreeSupport.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/TreeSupport.cpp b/src/libslic3r/TreeSupport.cpp index d52e81da7b..e880cf022b 100644 --- a/src/libslic3r/TreeSupport.cpp +++ b/src/libslic3r/TreeSupport.cpp @@ -1106,7 +1106,9 @@ void TreeSupport::detect_overhangs(bool detect_first_sharp_tail_only) if (layer_nr < blockers.size()) { Polygons& blocker = blockers[layer_nr]; - ts_layer->overhang_areas = diff_ex(ts_layer->overhang_areas, offset_ex(blocker, scale_(radius_sample_resolution))); + // Arthur: union_ is a must because after mirroring, the blocker polygons are in left-hand coordinates, ie clockwise, + // which are not valid polygons, and will be removed by offset_ex. union_ can make these polygons right. + ts_layer->overhang_areas = diff_ex(ts_layer->overhang_areas, offset_ex(union_(blocker), scale_(radius_sample_resolution))); } if (max_bridge_length > 0 && ts_layer->overhang_areas.size() > 0 && lower_layer) { @@ -1137,13 +1139,14 @@ void TreeSupport::detect_overhangs(bool detect_first_sharp_tail_only) #ifdef SUPPORT_TREE_DEBUG_TO_SVG for (const SupportLayer* layer : m_object->support_layers()) { - if (layer->overhang_areas.empty()) + if (layer->overhang_areas.empty() && blockers[layer->id()].empty()) continue; SVG svg(format("SVG/overhang_areas_%s.svg", layer->print_z), m_object->bounding_box()); if (svg.is_opened()) { svg.draw_outline(m_object->get_layer(layer->id())->lslices, "yellow"); - svg.draw(layer->overhang_areas, "red"); + svg.draw(layer->overhang_areas, "orange"); + svg.draw(blockers[layer->id()], "red"); for (auto& overhang : layer->overhang_areas) { double aarea = overhang.area()/ area_thresh_well_supported; auto pt = get_extents(overhang).center();