Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative fix for 'encompassing hole' tree support issue #2152

Merged
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
Loading