Function genus

Source
pub fn genus(mesh: &TriMesh) -> Result<u32, GenusError>
Expand description

Genus of a closed orientable triangle mesh.

A sphere or cube is 0, a torus 1, a double torus 2.

§Errors

Refuses a mesh with boundary or non-manifold edges: Euler’s formula assumes a closed two-manifold, and applying it anyway would produce a plausible-looking integer with no meaning.

Refuses a mesh with more than one connected component for the same reason. chi = 2 - 2g is the single-component form of chi = 2c - 2g; applying it when c > 1 yields a negative genus that cannot be represented, and clamping that into 0 would report a solid full of cavities as a sphere. Split with axiolid_mesh::decompose and call this per component.