Skip to content

fix: remove duplicate trace segments in same-net routing (issue #78)#126

Open
Nicolas-Rozas wants to merge 1 commit intotscircuit:mainfrom
Nicolas-Rozas:fix/remove-duplicate-trace-segments-78
Open

fix: remove duplicate trace segments in same-net routing (issue #78)#126
Nicolas-Rozas wants to merge 1 commit intotscircuit:mainfrom
Nicolas-Rozas:fix/remove-duplicate-trace-segments-78

Conversation

@Nicolas-Rozas
Copy link

/claim #78

Root Cause

SchematicTraceLinesSolver solves each MSP connection pair independently. When two pairs in the same net share a pin, both route through the same physical segment near that shared endpoint — producing "extra trace lines" in the rendered schematic.

Fix

1. Cross-trace deduplication — removeNetSegmentDuplicates.ts (new)

Groups traces by net, finds segments that appear in more than one trace, and trims those redundant endpoint segments from later traces. The net remains visually connected through the first trace that claimed the segment.

Applied as input preprocessing in the TraceCleanupSolver constructor so all downstream cleanup steps (turn minimization, Z-shape balancing) operate on clean data from the start.

2. Within-trace deduplication — simplifyPath.ts

Added removeDuplicateConsecutivePoints called at the top of simplifyPath. This removes zero-length segments that UntangleTraceSubsolver can introduce at path-concatenation junctions.

Tests

  • 4 new unit tests in tests/solvers/TraceCleanupSolver/removeNetSegmentDuplicates.test.ts
  • Full pipeline regression test using OverlapAvoidanceStepSolver fixture asserting zero duplicate segments
  • Updated snapshots for examples 02, 13, 15 (now show cleaner trace output)
  • All 53 tests pass ✅

…sue tscircuit#78)

When the MSP solver independently routes multiple pin pairs in the same net,
two traces can share a physical segment near shared pins, producing "extra
trace lines" in the schematic output.

Changes:
- Add `removeNetSegmentDuplicates` utility that detects cross-trace duplicate
  segments within the same net and trims redundant endpoint segments from
  later traces (the net remains visually connected through the first trace)
- Apply deduplication as input preprocessing in `TraceCleanupSolver` so all
  subsequent cleanup steps (turn minimization, Z-shape balancing) work on
  clean data from the start
- Add `removeDuplicateConsecutivePoints` in `simplifyPath` to also handle
  zero-length within-trace segments from UntangleTraceSubsolver path
  concatenation
- Update snapshots for examples 02, 13, 15 which now show cleaner output
- Add test suite covering both fix types and a full-pipeline regression test
@vercel
Copy link

vercel bot commented Mar 11, 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 11, 2026 5:05pm

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