Skip to content

feat: merge same-net trace lines that are close together#192

Open
tarai-dl wants to merge 1 commit intotscircuit:mainfrom
tarai-dl:rn/merge-same-net-traces
Open

feat: merge same-net trace lines that are close together#192
tarai-dl wants to merge 1 commit intotscircuit:mainfrom
tarai-dl:rn/merge-same-net-traces

Conversation

@tarai-dl
Copy link
Copy Markdown

Summary

This PR adds a new SameNetTraceMergerSolver that merges same-net trace lines that are close together (at the same Y for horizontal segments or the same X for vertical segments).

Changes

  • Added SameNetTraceMergerSolver in lib/solvers/SameNetTraceMergerSolver/
  • Integrated the solver into the pipeline after TraceCleanupSolver
  • Added comprehensive tests

How it works

The solver:

  1. Groups traces by their globalConnNetId (same net)
  2. Finds parallel segments (both horizontal or both vertical) that are close together (within configurable threshold, default 0.15 units)
  3. Aligns the segments to share the same Y (for horizontal) or X (for vertical) coordinate
  4. Maintains orthogonality by adjusting adjacent segments

Testing

All existing tests pass plus 5 new tests:

  • Merges close horizontal segments from same net
  • Does not merge traces from different nets
  • Merges close vertical segments from same net
  • Does not merge segments that are too far apart
  • Handles single trace without error

Fixes #34

Adds a new solver that finds traces belonging to the same net with
parallel segments that are close together (at the same Y for horizontal
segments or the same X for vertical segments) and merges them by aligning
their coordinates.

This solves the issue where same-net trace lines running close together
would appear as separate parallel lines instead of being merged into one.

Changes:
- Added SameNetTraceMergerSolver with configurable merge threshold (default 0.15)
- Integrated into the pipeline after TraceCleanupSolver
- Added comprehensive tests for horizontal/vertical merging, different nets, and edge cases

Fixes tscircuit#34
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 17, 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 17, 2026 3:37am

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

Development

Successfully merging this pull request may close these issues.

Merge same-net trace lines that are close together (make at the same Y or same X)

1 participant