From 762f8483015b5058820f58b7b34d660fdaed694e Mon Sep 17 00:00:00 2001 From: Thomas Rahm <67757218+ThomasRahm@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:37:17 +0200 Subject: [PATCH 1/5] Revert "Fix 'encompassing hole' issue (tree support)." This reverts commit 1752db52531887c67b7bbc4218cf85e1619537f8. --- src/TreeSupport.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/TreeSupport.cpp b/src/TreeSupport.cpp index 783807e002..67a68e1cf6 100644 --- a/src/TreeSupport.cpp +++ b/src/TreeSupport.cpp @@ -2093,17 +2093,6 @@ void TreeSupport::filterFloatingLines(std::vector& support_layer_storage) if (! found) { next_removed_holes_by_idx.emplace(idx); - - // Individual pieces of the hole could still be valid (if the 'hole' is made by branches surrounding others' for instance). - for (const auto& poly : hole) - { - if (poly.area() < 0) - { - auto poly_copy = poly; - poly_copy.reverse(); - valid_holes[layer_idx].push_back(poly_copy); - } - } } else { From bd1fc3e8e7e9b557956abdb880427740391683cc Mon Sep 17 00:00:00 2001 From: Thomas Rahm <67757218+ThomasRahm@users.noreply.github.com> Date: Wed, 5 Jun 2024 00:29:02 +0200 Subject: [PATCH 2/5] Revert "Tree-support: Create more dissalowed area; prevents model-intersection." This reverts commit 885352e9 --- src/TreeSupport.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/TreeSupport.cpp b/src/TreeSupport.cpp index 67a68e1cf6..21a34796de 100644 --- a/src/TreeSupport.cpp +++ b/src/TreeSupport.cpp @@ -2023,8 +2023,10 @@ void TreeSupport::filterFloatingLines(std::vector& support_layer_storage) return; } - const Shape& relevant_forbidden = volumes_.getCollision(0, layer_idx, true); - Shape outer_walls = TreeSupportUtils::toPolylines(support_layer_storage[layer_idx - 1].getOutsidePolygons()).createTubeShape(closing_dist, 0); + Shape outer_walls = TreeSupportUtils::toPolylines(support_layer_storage[layer_idx - 1].getOutsidePolygons()) + .createTubeShape( + closing_dist, + 0); //.unionPolygons(volumes_.getCollision(0, layer_idx - 1, true).offset(-(config.support_line_width+config.xy_min_distance))); Shape holes_below; @@ -2041,11 +2043,6 @@ void TreeSupport::filterFloatingLines(std::vector& support_layer_storage) { holes_resting_outside[layer_idx].emplace(idx); } - else if (hole.intersection(PolygonUtils::clipPolygonWithAABB(relevant_forbidden, hole_aabb)).area() > hole.length() * EPSILON) - { - holes_resting_outside[layer_idx].emplace( - idx); // technically not resting outside, also not valid, but the alternative is potentially having lines go though the model - } else { for (auto [idx2, hole2] : holeparts[layer_idx - 1] | ranges::views::enumerate) From 3600ea9514696d1da0e548a34c6b15b57fd7cc0f Mon Sep 17 00:00:00 2001 From: Thomas Rahm <67757218+ThomasRahm@users.noreply.github.com> Date: Wed, 5 Jun 2024 00:29:02 +0200 Subject: [PATCH 3/5] Fix issue causing support lines to overlap with the model --- src/TreeSupport.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/TreeSupport.cpp b/src/TreeSupport.cpp index 21a34796de..7d5380478a 100644 --- a/src/TreeSupport.cpp +++ b/src/TreeSupport.cpp @@ -2023,6 +2023,7 @@ void TreeSupport::filterFloatingLines(std::vector& support_layer_storage) return; } + Shape relevant_forbidden = volumes_.getCollision(0, layer_idx, true); Shape outer_walls = TreeSupportUtils::toPolylines(support_layer_storage[layer_idx - 1].getOutsidePolygons()) .createTubeShape( closing_dist, @@ -2043,6 +2044,11 @@ void TreeSupport::filterFloatingLines(std::vector& support_layer_storage) { holes_resting_outside[layer_idx].emplace(idx); } + else if (! hole.intersection(PolygonUtils::clipPolygonWithAABB(relevant_forbidden, hole_aabb)).offset(-config.xy_min_distance / 2).empty()) + { + // technically not resting outside, also not valid, but the alternative is potentially having lines go through the model + holes_resting_outside[layer_idx].emplace(idx); + } else { for (auto [idx2, hole2] : holeparts[layer_idx - 1] | ranges::views::enumerate) From 469be9c4ec047209e3a44abfa6f5ee657d0e5789 Mon Sep 17 00:00:00 2001 From: Thomas Rahm <67757218+ThomasRahm@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:46:36 +0200 Subject: [PATCH 4/5] Fix issue with tree support hole removal if the hole compasses other branches. Prevents removal of holes with holes. Also added a performance improvement found while debugging. --- src/TreeSupport.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/TreeSupport.cpp b/src/TreeSupport.cpp index 7d5380478a..ead27ed820 100644 --- a/src/TreeSupport.cpp +++ b/src/TreeSupport.cpp @@ -2024,10 +2024,7 @@ void TreeSupport::filterFloatingLines(std::vector& support_layer_storage) } Shape relevant_forbidden = volumes_.getCollision(0, layer_idx, true); - Shape outer_walls = TreeSupportUtils::toPolylines(support_layer_storage[layer_idx - 1].getOutsidePolygons()) - .createTubeShape( - closing_dist, - 0); //.unionPolygons(volumes_.getCollision(0, layer_idx - 1, true).offset(-(config.support_line_width+config.xy_min_distance))); + Shape outer_walls = TreeSupportUtils::toPolylines(support_layer_storage[layer_idx - 1].getOutsidePolygons()).createTubeShape(closing_dist, 0); Shape holes_below; @@ -2040,7 +2037,13 @@ void TreeSupport::filterFloatingLines(std::vector& support_layer_storage) { AABB hole_aabb = AABB(hole); hole_aabb.expand(EPSILON); - if (! hole.intersection(PolygonUtils::clipPolygonWithAABB(outer_walls, hole_aabb)).empty()) + if(hole.size() > 1) + { + // The hole contains other branches! It can not be fully removed. + // This may not fully handle this case as there could be a situation where such a hole becomes invalid, but for now this is the best solution not requiring larger changes. + holes_resting_outside[layer_idx].emplace(idx); + } + else if (! hole.intersection(PolygonUtils::clipPolygonWithAABB(outer_walls, hole_aabb)).empty()) { holes_resting_outside[layer_idx].emplace(idx); } @@ -2053,8 +2056,9 @@ void TreeSupport::filterFloatingLines(std::vector& support_layer_storage) { for (auto [idx2, hole2] : holeparts[layer_idx - 1] | ranges::views::enumerate) { + // TODO should technically be outline: Check if this is fine either way as it would save an offset if (hole_aabb.hit(AABB(hole2)) - && ! hole.intersection(hole2).empty()) // TODO should technically be outline: Check if this is fine either way as it would save an offset + && ! hole.intersection(PolygonUtils::clipPolygonWithAABB(hole2, hole_aabb)).empty()) { hole_rest_map[layer_idx][idx].emplace_back(idx2); } From 8de3babdb0a6360b477956ba3b0cb4501e9ff877 Mon Sep 17 00:00:00 2001 From: Thomas Rahm <67757218+ThomasRahm@users.noreply.github.com> Date: Tue, 22 Oct 2024 11:11:01 +0200 Subject: [PATCH 5/5] Restore a small change mistakenly undone by a previous commit. --- src/TreeSupport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TreeSupport.cpp b/src/TreeSupport.cpp index ead27ed820..8268bc2e9c 100644 --- a/src/TreeSupport.cpp +++ b/src/TreeSupport.cpp @@ -2023,7 +2023,7 @@ void TreeSupport::filterFloatingLines(std::vector& support_layer_storage) return; } - Shape relevant_forbidden = volumes_.getCollision(0, layer_idx, true); + const Shape& relevant_forbidden = volumes_.getCollision(0, layer_idx, true); Shape outer_walls = TreeSupportUtils::toPolylines(support_layer_storage[layer_idx - 1].getOutsidePolygons()).createTubeShape(closing_dist, 0); Shape holes_below;