Skip to content

fix: remove extra trace lines from duplicate segments#131

Open
blessuselessk wants to merge 1 commit intotscircuit:mainfrom
blessuselessk:fix/extra-trace-lines-issue78
Open

fix: remove extra trace lines from duplicate segments#131
blessuselessk wants to merge 1 commit intotscircuit:mainfrom
blessuselessk:fix/extra-trace-lines-issue78

Conversation

@blessuselessk
Copy link

@blessuselessk blessuselessk commented Mar 18, 2026

/claim #78

Summary

Fixes extra trace lines caused by two root causes:

Root Cause 1: Within-trace duplicate points

UntangleTraceSubsolver._applyBestRoute() concatenates path slices when replacing an L-shaped turn. The junction between old and new path can produce duplicate consecutive points (zero-length segments). Fixed by applying removeDuplicateConsecutivePoints after concatenation.

Root Cause 2: Cross-trace segment overlap

Multiple MSP pairs in the same net share a pin and get routed independently by SchematicTraceSingleLineSolver2. Both routes draw through the same physical segment near the shared pin, producing visible duplicate lines. Fixed by removeNetSegmentDuplicates which trims shared segments from the start/end of later traces within the same net.

Changes

  • simplifyPath.ts: Added removeDuplicateConsecutivePoints utility
  • UntangleTraceSubsolver.ts: Apply dedup after path concatenation in _applyBestRoute
  • removeNetSegmentDuplicates.ts: New — trims duplicate segments between same-net traces
  • TraceCleanupSolver.ts: Apply cross-trace dedup at output time
  • Updated 4 SVG snapshots (examples 02, 13, 15, 29) — all show reduced overlapping lines

Test plan

  • All 49 tests pass
  • TypeScript compiles clean
  • Biome format clean
  • 4 snapshot updates reflect fewer duplicate trace lines

Two root causes for extra trace lines:

1. Within-trace: _applyBestRoute() concatenates path slices which can
   produce duplicate consecutive points (zero-length segments). Fixed by
   applying removeDuplicateConsecutivePoints after path concatenation.

2. Cross-trace: Multiple MSP pairs in the same net share a pin and get
   routed independently, producing overlapping segments near the shared
   pin. Fixed by trimming duplicate segments from the start/end of later
   traces within the same net at output time.

Closes tscircuit#78
@vercel
Copy link

vercel bot commented Mar 18, 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 Mar 18, 2026 7:37pm

Request Review

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.

1 participant