refactor(geometry): move polygon offset callers onto ClipperBridge
Per-entity offsetting left spikes and inverted loops wherever a feature is narrower than the spacing (1.nest), and RemoveSelfIntersections only caught proper crossings. The callers that already flatten to polygons now take a single Clipper region offset instead: - PolygonHelper (BestFit) and PartBoundary use the conservative mode, which keeps their never-under-estimate guarantee. PartBoundary also keeps holes that appear when a perimeter curls back on itself. - NestValidator offsets perimeter and cutouts in one region; Clipper drops collapsed cutouts, so the collapsed-or-flipped heuristic goes away. - CutOff.IntersectPerimeter offsets through the bridge. The old OffsetEntity(Left) grew CW perimeters but shrank CCW ones, so with the plate's perimeter cache a cut-off ran through the part; slots narrower than twice the clearance now close up instead of leaving a gap. - GetOffsetPartLines (3 overloads) and the AddOffset* helpers had no callers and are removed, as is EntityView's never-defined DRAW_OFFSET block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,19 +34,16 @@ namespace OpenNest.Engine.Fill
|
||||
|
||||
if (perimeter != null)
|
||||
{
|
||||
var offsetEntity = perimeter.OffsetOutward(spacing);
|
||||
|
||||
if (offsetEntity != null)
|
||||
{
|
||||
// Circumscribe arcs so polygon vertices are always outside
|
||||
// the true arc — guarantees the boundary never under-estimates.
|
||||
var polygon = offsetEntity.ToPolygonWithTolerance(
|
||||
PolygonTolerance,
|
||||
circumscribe: true
|
||||
);
|
||||
polygon.RemoveSelfIntersections();
|
||||
_polygons.Add(polygon);
|
||||
}
|
||||
// Conservative offset: the boundary never under-estimates the spacing.
|
||||
// Holes appear only where the perimeter curls back on itself.
|
||||
var offset = ClipperBridge.OffsetPerimeter(
|
||||
perimeter,
|
||||
spacing,
|
||||
PolygonTolerance,
|
||||
circumscribe: true
|
||||
);
|
||||
_polygons.AddRange(offset.Outers);
|
||||
_polygons.AddRange(offset.Holes);
|
||||
}
|
||||
|
||||
PrecomputeDirectionalEdges(
|
||||
|
||||
Reference in New Issue
Block a user