Skip to content

fix: remove zero-length trace segments from duplicate consecutive points (#78)#396

Open
voltrace-io wants to merge 2 commits into
tscircuit:mainfrom
voltrace-io:voltrace-io/1779336875-fix-extra-trace-lines
Open

fix: remove zero-length trace segments from duplicate consecutive points (#78)#396
voltrace-io wants to merge 2 commits into
tscircuit:mainfrom
voltrace-io:voltrace-io/1779336875-fix-extra-trace-lines

Conversation

@voltrace-io
Copy link
Copy Markdown

Summary

Fixes #78 — extra trace lines in post-processing step.

Root cause: _applyBestRoute() in UntangleTraceSubsolver splices rerouted segments into the original trace path, which can produce consecutive duplicate boundary points. These zero-length segments survive the existing collinear-collapse pass in simplifyPath and render as extra trace lines in the schematic output.

Fix: Added removeDuplicateConsecutivePoints() to strip identical adjacent points (within floating-point epsilon) before each collinear-collapse pass in simplifyPath(). The function alternates dedup→collapse→dedup→collapse→dedup to ensure all zero-length segments are eliminated regardless of ordering.

Result: example35 snapshot reduced by 35 SVG lines, confirming extra trace removal.

/claim #78

Review & Testing Checklist for Human

  • Verify example35 snapshot diff shows trace improvement (fewer overlapping lines), not regression
  • Run bun test — should see 67 pass, 4 skip, 0 fail
  • Check that the epsilon tolerance (1e-9) in removeDuplicateConsecutivePoints does not incorrectly merge nearby but distinct points in dense schematics

Notes

  • 8 new unit tests cover: duplicate points at start/middle/end, multiple consecutive duplicates, zero-length two-point paths, collinear collapse, and duplicates at direction changes
  • The collinear-collapse logic is unchanged — only the dedup preprocessing is new
  • simplifyPath is called during the post-processing cleanup pipeline, so this fix applies to all traces automatically

@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
schematic-trace-solver Ready Ready Preview, Comment May 22, 2026 12:42am

Request Review

voltrace-io and others added 2 commits May 22, 2026 00:41
…nts in simplifyPath

Root cause: _applyBestRoute() in UntangleTraceSubsolver splices rerouted
segments into the original trace path, which can produce consecutive
duplicate boundary points. These zero-length segments survive the
collinear-collapse pass and render as extra trace lines in the schematic.

Fix: Added removeDuplicateConsecutivePoints() to strip identical adjacent
points before each collinear-collapse pass in simplifyPath(). The function
runs dedup-collapse-dedup-collapse-dedup to ensure all zero-length segments
are eliminated regardless of ordering.

Tests: 8 new unit tests for duplicate point removal. Updated example35
snapshot (35 fewer SVG lines, confirming extra trace removal).

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@voltrace-io voltrace-io force-pushed the voltrace-io/1779336875-fix-extra-trace-lines branch from 0202790 to 95fc820 Compare May 22, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix extra trace lines in post-processing step

1 participant