Skip to content

triangulate cuts polygons into ears, not fans - #344

Open
berkgeveci wants to merge 1 commit into
Kitware:mainfrom
berkgeveci:dataset/triangulate-concave
Open

berkgeveci wants to merge 1 commit into
Kitware:mainfrom
berkgeveci:dataset/triangulate-concave

Conversation

@berkgeveci

Copy link
Copy Markdown
Collaborator

Found by running VTK's own Python tests with Tack's algorithms in place of VTK's filters: vtkTriangleFilter's outputs differed from Tack's in area on 53 of 113 runs (the concave polygons of vtkDiscreteFlyingEdges2D, vtkImageToPolyDataFilter, eleState.py).

The bug: triangulate cut a polygon into a fan from its first corner. On a concave polygon the fan covers part of it twice and part not at all: a U-shaped polygon of area 6 gave triangles of area 9. (cell_geometry, integrate and contour of polygons were right; only triangulate fanned.)

The fix: each polygon is cut into ears in its plane -- the plane of its Newell normal's largest component -- as VTK's vtkTriangleFilter does: a corner turning as the polygon does, whose triangle holds no other corner, is cut off, until three corners are left (_refine._ears, one thread a polygon, the corners left linked within its own range). Still n - 2 triangles a polygon, each wound as the polygon; a degenerate remainder with no ear is fanned.

Tested: the U in xy, wound the other way, in yz and in a tilted plane, and a square with three corners in a line, beside a convex quad: the area exact per polygon and every triangle's normal the polygon's. Files touched (refinement, public filters, polyhedra, polylines, degenerate inputs, devices, polydata): 657 passed; quick tier 3038 passed.

🤖 Generated with Claude Code

A fan from a polygon's first corner covers a concave polygon twice in part and
leaves part uncovered (a U of area 6 gave triangles of area 9). Each polygon is
now cut into ears in its plane, as VTK's vtkTriangleFilter: n - 2 triangles
covering it once, each wound as the polygon. Found running VTK's Python tests
on Tack (the concave polygons of vtkDiscreteFlyingEdges2D and
vtkImageToPolyDataFilter).

This branch has not been deployed

No deployments
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