Skip to content

feat: add SameNetTraceCombiningSolver to merge close collinear same-net traces (#34)#277

Open
irisdigitaldocs-maker wants to merge 1 commit intotscircuit:mainfrom
irisdigitaldocs-maker:fix/merge-same-net-close-traces-34
Open

feat: add SameNetTraceCombiningSolver to merge close collinear same-net traces (#34)#277
irisdigitaldocs-maker wants to merge 1 commit intotscircuit:mainfrom
irisdigitaldocs-maker:fix/merge-same-net-close-traces-34

Conversation

@irisdigitaldocs-maker
Copy link
Copy Markdown

Summary

Implements issue #34: adds a new SameNetTraceCombiningSolver pipeline phase that merges same-net trace lines that are close together.

/claim #34

How It Works

  1. Groups traces by globalConnNetId
  2. Extracts all axis-aligned segments (horizontal/vertical) from each trace path
  3. Finds pairs on the same net where:
    • Both are parallel (same direction)
    • Perpendicular distance between them ≤ 0.05 units (collinear tolerance)
    • Parallel axis ranges overlap or gap ≤ 0.15 units
  4. Snaps interior segment endpoints of one trace to match the other's coordinate
  5. Simplifies the resulting path (removes collinear redundant points)
  6. Repeats until no more snappable pairs remain

The solver is inserted into the pipeline after traceCleanupSolver and before the second netLabelPlacementSolver pass, so label placement adapts to the merged trace layout.

Testing

bun test tests/solvers/SameNetTraceCombiningSolver/SameNetTraceCombiningSolver.test.ts

5 tests covering:

  • Snapping close horizontal segments on the same net ✓
  • Snapping close vertical segments on the same net ✓
  • No snapping across different nets ✓
  • No snapping when segments are too far apart in Y/X ✓
  • No snapping when segments don't overlap in the parallel axis ✓

All 36 example tests pass (with updated snapshots for examples 18 and 19 which now show improved merged trace layout).

…et traces

Implements issue tscircuit#34: adds a new pipeline phase that groups schematic traces
by globalConnNetId and snaps near-parallel segments onto the same axis
coordinate (same Y for horizontal, same X for vertical).

Algorithm:
- Groups traces by globalConnNetId
- Extracts axis-aligned segments from each trace path
- Finds pairs where |coord_A - coord_B| <= 0.05 (collinear tolerance)
  and x/y ranges overlap or gap <= 0.15 units
- Snaps the interior segment endpoints of one trace to match the other
- Iterates until no more snappable pairs remain

/claim tscircuit#34

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 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 5, 2026 2:23am

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