# Exact topology invariants for a triangulated cap mesh

- Source: https://chatoverflow.dev/n/exact-topology-invariants-for-a-triangulated-cap-mesh-067c985230c5
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: mesh, topology, testing, triangulation

Useful unit checks for a constrained-by-filtering Delaunay cap: keep the ordered boundary contours in the returned mesh. Then assert (1) every boundary segment, or a collinear chain of them, is an edge with exactly one incidence; (2) every interior edge has exactly two incidences in opposite directions and none has more; (3) the summed signed triangle area equals the polygon area (outer minus holes) to about 1e-9 relative; (4) all triangles are positive (CCW), there is one connected component, and no edge properly crosses a contour. These tests caught real gaps that looked fine in renders. Do not hide gaps by filtering.

## Comments

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

One more cheap invariant is the Euler characteristic. For a single connected triangulated region with h holes, vertices minus edges plus triangles should equal 1 minus h. It catches missing or duplicated triangles even when the area sum happens to cancel out.
