fix(cutting): replay seams whose bridge lengthens the cut

A nominal ring may close within NominalContourClosure.Tolerance, and replay
already carried that admitted gap as slack when bridging it shortens the cut.
When the gap instead lies across the following edge, the emitted path starts
that edge at the ring's end point, so the cut is longer by the gap. Two checks
still compared at the exact epsilon and refused it as "invalid input":

- the retrace guard rejected any surplus length beyond 1e-8;
- Follows matched the edge's leftover sliver against the next nominal entity
  and failed its direction check.

Both now use the ring's admitted slack, the same bound the shortfall and the
nominal side of Follows already use. Exactly closed rings keep the epsilon, and
a second circuit still exceeds the slack by a whole ring.

A0227-08's sprocket outline misses its start by 1e-6 and refused planning in
both keep-order and reorder modes; it now plans Ready and applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-10-16 09:55:49 -04:00
1 parent 21e1aee342
commit 017e06de2d
2 files changed
+35 -3

No files matched your search

@@ -77,6 +77,35 @@ public class SeamClosureReplayTests
Assert.True(result.IndependentlyReplayed);
}
[Theory]
[InlineData(5e-7)]
[InlineData(1e-6)]
public void AdmittedClosureSeam_ThatLengthensThePath_StillReplays(double seam)
{
// The ring stops short of its start across the following edge, so bridging the seam adds
// up to the admitted gap to the cut length and extends that edge before the next corner
// (A0227-08's sprocket outline). Entering on the top edge puts the seam mid-path.
var program = new Program();
program.MoveTo(0, 0);
program.LineTo(0, 10);
program.LineTo(10, 10);
program.LineTo(10, 0);
program.LineTo(0, -seam);
var settings = ExplicitContourTests.Parameters();
var part = new Part(new Drawing("seam", program));
var snapshot = Capture(part, settings);
var source = snapshot.Placements[0];
Assert.True(source.Material!.IsComplete, source.Material.Reason);
var choice = source.Prepared!.Entry(0, 1, new Vector(5, 10));
var emitted = source.Prepared.Emit([choice]);
var result = CuttingPlanService.ReplayPrograms(snapshot,
[source.Propose(emitted, Read(emitted), [choice])], 0, default);
Assert.Equal(CuttingPlanStatus.Ready, result.Status);
Assert.True(result.IndependentlyReplayed);
}
[Fact]
public void AdmittedClosureSeam_StillPlansWithGeneratedLeadIns()
{