From ba3c3cbea365d303b710a6cbbc9988d917eee00e Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Fri, 10 Apr 2026 08:17:35 -0400 Subject: [PATCH] fix: draw sub-program rapid directly to lead-in pierce MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- OpenNest/Controls/PlateRenderer.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/OpenNest/Controls/PlateRenderer.cs b/OpenNest/Controls/PlateRenderer.cs index 8f2e4c0..9af15dc 100644 --- a/OpenNest/Controls/PlateRenderer.cs +++ b/OpenNest/Controls/PlateRenderer.cs @@ -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)