fix: snap same-net close parallel traces to shared coordinate (#34)#346
Open
tungnguyentu wants to merge 2 commits into
Open
fix: snap same-net close parallel traces to shared coordinate (#34)#346tungnguyentu wants to merge 2 commits into
tungnguyentu wants to merge 2 commits into
Conversation
…uit#34) Adds a new `snapping_same_net_parallel_traces` step in TraceCleanupSolver (after untangling, before turn minimisation). For each net that has multiple traces, the step finds internal horizontal/vertical segment pairs that are within 0.15 schematic units of each other and have overlapping ranges, then snaps both to their midpoint coordinate so they appear as a single line. Pin-anchored endpoints (first and last path segments) are never moved, preserving port positions. The loop iterates until stable to handle chains of 3+ nearly-aligned traces converging to a common coordinate. Fixes tscircuit#34 /claim tscircuit#34
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
Adds a
snapping_same_net_parallel_tracescleanup step insideTraceCleanupSolverthat runs after untangling and before turn-minimisation.When two (or more) traces on the same net have internal horizontal segments within 0.15 schematic units of each other and overlapping X ranges, the step snaps both to their shared midpoint Y (same logic applies for close vertical segments and X). This makes near-parallel same-net traces appear as a single line.
Changes
lib/solvers/TraceCleanupSolver/snapSameNetParallelTraces.ts(new): pure function — groups traces byglobalConnNetId, iterates until stable finding pairs of internal parallel segments within the snap threshold, snaps both to the midpoint coordinate. Pin-anchored endpoints (first and last path segments) are never touched.lib/solvers/TraceCleanupSolver/TraceCleanupSolver.ts: adds"snapping_same_net_parallel_traces"step; the untangling sub-solver now transitions to it before turn-minimisation.tests/solvers/TraceCleanupSolver/snapSameNetParallelTraces.test.ts(new): 6 focused unit tests covering horizontal snap, vertical snap, different-net no-op, too-far no-op, non-overlapping no-op, and anchor-only no-op.Verification
bunx tsc --noEmit— cleanbun test— 63 pass / 4 skip / 0 fail; all existing snapshots unchanged (new step is a no-op on current fixtures)Fixes #34
/claim #34