pub struct EdgeAdjacency { /* private fields */ }Expand description
Edge-to-triangle adjacency over a triangle mesh.
Built once with EdgeAdjacency::build, then queried. Iteration order is
by EdgeKey, so any diagnosis derived from it is reproducible – a
report that reorders between runs is useless as an audit record.
§Layout
Edges are held in compressed-sparse-row form: keys ascending, starts
giving each key’s span, and uses one flat run per edge. A
BTreeMap<EdgeKey, Vec<EdgeUse>> costs a node allocation per distinct
edge plus a Vec allocation per edge that is ever used twice – roughly
245,000 allocations on an 82k-triangle sphere, against three here.
The structure is immutable after the build, which is what makes this affordable: CSR cannot accept a late insertion without reflowing, and nothing in the API offers one.
Implementations§
Source§impl EdgeAdjacency
impl EdgeAdjacency
Sourcepub fn build(mesh: &TriMesh) -> Self
pub fn build(mesh: &TriMesh) -> Self
Derive adjacency from a mesh.
Triangles with a repeated corner are skipped and counted. Corners are
taken as given: an out-of-range index is not adjacency data, and
validating it belongs to audit_mesh, not here.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Distinct undirected edges.
Sourcepub const fn degenerate_triangles(&self) -> usize
pub const fn degenerate_triangles(&self) -> usize
Triangles skipped for having a repeated corner.
Sourcepub fn edges(&self) -> impl Iterator<Item = (EdgeKey, &[EdgeUse])>
pub fn edges(&self) -> impl Iterator<Item = (EdgeKey, &[EdgeUse])>
Every edge with its uses, ordered by EdgeKey.
Sourcepub fn uses(&self, edge: EdgeKey) -> &[EdgeUse]
pub fn uses(&self, edge: EdgeKey) -> &[EdgeUse]
Triangles incident to one edge, or an empty slice if it is absent.
Sourcepub fn boundary_edges(&self) -> impl Iterator<Item = EdgeKey> + '_
pub fn boundary_edges(&self) -> impl Iterator<Item = EdgeKey> + '_
Edges used by exactly one triangle: the mesh boundary.
In a closed shell this is empty, which is what makes it a usable definition of “the hole” after a clip or a cut.
Sourcepub fn non_manifold_edges(&self) -> impl Iterator<Item = EdgeKey> + '_
pub fn non_manifold_edges(&self) -> impl Iterator<Item = EdgeKey> + '_
Edges used by three or more triangles.
Sourcepub fn inconsistent_edges(&self) -> impl Iterator<Item = EdgeKey> + '_
pub fn inconsistent_edges(&self) -> impl Iterator<Item = EdgeKey> + '_
Edges whose two triangles traverse them the same way.
Consistently wound neighbours traverse a shared edge in opposite directions, so agreement means one of the pair is flipped. Reported only for two-triangle edges: with three or more the pairing is ambiguous, and that is already a non-manifold defect.
Sourcepub fn is_closed_two_manifold(&self) -> bool
pub fn is_closed_two_manifold(&self) -> bool
Whether every edge has exactly two consistently wound triangles.
Sourcepub fn boundary_vertices(&self) -> Vec<u32>
pub fn boundary_vertices(&self) -> Vec<u32>
Vertices touched by a boundary edge.
Sourcepub fn vertex_neighbours(&self) -> Vec<Vec<u32>>
pub fn vertex_neighbours(&self) -> Vec<Vec<u32>>
Vertex-to-vertex neighbours, indexed by vertex.
Entry v lists the vertices sharing an edge with v, ascending.
Vertices used by no usable triangle get an empty list rather than
being omitted, so the result can be indexed directly.
Sourcepub fn triangle_neighbours(&self, triangle: usize) -> Vec<usize>
pub fn triangle_neighbours(&self, triangle: usize) -> Vec<usize>
Triangles sharing an edge with triangle, ascending.
Sourcepub fn euler_characteristic(&self) -> i64
pub fn euler_characteristic(&self) -> i64
Euler characteristic V - E + F over usable triangles.
Vertices are counted as those actually used by an edge, not the length of the position array: an unreferenced position is not part of the surface, and counting it shifts the characteristic silently.
Sourcepub const fn face_count(&self) -> usize
pub const fn face_count(&self) -> usize
Usable triangles, i.e. those that contributed adjacency.
Trait Implementations§
Source§impl Clone for EdgeAdjacency
impl Clone for EdgeAdjacency
Source§fn clone(&self) -> EdgeAdjacency
fn clone(&self) -> EdgeAdjacency
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more