Skip to main content

DiscreteMesh

Struct DiscreteMesh 

Source
pub struct DiscreteMesh {
    pub vertices: Vec<[f64; 3]>,
    pub triangles: Vec<[usize; 3]>,
}
Expand description

A triangle mesh suitable for discrete differential geometry computations.

Stores vertex positions and triangles, with lazy adjacency information.

Fields§

§vertices: Vec<[f64; 3]>

Vertex positions, indexed by vertex index.

§triangles: Vec<[usize; 3]>

Triangle faces, each given as three vertex indices.

Implementations§

Source§

impl DiscreteMesh

Source

pub fn new(vertices: Vec<[f64; 3]>, triangles: Vec<[usize; 3]>) -> Self

Construct a mesh from vertex positions and face index triples.

Source

pub fn num_vertices(&self) -> usize

Number of vertices.

Source

pub fn num_faces(&self) -> usize

Number of triangular faces.

Source

pub fn one_ring_faces(&self, v: usize) -> Vec<usize>

Returns all triangles that share vertex v.

Source

pub fn one_ring_vertices(&self, v: usize) -> Vec<usize>

Returns all neighbour vertices of vertex v (one-ring).

Source

pub fn vertex_normal(&self, v: usize) -> [f64; 3]

Area-weighted vertex normal at vertex v.

Source

pub fn face_normal(&self, fi: usize) -> [f64; 3]

Face normal for triangle fi.

Source

pub fn voronoi_area(&self, v: usize) -> f64

Voronoi area of vertex v (mixed Voronoi / barycentric area).

Uses the formulation of Meyer et al. (2003).

Source

pub fn cotan_laplacian(&self) -> Vec<(usize, usize, f64)>

Build the sparse cotangent-weight Laplace-Beltrami matrix as a list of (row, col, weight) triples.

The returned weights satisfy L[i][j] = (cot_alpha + cot_beta) / 2 for adjacent vertices i, j, and L[i][i] = -sum_j L[i][j].

Source

pub fn apply_laplacian(&self, f: &[f64]) -> Vec<f64>

Apply the Laplace-Beltrami operator to a scalar field f (length = n_vertices), returning the Laplacian value at each vertex: (Lf)[i] = sum_j L[i][j] * f[j].

Source

pub fn gaussian_curvature(&self) -> Vec<f64>

Discrete Gaussian curvature (angle defect) at each vertex.

K[v] = (2*pi - sum_angles) / A_v where A_v is the Voronoi area.

Source

pub fn mean_curvature(&self) -> Vec<f64>

Discrete mean curvature at each vertex using the cotangent formula.

Returns the mean curvature H[v] (scalar) at each vertex. H[v] = |Lx[v]| / (2 * A_v) where Lx is the Laplacian of position.

Source

pub fn principal_curvatures(&self) -> Vec<(f64, f64)>

Principal curvatures estimated from mean and Gaussian curvature.

Returns (kappa_1, kappa_2) where kappa_1 >= kappa_2.

Trait Implementations§

Source§

impl Clone for DiscreteMesh

Source§

fn clone(&self) -> DiscreteMesh

Returns a duplicate 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 DiscreteMesh

Source§

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

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.