fix: draw sub-program rapid directly to lead-in pierce
The SubProgramCall branch in DrawRapids used to draw a rapid from the previous feature's end to the hole center, then rely on the sub-program's own first rapid to draw from center to the lead-in pierce. That rendered a phantom center-hop segment that doesn't exist physically — a SubProgramCall is a coordinate-frame shift (emitted as a G52 bracket on Cincinnati), not a move to the hole center. Look ahead through the sub-program for its first pierce point in absolute coordinates and draw a single direct rapid from pos to that pierce. Recurse into the sub with skipFirstRapid: true so the sub's first rapid isn't drawn again on top. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -425,13 +425,21 @@ namespace OpenNest.Controls
|
||||
|
||||
if (code is SubProgramCall { Program: { } program } call)
|
||||
{
|
||||
// A SubProgramCall is a coordinate-frame shift, not a physical
|
||||
// rapid to the hole center. The Cincinnati post emits it as a
|
||||
// G52 bracket, so the physical rapid is the sub-program's first
|
||||
// motion, which goes straight from here to the lead-in pierce.
|
||||
// Look ahead for that pierce point and draw the direct rapid,
|
||||
// then recurse with skipFirstRapid so the sub doesn't also draw
|
||||
// its first rapid on top. See docs/cincinnati-post-output.md.
|
||||
var holeBase = basePos + call.Offset;
|
||||
var firstPierce = GetFirstPiercePoint(program, holeBase);
|
||||
|
||||
if (ShouldDrawRapid(skipFirstRapid, ref firstRapidSkipped))
|
||||
DrawLine(g, pos, holeBase, view.ColorScheme.RapidPen);
|
||||
DrawLine(g, pos, firstPierce, view.ColorScheme.RapidPen);
|
||||
|
||||
var subPos = holeBase;
|
||||
DrawRapids(g, program, holeBase, ref subPos);
|
||||
DrawRapids(g, program, holeBase, ref subPos, skipFirstRapid: true);
|
||||
pos = subPos;
|
||||
}
|
||||
else if (code is Motion motion)
|
||||
|
||||
Reference in New Issue
Block a user