Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

Preserve translated minimum-length FlexPath segments - #337

Closed
CAOShurong wants to merge 1 commit into
heitzmann:mainfrom
CAOShurong:codex/fix-minimum-length-paths
Closed

CAOShurong wants to merge 1 commit into
heitzmann:mainfrom
CAOShurong:codex/fix-minimum-length-paths

Conversation

@CAOShurong

Copy link
Copy Markdown
Contributor

Fixes #277. Extends #278 to translated coordinates, where 3.28 - 3.279 rounds below 0.001 and a minimum-length segment is still discarded during polygon conversion or GDS/OASIS writing.

Account for endpoint roundoff before removing a point. Exact duplicates and clearly sub-tolerance segments are still removed; segments within the roundoff bound are preserved. The change stays in remove_overlapping_points, without changing path tolerance or adding output-grid parameters.

Add regressions for translated segments in both directions, two grids, polygon conversion, GDS/OASIS round-trips and repeated OASIS writes, plus duplicate and sub-tolerance controls.

Validated on Windows with MSVC and Python 3.13: all 402 tests pass, including the original 294; 42 added cases fail on current main. The issue's attachment round-trips without altering path spines, and independent KLayout geometry comparisons pass. Linux/macOS were not tested locally. A filtered overlap-removal microbenchmark was about 14% slower; full polygon conversion measured within 2% of baseline for the 256/4096-point cases tested.

@heitzmann

Copy link
Copy Markdown
Owner

I'm not convinced by this change. Having segments below the spine tolerance can impact the creation of the polygonal contour in other ways, is my feeling, because we would be breaking an assumption that the remaining of the code might be using. If you need to preserve segments below 1 nm (honestly I don't know why… this is way below any real fabrication error I've ever seen), why not just decrease the flex path tolerance?

@CAOShurong

Copy link
Copy Markdown
Contributor Author

Lowering the tolerance works: I rechecked the supplied file with read_oas(..., tolerance=0.0005) and its spines remain unchanged. The default 0.001 loses a nominal 1 nm grid step because 3.28 - 3.279 rounds just below it.

Your concern is valid: at a synthetic x=1e12, this bound also retains a 0.0006103515625 segment with tolerance=0.001. I do not have evidence that relaxing the contour precondition that far is safe. I am closing this version and keeping the branch and tests available.

@CAOShurong CAOShurong closed this Oct 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OASIS missing paths after saving

2 participants