Skip to content

Sort holes in interiorcuts#196

Merged
gpeairs merged 5 commits intomainfrom
gp/fix-175
Apr 8, 2026
Merged

Sort holes in interiorcuts#196
gpeairs merged 5 commits intomainfrom
gp/fix-175

Conversation

@gpeairs
Copy link
Copy Markdown
Member

@gpeairs gpeairs commented Apr 2, 2026

Fixes #175.

Right now _normalize_clip_arg turns ClippedPolygons into polygons via interiorcuts, but we can just extract the oriented contours directly. This then lets us do the guillotine cut for ClippedPolygons with more points than GDS_POLYGON_MAX without an intermediate interiorcuts, which fixes the mentioned issue. [Edit: it doesn't, see comments further down on how we actually fix the issue.]

In a follow-up, we can probably do the same for offsets of ClippedPolygons, which should address the issue where shrinking a polygon with an interior cut pulls it open. [This is still probably a good idea.]

@gpeairs gpeairs requested a review from laylagi April 2, 2026 10:05
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@gpeairs
Copy link
Copy Markdown
Member Author

gpeairs commented Apr 3, 2026

We need a solution that works for rendering styled ClippedPolygons, but I don't want to start pulling apart the to_polygons -> render! separation. Maybe it's enough to self-union any big polygon so it takes the ClippedPolygon guillotine path anyway?

@gpeairs
Copy link
Copy Markdown
Member Author

gpeairs commented Apr 8, 2026

Looks like the guillotine cut interaction was a red herring -- interiorcuts was just processing holes in a bad order. I'm surprised we hadn't encountered this before, but sorting contours by the y coordinate of the cut start point should guarantee that no cut passes through a hole that hasn't been processed into the outer contour yet.

@gpeairs gpeairs changed the title Clip ClippedPolygon contours directly Sort holes in interiorcuts Apr 8, 2026
Copy link
Copy Markdown
Contributor

@laylagi laylagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, it fixes the issue in my example. Thank you!

@gpeairs gpeairs merged commit dc789bd into main Apr 8, 2026
10 checks passed
@gpeairs gpeairs deleted the gp/fix-175 branch April 8, 2026 18:08
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.

Bad cuts in large polygons with holes

2 participants