feat: merge same-net collinear traces that are close together#143
feat: merge same-net collinear traces that are close together#143ayushopchauhan wants to merge 1 commit intotscircuit:mainfrom
Conversation
…uit#34) Add mergeCollinearTraces step to TraceCleanupSolver pipeline. When two traces belong to the same net and have parallel segments within 0.15 units of each other, this aligns them to the average coordinate, producing cleaner schematics. - New file: mergeCollinearTraces.ts with segment extraction, proximity detection, and coordinate averaging - Integrated as final step in TraceCleanupSolver pipeline - Preserves pin endpoints (only moves interior segments) - New test: example31 with multi-chip same-net circuit - New page: example31 for visual debugging
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@seveibar Ready for review when you get a chance. This adds a new |
|
Hey @seveibar, friendly nudge - this is ready for review. CI is green, all tests passing. Let me know if you'd like any changes. |
|
Note: This PR also addresses #29 ("New phase to combine same-net trace segments that are close together"). Both #29 and #34 describe the same core problem -- same-net traces with parallel segments running close together should be merged into cleaner paths. This PR implements that as a new pipeline phase ( |
Summary
Fixes #34 - Merge same-net trace lines that are close together (make at the same Y or same X).
When two traces belong to the same net (
globalConnNetId) and have parallel segments running within 0.15 units of each other, this aligns them to the average coordinate, producing cleaner schematics.What changed
New file:
lib/solvers/TraceCleanupSolver/mergeCollinearTraces.tsThe merge algorithm:
globalConnNetIdare candidatesMERGE_THRESHOLD(0.15 units) on the perpendicular axisModified:
TraceCleanupSolver.tsAdded
merging_collinear_tracesas the 4th and final pipeline step:New test:
tests/examples/example31.test.tsCircuit with two VCC traces connecting from opposite sides of U1 to R1 and R2, demonstrating the before/after merge behavior.
New page:
site/examples/example31-merge-same-net-traces.page.tsxVisual debugger page for inspecting the merge behavior interactively.
Before / After
Before: Two same-net traces may have parallel horizontal segments at y=0.18 and y=0.22, creating visual clutter.
After: Both segments align to y=0.20 (average), producing a cleaner schematic.
Testing
bun test tests/examples/example31.test.ts