fix: remove self-intersecting loops from polygon offset

Polygon offset at concave corners creates geometry that folds back
through itself. Added RemoveSelfIntersections() to Polygon that
detects non-adjacent edge crossings and removes the smaller loop
at each crossing. Applied to both collision detection and rendering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 22:23:44 -05:00
parent 08b31d0797
commit 4d270ae68e
3 changed files with 128 additions and 2 deletions

View File

@@ -789,6 +789,7 @@ namespace OpenNest
continue;
var polygon = offsetEntity.ToPolygonWithTolerance(PushChordTolerance);
polygon.RemoveSelfIntersections();
polygon.Offset(part.Location);
lines.AddRange(polygon.ToLines());
}
@@ -810,6 +811,7 @@ namespace OpenNest
continue;
var polygon = offsetEntity.ToPolygonWithTolerance(PushChordTolerance);
polygon.RemoveSelfIntersections();
polygon.Offset(part.Location);
lines.AddRange(GetDirectionalLines(polygon, facingDirection));
}