Skip to content

Commit

Permalink
Alternative fix for 'encompassing hole' tree support issue (#2152)
Browse files Browse the repository at this point in the history
  • Loading branch information
HellAholic authored Oct 23, 2024
2 parents eb91a7a + 16bfaa4 commit 3602113
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/TreeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2037,21 +2037,28 @@ void TreeSupport::filterFloatingLines(std::vector<Shape>& 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(relevant_forbidden, hole_aabb)).area() > hole.length() * EPSILON)
else if (! hole.intersection(PolygonUtils::clipPolygonWithAABB(outer_walls, hole_aabb)).empty())
{
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
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)
{
// 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);
}
Expand Down Expand Up @@ -2093,17 +2100,6 @@ void TreeSupport::filterFloatingLines(std::vector<Shape>& 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
{
Expand Down

0 comments on commit 3602113

Please sign in to comment.