fix: remove duplicate consecutive points in simplifyPath#341
Open
tungnguyentu wants to merge 1 commit into
Open
fix: remove duplicate consecutive points in simplifyPath#341tungnguyentu wants to merge 1 commit into
tungnguyentu wants to merge 1 commit into
Conversation
Zero-length trace segments (two identical consecutive points) caused `isVertical`/`isHorizontal` to behave inconsistently and left extra visible line segments in the schematic output. Fix: deduplicate consecutive equal points before each collinear-collapse pass. Running two collapse passes after dedup handles back-to-back collinear sequences that the first pass may expose. Adds five focused tests: duplicate removal, collinear collapse, right-angle preservation, duplicates at endpoints, and idempotency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
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 #78
/claim #78
Root Cause
The
simplifyPathfunction inTraceCleanupSolverdid not handle duplicate consecutive points (zero-length segments). When two identical points appear back-to-back in a trace path,isVertical/isHorizontalreturn inconsistent results, causing the collinear-collapse passes to miss those segments. The result is extra visible line segments in the schematic output.Fix
Added a
dedupConsecutivehelper that strips identical adjacent points before each collinear-collapse pass. Two collapse passes run in sequence to handle cases where the first pass exposes a new collinear run, followed by a final dedup to ensure a clean result.Tests
Five focused tests in
tests/solvers/TraceCleanupSolver/simplify-path.test.ts:All 62 tests pass (4 skipped, 0 fail). No snapshot changes — the fix only affects degenerate paths not covered by existing examples.