feat: merge collinear traces on same net to simplify schematic layout#117
Open
buildingvibes wants to merge 2 commits intotscircuit:mainfrom
Open
feat: merge collinear traces on same net to simplify schematic layout#117buildingvibes wants to merge 2 commits intotscircuit:mainfrom
buildingvibes wants to merge 2 commits intotscircuit:mainfrom
Conversation
Implements automatic merging of collinear trace segments that belong to the same net and are aligned (same Y for horizontal or same X for vertical). This addresses issue tscircuit#34 by reducing fragmented trace segments into single continuous lines, making schematics cleaner and more readable. Changes: - Added mergeCollinearTraces utility function that: - Groups traces by net ID - Identifies horizontal and vertical segments - Merges overlapping or adjacent collinear segments - Simplifies traces with multiple collinear points - Integrated merging as final step in TraceCleanupSolver pipeline - Added comprehensive unit tests for merge logic - Added example28 demonstrating the feature - Added integration test for the complete pipeline The merge algorithm uses a threshold (default 0.01) to handle minor floating-point variations while ensuring segments are truly aligned. Only segments on the same net are merged, preserving circuit topology. Fixes tscircuit#34
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The merge collinear traces feature (implemented in this PR) changes the visual output of the solver by combining collinear trace segments into single continuous lines. This is the expected behavior and improves schematic readability. Updated 9 test snapshots to match the new output.
fe35d66 to
827d11c
Compare
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
This PR implements automatic merging of collinear trace segments that belong to the same net and are aligned, addressing issue #34. The implementation reduces fragmented trace segments into single continuous lines, making schematics cleaner and more readable.
Key Changes
New utility function
mergeCollinearTraces: Core logic for identifying and merging overlapping or adjacent collinear segmentsIntegrated into TraceCleanupSolver pipeline: Added as the final "merging_collinear_traces" step
Comprehensive testing:
Technical Details
The merge algorithm:
globalConnNetIdThe threshold parameter handles minor floating-point variations while ensuring segments are truly aligned. Only segments on the same net are merged, preserving circuit topology.
Test Plan
npx tsc --noEmitnpm run formatmergeCollinearTracesfunctionManual Testing
The example28 page can be viewed in the browser to visually verify that:
Fixes #34
/attempt #34
/claim #34