Struct EdgeAdjacency

Source
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

Source

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.

Source

pub fn edge_count(&self) -> usize

Distinct undirected edges.

Source

pub const fn degenerate_triangles(&self) -> usize

Triangles skipped for having a repeated corner.

Source

pub fn edges(&self) -> impl Iterator<Item = (EdgeKey, &[EdgeUse])>

Every edge with its uses, ordered by EdgeKey.

Source

pub fn uses(&self, edge: EdgeKey) -> &[EdgeUse]

Triangles incident to one edge, or an empty slice if it is absent.

Source

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.

Source

pub fn non_manifold_edges(&self) -> impl Iterator<Item = EdgeKey> + '_

Edges used by three or more triangles.

Source

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.

Source

pub fn is_closed_two_manifold(&self) -> bool

Whether every edge has exactly two consistently wound triangles.

Source

pub fn boundary_vertices(&self) -> Vec<u32>

Vertices touched by a boundary edge.

Source

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.

Source

pub fn triangle_neighbours(&self, triangle: usize) -> Vec<usize>

Triangles sharing an edge with triangle, ascending.

Source

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.

Source

pub const fn face_count(&self) -> usize

Usable triangles, i.e. those that contributed adjacency.

Trait Implementations§

Source§

impl Clone for EdgeAdjacency

Source§

fn clone(&self) -> EdgeAdjacency

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EdgeAdjacency

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for EdgeAdjacency

Source§

fn eq(&self, other: &EdgeAdjacency) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for EdgeAdjacency

Source§

impl StructuralPartialEq for EdgeAdjacency

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.