Module mesh_check

Module mesh_check 

Source
Expand description

mesh_check: the one home for “is this triangle soup closed, paired, manifold, how much does it enclose, and how thin are its triangles”.

Before this module each gate hand-rolled its own edge-pairing hash walk, with its own vertex key and its own degenerate rule. EdgeLedger is that walk once; every verdict here is a named query on it. No gate changed its key or its rule: the spellings are arguments (VertexKey, Degenerate), so a gate that welds at 0.1 mm still does, and one that needs exact bits still does. Keys are exact or grid-quantised, and the answers are independent of triangle order.

§“Watertight”

New code and tests mean one thing by it (is_watertight): vertices on the 0.1 mm grid (GridDiv(1e-4)), triangles that collapse on the grid skipped, every remaining edge used exactly once in each direction, and at least one edge. The existing gate verdicts are deliberately different questions:

VerdictKeyDegenerateRule
directed_closedGridDiv(1e-4)skip triangleevery edge nets to zero
closed_or_hairlineGridDiv(1e-4)skip trianglezero net, or a bounded T-junction chain
edge_multiplicity_defectsBitsZeroFoldedskip triangleuses per undirected edge
directed_closed_exactBitsrejectevery edge nets to zero
undirected_defect_countGridDiv(1e-4)skip triangleuses per undirected edge
strictly_paired_at(k)GridMul(k)skip triangleexactly one use each way

Unifying those is a policy change, not a refactor, and is not done here.

The module is pub(crate), and pub under the test-support feature so the shared test oracles can delegate to it.

Structs§

ClosureVerdict
Cached result of the shared 0.1 mm directed-edge walk.
EdgeLedger
Per-undirected-edge directed use counts of a triangle soup.
EdgeMultiplicityDefects
Per-undirected-edge MULTIPLICITY defects, the class the signed predicates above are structurally blind to.
TriangleShape
The census’s shape reading of a mesh.

Enums§

Degenerate
What the walk does with a triangle whose corners collapse onto one key.
VertexKey
How a vertex becomes a hash key.

Functions§

closed_enough_to_emit
Named emit contract for callers that tolerate bounded T-junction hairlines.
closed_or_hairline
Closed-surface audit with a HAIRLINE tolerance: the surface passes when every unpaired directed edge (0.1 mm grid) is collinearly COVERED by unpaired edges of the opposite net sign, the signature of two adjacent faces subdividing a shared boundary line differently (a T-junction chain, an invisible sub-grid gap), NOT of a missing surface. A genuine hole leaves a boundary loop whose edges have nothing opposite along them and fails. The exact kernel’s own output is routinely NOT even undirected-watertight on these hosts, so this gate is still far stricter than the status quo.
directed_closed
DIRECTED quantized closed-surface audit (0.1 mm grid): every directed edge must be cancelled by its reverse. Strictly stronger than the undirected 2-manifold check: it catches inconsistent winding and doubled coincident surfaces (two triangles sharing an edge in the SAME direction), not just cracks. Triangles that collapse to a degenerate key on the grid are skipped. An empty mesh is not closed.
directed_closed_exact
Closed-surface check on exact f32 bit coords: every directed edge paired and no degenerate edge. The #2176 lesson: only per-component-watertight solid cutters may join a batched group; an open component poisons the whole group’s ray parity (batch admission).
edge_multiplicity_defects
Count the EdgeMultiplicityDefects of mesh, keyed EXACTLY.
is_watertight
The documented definition of “watertight” for new code and tests: vertices on the 0.1 mm grid, collapsed triangles skipped, every edge used exactly once each way, and at least one edge. Existing gates keep their own keys and rules (see super); this is the one to reach for when writing a new check.
signed_volume
Signed volume of a (closed) triangle mesh via the divergence theorem, about volume_reference of the same mesh. Reads the f32 positions unsnapped; an out-of-range index panics. Positive for outward (CCW) winding.
signed_volume_about
signed_volume about a caller-chosen o, in one walk. A before/after difference over the same host must read both meshes about ONE point (the host’s volume_reference): the flux of a crack the cut did not touch then cancels, where two per-mesh points would leave (o_after - o_before)·N/6 of it in the removed volume (#4632).
strictly_paired_at
Every undirected edge is used exactly once each way on a grid of per_unit cells per world unit, collapsed triangles skipped. The strict directed-pair rule (#3397), not just a zero net balance (which a 2-forward/2-reverse seam or a duplicated sheet also satisfies). An empty mesh does not pass.
triangle_shape
Read mesh as the census does. Triangles without area and triangles naming a vertex the mesh does not have are left out, as there.
undirected_defect_count
Number of 0.1 mm-welded undirected edges whose triangle multiplicity is not two; usize::MAX when no triangle survives the grid.
volume_reference
The point signed_volume sums mesh about: the centre of its position bounds (the origin for an empty mesh). kernel::signed_volume uses the same rule over the vertices its triangles reference, so the two agree unless the buffer holds unreferenced positions. On native, positions are absolute, and an open surface’s divergence sum grows with the distance to the reference point, so the point must lie within the operand’s extent, not at the world origin. Read off Mesh::bounds, a linear scan of the position buffer, so the sum itself is the only index walk.

Type Aliases§

Key3
A quantised or bit-exact vertex identity.