Skip to content

Merge same-net trace lines that are close together (snap to same X/Y)#196

Open
CyberSculptor96 wants to merge 19 commits intotscircuit:mainfrom
CyberSculptor96:fix/issue-34-merge-close-traces
Open

Merge same-net trace lines that are close together (snap to same X/Y)#196
CyberSculptor96 wants to merge 19 commits intotscircuit:mainfrom
CyberSculptor96:fix/issue-34-merge-close-traces

Conversation

@CyberSculptor96
Copy link
Copy Markdown

Summary

Adds a new trace cleanup step that merges same-net trace segments running in parallel when they are within a small distance threshold. Parallel horizontal segments get snapped to the same Y coordinate, and parallel vertical segments get snapped to the same X coordinate.

Changes

  • Added mergeSameNetTraces.ts with logic to detect and merge close parallel same-net segments
  • Extended TraceCleanupSolver pipeline with a merging_same_net_traces step after Z-shape balancing
  • Updated simplifyPath to handle degenerate segments from coordinate snapping
  • Added tests demonstrating before/after behavior

Closes #34

… close together. Finds parallel segments (same X or same Y within a threshold) belonging to the same net and snaps them to a shared coordinate, then simplifies the resulting paths.
…re close but not aligned, and verifies they get merged to the same coordinate after the cleanup solver runs.
…er balancing L-shapes. This step calls mergeSameNetTraces for groups of traces sharing the same globalConnNetId, merging parallel segments that are within a configurable distance threshold.
…th segments that result from merging (segments where start and end are essentially the same point after snapping).
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 18, 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 18, 2026 4:10am

Request Review

@CyberSculptor96
Copy link
Copy Markdown
Author

Hi! All CI checks are now passing ✅

  • test
  • type-check
  • format-check

This PR implements the fix for #34 by adding a mergeSameNetTraces step at the end of the TraceCleanupSolver pipeline. The approach:

  • Extracts all horizontal/vertical segments from traces sharing the same net
  • Snaps parallel segments that are within 0.2 units of each other to their average coordinate
  • This causes close parallel same-net traces to visually merge into a single line

Happy to address any review feedback. Let me know if anything needs adjustment!

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