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
impl DiscreteMesh
Sourcepub fn new(vertices: Vec<[f64; 3]>, triangles: Vec<[usize; 3]>) -> Self
pub fn new(vertices: Vec<[f64; 3]>, triangles: Vec<[usize; 3]>) -> Self
Construct a mesh from vertex positions and face index triples.
Sourcepub fn num_vertices(&self) -> usize
pub fn num_vertices(&self) -> usize
Number of vertices.
Sourcepub fn one_ring_faces(&self, v: usize) -> Vec<usize>
pub fn one_ring_faces(&self, v: usize) -> Vec<usize>
Returns all triangles that share vertex v.
Sourcepub fn one_ring_vertices(&self, v: usize) -> Vec<usize>
pub fn one_ring_vertices(&self, v: usize) -> Vec<usize>
Returns all neighbour vertices of vertex v (one-ring).
Sourcepub fn vertex_normal(&self, v: usize) -> [f64; 3]
pub fn vertex_normal(&self, v: usize) -> [f64; 3]
Area-weighted vertex normal at vertex v.
Sourcepub fn face_normal(&self, fi: usize) -> [f64; 3]
pub fn face_normal(&self, fi: usize) -> [f64; 3]
Face normal for triangle fi.
Sourcepub fn voronoi_area(&self, v: usize) -> f64
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).
Sourcepub fn cotan_laplacian(&self) -> Vec<(usize, usize, f64)>
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].
Sourcepub fn apply_laplacian(&self, f: &[f64]) -> Vec<f64>
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].
Sourcepub fn gaussian_curvature(&self) -> Vec<f64>
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.
Sourcepub fn mean_curvature(&self) -> Vec<f64>
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.
Sourcepub fn principal_curvatures(&self) -> Vec<(f64, f64)>
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
impl Clone for DiscreteMesh
Source§fn clone(&self) -> DiscreteMesh
fn clone(&self) -> DiscreteMesh
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DiscreteMesh
impl RefUnwindSafe for DiscreteMesh
impl Send for DiscreteMesh
impl Sync for DiscreteMesh
impl Unpin for DiscreteMesh
impl UnsafeUnpin for DiscreteMesh
impl UnwindSafe for DiscreteMesh
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.