Skip to content

Fix Bentley-Ottmann polygon walk at shared vertices#382

Open
aldernero wants to merge 1 commit into
tdewolff:masterfrom
aldernero:master
Open

Fix Bentley-Ottmann polygon walk at shared vertices#382
aldernero wants to merge 1 commit into
tdewolff:masterfrom
aldernero:master

Conversation

@aldernero
Copy link
Copy Markdown
Contributor

Summary

  • Fix panics in bentleyOttmann when building result polygons at vertices where many segments meet (e.g. after Path.StrokeSettle on dense, shared-edge geometry such as merged Voronoi cell outlines).
  • Search both directions around the snap-square event ring for the next result segment, with a fallback to another left endpoint at the vertex.
  • Close partial contours to the other endpoint instead of panicking when no neighbor is found.
  • Add regression tests for merged grid stroke/settle (path_intersection_voronoi_test.go).

Problem

Path.Stroke calls Settle(Positive) on the offset outline. At tight junctions, polygon walking only searched one direction for the next segment at a vertex. When no match was found, the code panicked:

next node for result polygon is nil, probably buggy intersection code

Test plan

  • go test ./... in this repo
  • Reproduced originally via merged Voronoi cell stroke in gaul (TestVoronoiCanvasMergedStroke_denseGrid)

Made with Cursor

When building result polygons, the next segment at a vertex was only
searched in one direction around the snap-square event ring. Offset stroke
outlines (e.g. dense adjacent cells) could leave no match and panic.

Search both directions, fall back to another left endpoint in the result,
and close the contour to the other endpoint instead of panicking when no
neighbor exists. Add regression tests for merged grid stroke/settle.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant