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:
| Verdict | Key | Degenerate | Rule |
|---|---|---|---|
directed_closed | GridDiv(1e-4) | skip triangle | every edge nets to zero |
closed_or_hairline | GridDiv(1e-4) | skip triangle | zero net, or a bounded T-junction chain |
edge_multiplicity_defects | BitsZeroFolded | skip triangle | uses per undirected edge |
directed_closed_exact | Bits | reject | every edge nets to zero |
undirected_defect_count | GridDiv(1e-4) | skip triangle | uses per undirected edge |
strictly_paired_at(k) | GridMul(k) | skip triangle | exactly 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§
- Closure
Verdict - Cached result of the shared 0.1 mm directed-edge walk.
- Edge
Ledger - Per-undirected-edge directed use counts of a triangle soup.
- Edge
Multiplicity Defects - Per-undirected-edge MULTIPLICITY defects, the class the signed predicates above are structurally blind to.
- Triangle
Shape - The census’s shape reading of a mesh.
Enums§
- Degenerate
- What the walk does with a triangle whose corners collapse onto one key.
- Vertex
Key - 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
EdgeMultiplicityDefectsofmesh, 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_referenceof the same mesh. Reads the f32 positions unsnapped; an out-of-range index panics. Positive for outward (CCW) winding. - signed_
volume_ about signed_volumeabout a caller-choseno, in one walk. A before/after difference over the same host must read both meshes about ONE point (the host’svolume_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/6of it in the removed volume (#4632).- strictly_
paired_ at - Every undirected edge is used exactly once each way on a grid of
per_unitcells 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
meshas 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::MAXwhen no triangle survives the grid. - volume_
reference - The point
signed_volumesumsmeshabout: the centre of its position bounds (the origin for an empty mesh).kernel::signed_volumeuses 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 offMesh::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.