fix(geometry): tighten circumscribed flattening; stop padding the validator
The Clipper validator flagged valid Opus55 and PEP layouts (P260805-03, P260626-03). Two causes: - Arc.ToPoints(circumscribe) scales every vertex out by 1/cos(step/2), endpoints included, so a 0.03125 corner fillet flattened at 0.01 poked 0.013 past the straight edges it meets. ClipperBridge now flattens itself: circumscribed arcs keep their endpoints on the arc and put interior vertices on tangent intersections, with the segment count chosen so the outward error stays within the tolerance. Arc.ToPoints is unchanged for its other callers. - The conservative padding made a layout exactly at the spacing fail. NestValidator now uses OffsetForValidation: the same conservative flattening, round joins at a tenth of the tolerance, no padding. Its only leniency is that join chord error at convex corners. With both, Opus55 is valid on all 26 benchmark jobs (25 before the Clipper migration; the old failure was a spike artifact). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -329,9 +329,10 @@ namespace OpenNest.Benchmark
|
||||
/// outward, cutouts offset inward, in one Clipper region offset). A cutout
|
||||
/// that closes up under the offset is dropped, which treats it as solid:
|
||||
/// conservative, since it has no room for another part at the required
|
||||
/// spacing anyway. The flattening is conservative too (perimeter arcs
|
||||
/// circumscribed, cutout arcs inscribed), so the check never passes a
|
||||
/// layout that is closer than the spacing.
|
||||
/// spacing anyway. Arcs are flattened conservatively (perimeter arcs
|
||||
/// circumscribed, cutout arcs inscribed) but nothing is padded, so a layout
|
||||
/// exactly at the spacing passes; the only leniency is the round-join chord
|
||||
/// error at convex corners (OutlineTolerance / 10).
|
||||
/// part.Program is already rotated; only a Location offset is needed.
|
||||
/// </summary>
|
||||
private static PartOutline Outline(Part part, double inflateBy)
|
||||
@@ -352,11 +353,10 @@ namespace OpenNest.Benchmark
|
||||
// Adaptive tolerance instead of Shape.ToPolygon()'s default (up to 1000
|
||||
// segments per arc) - arc-heavy real parts otherwise produce thousands
|
||||
// of vertices, which is needlessly slow for a spacing check.
|
||||
var region = ClipperBridge.Offset(
|
||||
var region = ClipperBridge.OffsetForValidation(
|
||||
profile,
|
||||
inflateBy > Tolerance.Epsilon ? inflateBy : 0,
|
||||
OutlineTolerance,
|
||||
circumscribe: true
|
||||
OutlineTolerance
|
||||
);
|
||||
|
||||
var perimeter = region.LargestOuter();
|
||||
|
||||
Reference in New Issue
Block a user