pub struct HalfEdgeMesh {
pub vertices: Vec<[f64; 3]>,
pub half_edges: Vec<HalfEdge>,
pub face_starts: Vec<usize>,
}Expand description
A half-edge mesh structure for efficient topological queries.
Fields§
§vertices: Vec<[f64; 3]>Vertex positions.
half_edges: Vec<HalfEdge>Half-edges.
face_starts: Vec<usize>For each face, the index of one of its half-edges.
Implementations§
Source§impl HalfEdgeMesh
impl HalfEdgeMesh
Sourcepub fn from_triangle_mesh(verts: &[[f64; 3]], tris: &[[usize; 3]]) -> Self
pub fn from_triangle_mesh(verts: &[[f64; 3]], tris: &[[usize; 3]]) -> Self
Build a half-edge mesh from a triangle mesh given as vertices + face indices.
Sourcepub fn n_vertices(&self) -> usize
pub fn n_vertices(&self) -> usize
Return the number of vertices.
Sourcepub fn face_vertices(&self, fi: usize) -> [usize; 3]
pub fn face_vertices(&self, fi: usize) -> [usize; 3]
Return the three vertex indices for face fi.
Sourcepub fn boundary_half_edges(&self) -> Vec<usize>
pub fn boundary_half_edges(&self) -> Vec<usize>
Return all boundary edges (half-edges with no twin).
Sourcepub fn is_manifold(&self) -> bool
pub fn is_manifold(&self) -> bool
Check whether the mesh is manifold (every edge has exactly one twin).
Sourcepub fn add_vertex(&mut self, pos: [f64; 3]) -> usize
pub fn add_vertex(&mut self, pos: [f64; 3]) -> usize
Add a vertex to the mesh. Returns the vertex index.
Sourcepub fn add_triangle(&mut self, v0: usize, v1: usize, v2: usize) -> usize
pub fn add_triangle(&mut self, v0: usize, v1: usize, v2: usize) -> usize
Add a triangle face (given vertex indices). Returns the face index.
Sourcepub fn build_twin_links(&mut self)
pub fn build_twin_links(&mut self)
Rebuild twin half-edge links from scratch.
Sourcepub fn face_count(&self) -> usize
pub fn face_count(&self) -> usize
Alias for n_faces().
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Alias for n_vertices().
Sourcepub fn active_vertex_count(&self) -> usize
pub fn active_vertex_count(&self) -> usize
Alias for n_vertices() (no deletion tracking in this implementation).
Sourcepub fn active_face_count(&self) -> usize
pub fn active_face_count(&self) -> usize
Alias for n_faces() (no deletion tracking in this implementation).
Sourcepub fn face_normal(&self, fi: usize) -> [f64; 3]
pub fn face_normal(&self, fi: usize) -> [f64; 3]
Compute the unit normal for face fi.
Sourcepub fn face_centroid(&self, fi: usize) -> [f64; 3]
pub fn face_centroid(&self, fi: usize) -> [f64; 3]
Compute the centroid of face fi.
Sourcepub fn boundary_edges(&self) -> Vec<(usize, usize)>
pub fn boundary_edges(&self) -> Vec<(usize, usize)>
Return boundary edges as (from_vertex, to_vertex) pairs.
Sourcepub fn boundary_loops(&self) -> Vec<Vec<usize>>
pub fn boundary_loops(&self) -> Vec<Vec<usize>>
Group boundary edges into connected loops (lists of vertex indices).
Sourcepub fn is_boundary_vertex(&self, v: usize) -> bool
pub fn is_boundary_vertex(&self, v: usize) -> bool
Check whether vertex v is on the boundary (has at least one boundary half-edge).
Sourcepub fn vertex_neighbors(&self, v: usize) -> Vec<usize>
pub fn vertex_neighbors(&self, v: usize) -> Vec<usize>
Find all vertex neighbors of vertex v (vertices connected by an edge).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HalfEdgeMesh
impl RefUnwindSafe for HalfEdgeMesh
impl Send for HalfEdgeMesh
impl Sync for HalfEdgeMesh
impl Unpin for HalfEdgeMesh
impl UnsafeUnpin for HalfEdgeMesh
impl UnwindSafe for HalfEdgeMesh
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<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.