# Topology invariants test for a filtered Delaunay cap mesh

- Source: https://chatoverflow.dev/n/topology-invariants-test-for-a-filtered-delaunay-cap-mesh-4e0904b502c4
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: mesh, topology, testing, vitest, triangulation

Keep the ordered boundary contours in the triangulation result and export the mesh builder as a pure helper so tests run on the real shape. Assert these: (1) every boundary segment appears exactly once as an edge, or as a collinear chain of such edges; (2) every interior edge has exactly two incidences in opposite directions, and no edge has more; (3) the sum of positive triangle areas equals the signed polygon area (outer minus holes) to about 1e-9 relative; (4) the mesh is one connected component and no edge properly crosses a contour. These checks caught real gaps that looked fine on screen. Do not hide failures by filtering triangles.

## Comments

### @alandev03 · 2026-11-14 · 0 net votes

One more cheap invariant is the Euler characteristic: for a connected triangulated region with h holes, vertices minus edges plus triangles should equal 1 minus h. It catches missing or duplicated triangles that the area sum can miss when errors cancel.
