From fbbfb06f6b9f3c8328b195435cc0ec19e9797e6d Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 13 Apr 2023 10:22:46 +0800 Subject: [PATCH] ENH: make tree support much smoother We increase the smooth iterations from 1 to 50. Change-Id: Iba883fd67d7a9a71c92b364dcc9b76e00fc45820 (cherry picked from commit 945fba20a5629148bfd8cee47f492d42c50f9824) --- 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 865120f6a..c37b63879 100644 --- a/src/libslic3r/TreeSupport.cpp +++ b/src/libslic3r/TreeSupport.cpp @@ -2719,6 +2719,10 @@ void TreeSupport::drop_nodes(std::vector>& contact_nodes) next_node->is_merged = true; contact_nodes[layer_nr_next].push_back(next_node); + // make sure the trees are all connected + if (node.parent) node.parent->child = next_node; + if (neighbour->parent) neighbour->parent->child = next_node; + // Make sure the next pass doesn't drop down either of these (since that already happened). node.merged_neighbours.push_front(neighbour); to_delete.insert(neighbour); @@ -3018,7 +3022,7 @@ void TreeSupport::smooth_nodes(std::vector> &contact_nodes) std::vector pts1 = pts; // TODO here we assume layer height gap is constant. If not true, need to consider height jump // TODO it seems the smooth iterations can't be larger than 1, otherwise some nodes will fly away - for (size_t k = 0; k < 1; k++) { + for (size_t k = 0; k < 50; k++) { for (size_t i = 1; i < pts.size() - 1; i++) { size_t i2 = i >= 2 ? i - 2 : 0; size_t i3 = i < pts.size() - 2 ? i + 2 : pts.size() - 1; @@ -3029,8 +3033,7 @@ void TreeSupport::smooth_nodes(std::vector> &contact_nodes) } for (size_t i = 1; i < pts.size() - 1; i++) { if (!is_processed[branch[i]]) { - // do not move if the new position is too far away - if (vsize2_with_unscale(branch[i]->position - pts[i]) < SQ(m_support_params.support_extrusion_width * 2)) { branch[i]->position = pts[i]; } + branch[i]->position = pts[i]; branch[i]->movement = branch[i]->parent ? (branch[i]->position - branch[i]->parent->position) : Point(0, 0); is_processed[branch[i]] = true; }