Skip to content

feat: add SameNetTraceMergeSolver to snap close parallel same-net traces#187

Open
lyfher wants to merge 1 commit intotscircuit:mainfrom
lyfher:feat/same-net-trace-merge-solver
Open

feat: add SameNetTraceMergeSolver to snap close parallel same-net traces#187
lyfher wants to merge 1 commit intotscircuit:mainfrom
lyfher:feat/same-net-trace-merge-solver

Conversation

@lyfher
Copy link
Copy Markdown

@lyfher lyfher commented Apr 15, 2026

Problem

When multiple traces on the same electrical net are routed with parallel segments close to each other (within ~0.05 units), they appear as separate nearly-overlapping lines instead of a clean single line.

Reproduction: site/examples/example28-same-net-trace-merge.page.tsx — two GND traces with segments at y=+0.025 and y=-0.025.

Solution

New SameNetTraceMergeSolver pipeline phase that runs after TraceCleanupSolver:

  1. Groups trace segments by globalConnNetId
  2. Finds pairs of parallel segments (horizontal or vertical) within GAP_THRESHOLD = 0.05
  3. Verifies ≥30% overlap in the parallel axis
  4. Snaps both segments to their median coordinate

Tests

6 unit tests covering:

  • Horizontal merge ✅
  • Vertical merge ✅
  • No merge across different nets ✅
  • No merge when gap > threshold ✅
  • No merge when segments don't overlap ✅
  • End-to-end pipeline test ✅

All 55 existing tests pass.

Fixes #29, fixes #34

…ce segments

Implements a new pipeline phase (SameNetTraceMergeSolver) that runs after
TraceCleanupSolver and snaps parallel trace segments belonging to the same
electrical net onto a shared coordinate when they are within 0.05 units of
each other with at least 30% overlap.

- Handles both horizontal and vertical segments
- Skips segments on different nets to prevent short circuits
- Includes 6 unit tests covering merge, no-merge (different net, too far, no overlap)
  and end-to-end pipeline test
- Adds example28 reproduction page showing the before/after

Fixes tscircuit#29, fixes tscircuit#34

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 15, 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 Apr 15, 2026 0:53am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants