Skip to content

feat: merge same-net trace lines that are close together (align to same X/Y) #34#166

Open
mitchellecm7 wants to merge 4 commits intotscircuit:mainfrom
mitchellecm7:fix/merge-same-net-traces-34
Open

feat: merge same-net trace lines that are close together (align to same X/Y) #34#166
mitchellecm7 wants to merge 4 commits intotscircuit:mainfrom
mitchellecm7:fix/merge-same-net-traces-34

Conversation

@mitchellecm7
Copy link
Copy Markdown

/claim #34

Demo Video

@tscircuit_schematic-trace-solver.-.Google.Chrome.2026-04-07.17-31-00.mp4

Problem
Same-net trace lines that are close together (e.g., multiple IOVDD traces) are drawn at slightly different Y or X coordinates, causing non-aligned parallel lines.

Solution
Enhanced SameNetSegmentMergingSolver to detect and align parallel segments on the same net within a threshold distance.

Changes Made

SameNetSegmentMergingSolver.ts

  • Added alignThreshold parameter (default 0.5)
  • Added alignParallelSegments() method that:
    • Groups parallel segments (horizontal/vertical) by proximity
    • Clusters segments within alignThreshold distance
    • Aligns each cluster to median position
  • Horizontal segments → same Y coordinate
  • Vertical segments → same X coordinate
  • Added rebuildTracesFromSegments() helper

SchematicTracePipelineSolver.ts

  • Updated pipeline to pass alignThreshold: 0.5 to SameNetSegmentMergingSolver
    How It Works
  1. Groups traces by netId
  2. Separates horizontal and vertical segments
  3. Clusters parallel segments that are within threshold distance
  4. Aligns each cluster to median X or Y coordinate
  5. Rebuilds trace paths while maintaining connectivity

Testing
Tested with netlist containing multiple IOVDD pins:

  • All IOVDD horizontal traces now share same Y coordinate
  • All DVDD traces aligned correctly
  • Perpendicular connections adjust automatically

Visual Result
Before: Parallel traces at slightly different positions
After: Perfectly aligned traces on same X/Y coordinates

Fixes #34

- Added SameNetSegmentMergingSolver to merge close same-net trace segments
- Integrated into SchematicTracePipelineSolver pipeline
- Added demo page SameNetSegmentMergingDemo.page.tsx
- Merges collinear segments within 0.5 unit threshold
- Add alignParallelSegments() method for horizontal/vertical alignment
- Add alignThreshold parameter (default 0.5)
- Cluster same-net parallel segments within threshold distance
- Align clusters to median X (vertical) or Y (horizontal) coordinate
- Maintain connectivity through perpendicular segments

Fixes tscircuit#34
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 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 8, 2026 1:12am

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.

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

1 participant