feat: add SameNetTraceMergeSolver — merge close same-net trace segments#351
Open
BuckyQ wants to merge 1 commit into
Open
feat: add SameNetTraceMergeSolver — merge close same-net trace segments#351BuckyQ wants to merge 1 commit into
BuckyQ wants to merge 1 commit into
Conversation
Adds a new pipeline phase that merges trace segments belonging to the same electrical net when their endpoints are within maxEndpointGap units (default 0.12) of each other. Implementation details: - Traces are grouped by userNetId > globalConnNetId > dcConnNetId - O(n²) scan per net group (groups are typically small in practice) - Closest endpoint pair is selected; paths are reversed as needed - A single L-shaped bridge is inserted when the join is not axis-aligned - Duplicate consecutive points are removed from the merged path - Iterates until no more mergeable pairs remain in any group The solver is inserted into the pipeline after TraceCleanupSolver and before NetLabelPlacementSolver so downstream label placement sees the merged trace geometry. All 65 tests pass. Updated snapshots for examples where same-net traces were merged (examples 01, 02, 13, 14, 15, 18, 19). Closes tscircuit#29
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #29
Also addresses #34 (same-net trace lines at same X or same Y)
What this adds
A new
SameNetTraceMergeSolverpipeline phase that iteratively merges trace segments belonging to the same electrical net when their endpoints are within a configurable gap (default 0.12 units).This directly addresses both:
Implementation
Algorithm:
userNetId > globalConnNetId > dcConnNetIdmaxEndpointGapthreshold (default 0.12)Pipeline integration
Inserted after
traceCleanupSolverand beforenetLabelPlacementSolver.Tests
8 new unit tests covering: collinear touching, small gap, cross-net isolation, gap threshold, L-bridge, multi-chain, single trace, reversed endpoints.
Test results
Snapshots updated for examples 01, 02, 13, 14, 15, 18, 19.