pub struct HalfEdgeMesh {
pub half_edges: Vec<HalfEdge>,
pub vertices: Vec<HEVertex>,
pub faces: Vec<HEFace>,
}Expand description
A manifold polygon mesh represented with the half-edge data structure.
Supports O(1) adjacency queries: vertex–face, face–face, and edge–edge.
Fields§
§half_edges: Vec<HalfEdge>All half-edges.
vertices: Vec<HEVertex>All vertices.
faces: Vec<HEFace>All faces.
Implementations§
Source§impl HalfEdgeMesh
impl HalfEdgeMesh
Sourcepub fn add_vertex(&mut self, pos: Point3) -> VertexId
pub fn add_vertex(&mut self, pos: Point3) -> VertexId
Add a vertex at the given position and return its VertexId.
Sourcepub fn add_triangle(
&mut self,
v0: VertexId,
v1: VertexId,
v2: VertexId,
) -> FaceId
pub fn add_triangle( &mut self, v0: VertexId, v1: VertexId, v2: VertexId, ) -> FaceId
Add a triangular face from three vertex indices (counter-clockwise winding).
Allocates three half-edges and one face record. Twin links are resolved
lazily by build_twin_links.
Sourcepub fn face_vertices(&self, fid: FaceId) -> Vec<VertexId> ⓘ
pub fn face_vertices(&self, fid: FaceId) -> Vec<VertexId> ⓘ
Walk around a face and collect the vertex indices.
Sourcepub fn vertex_faces(&self, vid: VertexId) -> Vec<FaceId> ⓘ
pub fn vertex_faces(&self, vid: VertexId) -> Vec<FaceId> ⓘ
Collect all faces that share vertex vid.
Sourcepub fn build_twin_links(&mut self)
pub fn build_twin_links(&mut self)
Resolve twin half-edge links by matching directed edges (v_a, v_b) with (v_b, v_a).
Sourcepub fn num_vertices(&self) -> usize
pub fn num_vertices(&self) -> usize
Number of vertices.
Sourcepub fn face_normal(&self, fid: FaceId) -> Point3
pub fn face_normal(&self, fid: FaceId) -> Point3
Compute the face normal (assumes planar convex polygon).
Sourcepub fn face_centroid(&self, fid: FaceId) -> Point3
pub fn face_centroid(&self, fid: FaceId) -> Point3
Compute the centroid of a face.
Trait Implementations§
Source§impl Clone for HalfEdgeMesh
impl Clone for HalfEdgeMesh
Source§fn clone(&self) -> HalfEdgeMesh
fn clone(&self) -> HalfEdgeMesh
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HalfEdgeMesh
impl Debug for HalfEdgeMesh
Source§impl Default for HalfEdgeMesh
impl Default for HalfEdgeMesh
Source§fn default() -> HalfEdgeMesh
fn default() -> HalfEdgeMesh
Returns the “default value” for a type. Read more
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
Mutably borrows from an owned value. Read more
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.