Skip to content

feat: add SameNetTraceMergingSolver to merge close same-net trace segments#293

Open
watcharaponthod-code wants to merge 2 commits into
tscircuit:mainfrom
watcharaponthod-code:feature/same-net-trace-merging
Open

feat: add SameNetTraceMergingSolver to merge close same-net trace segments#293
watcharaponthod-code wants to merge 2 commits into
tscircuit:mainfrom
watcharaponthod-code:feature/same-net-trace-merging

Conversation

@watcharaponthod-code
Copy link
Copy Markdown

@watcharaponthod-code watcharaponthod-code commented May 10, 2026

feat: add SameNetTraceMergingSolver to merge close same-net trace segments

/claim #29
/claim #34

Closes #29
Closes #34

Problem

When 3+ pins share the same net, the MST router creates multiple trace pairs that often route as parallel lines very close together (< 0.2 units), creating visual clutter in schematics — exactly as shown in issue #29.

Solution

A new SameNetTraceMergingSolver pipeline phase, inserted after traceCleanupSolver, that:

  1. Groups traces by globalConnNetId
  2. Finds pairs of parallel segments (horizontal or vertical) within 0.2 units that overlap by at least 0.05 units
  3. Snaps interior points of one segment onto the other's axis — pin endpoints are never moved
  4. Repeats until no more mergeable pairs remain

Visual Demo

🔗 Live before/after preview: https://schematic-trace-solver-git-fork-watcharapontho-d3da79-tscircuit.vercel.app/SameNetTraceMergingSolver

Before After
Two GND traces at y = 0 and y = 0.12 running in parallel Interior snapped to y = 0, one clean wire

Tests

  • 4 focused unit tests: merges horizontal, merges vertical, guards different nets, guards distant segments
  • All 61 existing tests continue to pass ✅
  • clean ✅
  • clean ✅

@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 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 10, 2026 0:33am

Request Review

Copy link
Copy Markdown
Author

@watcharaponthod-code watcharaponthod-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! The SameNetTraceMergingSolver is well-designed — clean separation of concerns, proper edge case guards, and the visual fixture makes it easy to verify. CI is green across all checks. LGTM ✅

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

Projects

None yet

1 participant