ifc_lite_geometry/mesh_check/mod.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5//! `mesh_check`: the one home for "is this triangle soup closed, paired,
6//! manifold, how much does it enclose, and how thin are its triangles".
7//!
8//! Before this module each gate hand-rolled its own edge-pairing hash walk, with
9//! its own vertex key and its own degenerate rule. [`EdgeLedger`] is that walk
10//! once; every verdict here is a named query on it. **No gate changed its key or
11//! its rule**: the spellings are arguments ([`VertexKey`], [`Degenerate`]), so a
12//! gate that welds at 0.1 mm still does, and one that needs exact bits still
13//! does. Keys are exact or grid-quantised, and the answers are independent of
14//! triangle order.
15//!
16//! # "Watertight"
17//!
18//! New code and tests mean one thing by it ([`is_watertight`]): vertices on the
19//! 0.1 mm grid (`GridDiv(1e-4)`), triangles that collapse on the grid skipped,
20//! every remaining edge used exactly once in each direction, and at least one
21//! edge. The existing gate verdicts are deliberately different questions:
22//!
23//! | Verdict | Key | Degenerate | Rule |
24//! |---|---|---|---|
25//! | [`directed_closed`] | `GridDiv(1e-4)` | skip triangle | every edge nets to zero |
26//! | [`closed_or_hairline`] | `GridDiv(1e-4)` | skip triangle | zero net, or a bounded T-junction chain |
27//! | [`edge_multiplicity_defects`] | `BitsZeroFolded` | skip triangle | uses per undirected edge |
28//! | `directed_closed_exact` | `Bits` | reject | every edge nets to zero |
29//! | `undirected_defect_count` | `GridDiv(1e-4)` | skip triangle | uses per undirected edge |
30//! | `strictly_paired_at(k)` | `GridMul(k)` | skip triangle | exactly one use each way |
31//!
32//! Unifying those is a policy change, not a refactor, and is not done here.
33//!
34//! The module is `pub(crate)`, and `pub` under the `test-support` feature so
35//! the shared test oracles can delegate to it.
36
37mod area;
38mod closure;
39mod hairline;
40mod ledger;
41mod shape;
42mod volume;
43
44#[cfg(test)]
45pub(crate) mod closure_tests;
46
47// Not every re-export has a caller in every feature set (the shared oracles and
48// the manifold gate are opt-in).
49#[allow(unused_imports)]
50pub use closure::{
51 closed_enough_to_emit, closed_or_hairline, directed_closed, directed_closed_exact,
52 edge_multiplicity_defects, is_watertight, strictly_paired_at, undirected_defect_count,
53 ClosureVerdict, EdgeMultiplicityDefects,
54};
55pub(crate) use area::surface_area;
56pub use ledger::{Degenerate, EdgeLedger, Key3, VertexKey};
57pub use shape::triangle_shape;
58#[cfg(feature = "test-support")]
59pub use shape::TriangleShape;
60pub use volume::{signed_volume, signed_volume_about, volume_reference};