Add SameNetTraceCombiningSolver pipeline phase (#29)#283
Open
brone1323 wants to merge 1 commit into
Open
Conversation
…ents Implements the new pipeline phase requested in tscircuit#29. Same-net traces that get routed close together by independent MSP pairs currently emit visually duplicated parallel runs. The new solver detects axis-parallel segments within a small orthogonal tolerance, snaps the shorter one onto the longer one's axis, and records a junction point at the rejoin. Wired in after TraceCleanupSolver so its output flows into the existing NetLabelPlacement / Example28 / orientation solvers without disturbing their inputs structurally. Tolerances default to 0.15 (orthogonal) and 0.05 (overlap), tight enough to leave legitimately distinct same-net traces untouched. Includes unit tests covering merge, different-nets, far-apart, and no-overlap cases.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Author
Demo videoGenerated programmatically (HTML deck → Playwright recordVideo → ffmpeg). Hosted as a release asset on the fork to comply with the Algora claim requirement. Sammy / @brone1323 |
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.
/claim #29
Closes #29.
Why a new phase
The existing trace solvers (
SchematicTraceLinesSolver,TraceOverlapShiftSolver,TraceCleanupSolver) shape traces independently per MSP connection pair. When two pairs in the same net produce axis-parallel segments that happen to land close to each other (the three-pin row in the issue screenshot is the canonical case), the rendered schematic shows visually duplicated parallel lines instead of a single tree-like trace with a junction.TraceOverlapShiftSolverdeliberately ignores same-net overlaps because shifting them apart isn't the right move — they should merge, not separate.This is exactly the post-processing step the issue calls out, and it's the same observation seveibar made in tscircuit/tscircuit-autorouter#66: "good trace adjacency behavior (combining traces in the same net when they're nearby) is a bit better than thickness, and maybe a good idea to do prior to this."
Approach
New solver
SameNetTraceCombiningSolver:SolvedTracePaths byglobalConnNetId.(segmentA, segmentB)pair drawn from distinct traces. Same orientation only — purely orthogonal segments are the only ones the existing pipeline emits and the only ones that visually duplicate.mergeDistance(0.15) AND parallel-axis overlap >=minOverlap(0.05). The pin grid in this project sits at 0.2 increments, so 0.15 catches visible duplication without crossing into legitimately distinct same-net runs.Output extends the existing trace shape; only the geometry of
tracePathis mutated (on a clone of the input — the upstream solvers' state is untouched).Pipeline wiring
Inserted as a new
pipelineDefstep right aftertraceCleanupSolver. Downstream consumers (netLabelPlacementSolver,example28Solver) prefer the combined output via the existing??fallback chain, so if the phase is skipped or absent the pipeline still works exactly as before.Tests
tests/solvers/SameNetTraceCombiningSolver/SameNetTraceCombiningSolver.test.tscovers four cases:mergeDistanceare left alone.All existing tests still pass; type-check is clean.
Files
lib/solvers/SameNetTraceCombiningSolver/SameNetTraceCombiningSolver.ts(new)tests/solvers/SameNetTraceCombiningSolver/SameNetTraceCombiningSolver.test.ts(new)lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts(pipeline wiring)