Struct half_edge_mesh::mesh::HalfEdgeMesh [−][src]
pub struct HalfEdgeMesh { pub edges: HashMap<u32, EdgeRc>, pub vertices: HashMap<u32, VertRc>, pub faces: HashMap<u32, FaceRc>, // some fields omitted }
Half-Edge Mesh data structure
While it's possible to create non-triangular faces, this code assumes
triangular faces in several locations
mesh.edges, mesh.vertices, and mesh.faces are HashMaps
containing reference-counted Pointers
to the mesh contents. Usually, these Rc values are the last values to exist. When they
are destroyed, the pointed-to contents are destroyed as well.
Vertex, edge, and face ids are mesh-specific and unique only within a certain mesh
Integer overflow is undefined in Rust, but checked in debug builds. I think this means
that it's possible to generate the same id twice, after 2^32-1 ids have been made.
Try not to make more than 2^32-1 of any one of them, stuff might get messed up.
TODO: Better error reporting, using a custom error type
See also: http://blog.burntsushi.net/rust-error-handling/
Probably should do it whenever faces are added or a vertex is modified ?
TODO: Better way of updating face-specific data like center and normals
Fields
edges: HashMap<u32, EdgeRc>
vertices: HashMap<u32, VertRc>
faces: HashMap<u32, FaceRc>
Methods
impl HalfEdgeMesh
[src]
impl HalfEdgeMesh
pub fn empty() -> HalfEdgeMesh
[src]
pub fn empty() -> HalfEdgeMesh
Constructs an empty mesh
pub fn from_tetrahedron_pts(
p1: Point3<f32>,
p2: Point3<f32>,
p3: Point3<f32>,
p4: Point3<f32>
) -> HalfEdgeMesh
[src]
pub fn from_tetrahedron_pts(
p1: Point3<f32>,
p2: Point3<f32>,
p3: Point3<f32>,
p4: Point3<f32>
) -> HalfEdgeMesh
Construct a half edge mesh from four points that form a tetrahedron A half-edge mesh requires at least a tetrahedron to be valid. When seen from an arbitrary "front" side of the tetrahedron, the vertices given to this function should be as follows: p1: apex, p2: bottom left front, p3: bottom right front, p4: bottom rear
pub fn from_octahedron_pts(
p1: Point3<f32>,
p2: Point3<f32>,
p3: Point3<f32>,
p4: Point3<f32>,
p5: Point3<f32>,
p6: Point3<f32>
) -> HalfEdgeMesh
[src]
pub fn from_octahedron_pts(
p1: Point3<f32>,
p2: Point3<f32>,
p3: Point3<f32>,
p4: Point3<f32>,
p5: Point3<f32>,
p6: Point3<f32>
) -> HalfEdgeMesh
Construct a half edge mesh from six points that form an octahedron p1: top apex, p2: mid left front, p3: mid right front, p4: mid left back, p5: mid right back, p6: bottom apex
pub fn from_face_vertex_mesh(
vertices: &[Point3<f32>],
indices: &[[usize; 3]]
) -> HalfEdgeMesh
[src]
pub fn from_face_vertex_mesh(
vertices: &[Point3<f32>],
indices: &[[usize; 3]]
) -> HalfEdgeMesh
Construct a half edge mesh from a Vec of vertices and a Vec of triplets of indices into the Vec of vertices.
pub fn new_edge_id(&mut self) -> u32
[src]
pub fn new_edge_id(&mut self) -> u32
pub fn new_vert_id(&mut self) -> u32
[src]
pub fn new_vert_id(&mut self) -> u32
pub fn new_face_id(&mut self) -> u32
[src]
pub fn new_face_id(&mut self) -> u32
pub fn push_edge(&mut self, edge: EdgeRc)
[src]
pub fn push_edge(&mut self, edge: EdgeRc)
pub fn extend_edges(&mut self, edges: &[EdgeRc])
[src]
pub fn extend_edges(&mut self, edges: &[EdgeRc])
pub fn move_edges(&mut self, edges: Vec<EdgeRc>)
[src]
pub fn move_edges(&mut self, edges: Vec<EdgeRc>)
pub fn push_vert(&mut self, vert: VertRc)
[src]
pub fn push_vert(&mut self, vert: VertRc)
pub fn extend_verts(&mut self, verts: &[VertRc])
[src]
pub fn extend_verts(&mut self, verts: &[VertRc])
pub fn move_verts(&mut self, verts: Vec<VertRc>)
[src]
pub fn move_verts(&mut self, verts: Vec<VertRc>)
pub fn push_face(&mut self, face: FaceRc)
[src]
pub fn push_face(&mut self, face: FaceRc)
pub fn extend_faces(&mut self, faces: &[FaceRc])
[src]
pub fn extend_faces(&mut self, faces: &[FaceRc])
pub fn move_faces(&mut self, faces: Vec<FaceRc>)
[src]
pub fn move_faces(&mut self, faces: Vec<FaceRc>)
pub fn add_triangle(&mut self, triangle: (FaceRc, EdgeRc, EdgeRc, EdgeRc))
[src]
pub fn add_triangle(&mut self, triangle: (FaceRc, EdgeRc, EdgeRc, EdgeRc))
Adds a tuple of (face, edge, edge, edge) to the mesh
pub fn make_triangle(
&mut self,
p1: &VertRc,
p2: &VertRc,
p3: &VertRc
) -> (FaceRc, EdgeRc, EdgeRc, EdgeRc)
[src]
pub fn make_triangle(
&mut self,
p1: &VertRc,
p2: &VertRc,
p3: &VertRc
) -> (FaceRc, EdgeRc, EdgeRc, EdgeRc)
Takes three Rc<RefCell<Vert>>
,
creates three edges and one face, and connects them as well as it can
Note: since this creates a lone triangle, edge.pair links are
still empty after this function
pub fn are_faces_adjacent(&self, face_l: &FaceRc, face_r: &FaceRc) -> bool
[src]
pub fn are_faces_adjacent(&self, face_l: &FaceRc, face_r: &FaceRc) -> bool
Checks if two faces are adjacent by looking for a shared edge
pub fn are_face_ptrs_adjacent(&self, face_l: &FacePtr, face_r: &FacePtr) -> bool
[src]
pub fn are_face_ptrs_adjacent(&self, face_l: &FacePtr, face_r: &FacePtr) -> bool
pub fn triangulate_face(&mut self, point: Point3<f32>, target_face: &FaceRc)
[src]
pub fn triangulate_face(&mut self, point: Point3<f32>, target_face: &FaceRc)
Replace a face with three faces, each connected to the new point And one of the face's previous vertices TODO: Make all of these mesh-manipulation functions return a Result<(), &str> to check that manipulation was completed
pub fn triangulate_face_ptr(&mut self, point: Point3<f32>, face: &FacePtr)
[src]
pub fn triangulate_face_ptr(&mut self, point: Point3<f32>, face: &FacePtr)
pub fn attach_point_for_faces(
&mut self,
point: Point3<f32>,
remove_faces: &[FaceRc]
) -> Result<Vec<FaceRc>, &'static str>
[src]
pub fn attach_point_for_faces(
&mut self,
point: Point3<f32>,
remove_faces: &[FaceRc]
) -> Result<Vec<FaceRc>, &'static str>
Attach a point to a mesh, replacing many faces (used for the convex hull algorithm) The faces should be a continuously connected group, each adjacent pair of vertices in the border of this group are connected to the point in a new triangular face. The programmer is responsible for ensuring that there are no holes in the passed set of faces. Returns Pointers to the new faces in the result, if successful
pub fn attach_point_for_face_ptrs(
&mut self,
point: Point3<f32>,
faces: &[FacePtr]
) -> Result<Vec<FaceRc>, &'static str>
[src]
pub fn attach_point_for_face_ptrs(
&mut self,
point: Point3<f32>,
faces: &[FacePtr]
) -> Result<Vec<FaceRc>, &'static str>
pub fn remove_vert(&mut self, vert: &VertRc) -> Result<(), &'static str>
[src]
pub fn remove_vert(&mut self, vert: &VertRc) -> Result<(), &'static str>
This function should only work if the vertex has exactly three adjacent edges. Therefore, it has three adjacent faces. The vertices connected to those edges form a new face, and the faces and edges connected to the removed vertex are also removed
pub fn remove_vert_ptr(&mut self, point: &VertPtr) -> Result<(), &'static str>
[src]
pub fn remove_vert_ptr(&mut self, point: &VertPtr) -> Result<(), &'static str>
pub fn flip_edge(&mut self, _edge: &EdgeRc)
[src]
pub fn flip_edge(&mut self, _edge: &EdgeRc)
flips an edge between two faces so that the faces are each split by the other diagonal of the parallelogram they form.
pub fn flip_edge_ptr(&mut self, edge: &EdgePtr)
[src]
pub fn flip_edge_ptr(&mut self, edge: &EdgePtr)
pub fn split_edge(&mut self, _edge: &EdgeRc, _tval: f32)
[src]
pub fn split_edge(&mut self, _edge: &EdgeRc, _tval: f32)
Inserts a vertex at the position, specified by tval, along edge.origin -> edge.next.origin The edge's two neighboring faces are each split into two faces. All four new faces include the new vertex
pub fn split_edge_rc(&mut self, edge: &EdgePtr, tval: f32)
[src]
pub fn split_edge_rc(&mut self, edge: &EdgePtr, tval: f32)
Auto Trait Implementations
impl !Send for HalfEdgeMesh
impl !Send for HalfEdgeMesh
impl !Sync for HalfEdgeMesh
impl !Sync for HalfEdgeMesh