Skip to content

Fix OGC extraction producing figure-8 contours at shared vertices#58

Open
bretttully wants to merge 3 commits intoiShape-Rust:mainfrom
bretttully:gh-57/ogc-bug
Open

Fix OGC extraction producing figure-8 contours at shared vertices#58
bretttully wants to merge 3 commits intoiShape-Rust:mainfrom
bretttully:gh-57/ogc-bug

Conversation

@bretttully
Copy link
Contributor

Summary

  • Fix a bug where extract_ogc produces self-touching figure-8 contours when hull contours share a vertex with a hole (e.g. pinch point at (2,2))
  • Add inline pinch-point detection and splitting during pass 1 of OGC extraction, using i_key_sort::sort_by_two_keys for O(n log n) duplicate detection
  • Sub-contours from splitting are classified by winding area as new shapes or pending holes, joined via join_unsorted_holes after pass 2

Test plan

  • 16 new tests covering 4 geometries (shared point, two shapes touching, two holes sharing vertices, three holes sharing vertices) × 4 fill rules (EvenOdd, NonZero, Positive, Negative)
  • Each test validates both OverlayRule::Subject and OverlayRule::Union
  • Exact vertex-level assertions validated against Shapely reference output
  • Full workspace regression suite passes (494 tests)
  • cargo fmt and cargo clippy clean

claude and others added 3 commits February 5, 2026 12:08
Four non-overlapping boxes are unioned to form a shape with a hole.
The exterior contour and hole contour should share a single point
at (2,2), but the library currently merges them into one figure-8
contour that visits (2,2) twice.

Tests EvenOdd, NonZero, Positive, and Negative fill rules.

https://claude.ai/code/session_01UWsUQwhyBYT5ABqevBFmkR
- Switch to Overlay::with_contours_custom with IntOverlayOptions::ogc()
- Add test_input_winding_order asserting all rectangles are CCW
  (negative area_two)
- Simplify overlay helper to accept fill_rule and return results directly

https://claude.ai/code/session_01UWsUQwhyBYT5ABqevBFmkR
When hull contours self-touch at pinch points (e.g. exterior and hole
sharing a vertex), extract_ogc now detects and splits them inline during
pass 1. Split sub-contours are classified by winding area as either new
shapes or pending holes, which are joined after pass 2.

- Add find_pinch_point using i_key_sort's sort_by_two_keys for O(n log n)
  duplicate detection on contour points
- Add split_all_pinch_points to recursively decompose figure-8 contours
- Add comprehensive tests (16 cases) covering 4 geometries × 4 fill rules,
  validated against Shapely reference output
@bretttully
Copy link
Contributor Author

Fixes #57

Here are the test cases:
test_shared_point
test_three_holes_sharing_vertices
test_two_holes_sharing_vertices
test_two_shapes_touching_at_point

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
iOverlay/src/core/extract_ogc.rs 95.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants