Struct hedge::Mesh
[−]
[src]
pub struct Mesh { pub edge_list: Vec<Edge>, pub vertex_list: Vec<Vertex>, pub face_list: Vec<Face>, }
Implements the fundamental storage operations and represents the principle grouping of all components.
Fields
edge_list: Vec<Edge>
vertex_list: Vec<Vertex>
face_list: Vec<Face>
Methods
impl Mesh
[src]
fn new() -> Mesh
Creates a new Mesh with an initial component added to each Vec.
The idea behind having a single invalid component at the front of each Vec comes from the blog http://ourmachinery.com/post/defaulting-to-zero/
fn set_twin_edges(&mut self, e1: EdgeIndex, e2: EdgeIndex)
Mark the two edges as adjacent twins.
In order for this to be valid each edge should be connected in such a way that the vertex of each is the same as the vertex of the next edge of each.
So: A->Next->Vertex == B->Vertex
&& B->Next->Vertex == A->Vertex
In debug builds we assert the provided indices are valid.
fn connect_edges(&mut self, prev: EdgeIndex, next: EdgeIndex)
Connects the two edges as part of an edge loop.
In debug builds we assert that neither index is not the default index.
fn edge_from_vertex(&mut self, vert: VertexIndex) -> EdgeIndex
Create a new edge from the specified vertex.
In debug builds we assert that the vertex index is not the default index.
fn edge_from_twin(&mut self, twin: EdgeIndex) -> EdgeIndex
Create a new edge as a twin of the specified edge
In debug builds we assert that the twin index is not the default index and that the twins next index is not the default index (since we need that edge to find the correct vertex index).
fn extend_edge_loop(&mut self, vert: VertexIndex, prev: EdgeIndex) -> EdgeIndex
Create a new edge connected to the previous edge specified.
In debug builds we assert that the indices specified are valid.
fn close_edge_loop(
&mut self,
vert: VertexIndex,
prev: EdgeIndex,
next: EdgeIndex
) -> EdgeIndex
&mut self,
vert: VertexIndex,
prev: EdgeIndex,
next: EdgeIndex
) -> EdgeIndex
Create a new edge, closing an edge loop, using the prev
and next
indices provided.
In debug builds we assert that all specified indices are valid.
fn add_edge(&mut self, edge: Edge) -> EdgeIndex
Adds the provided Edge
to the mesh and returns it's EdgeIndex
fn add_vertex(&mut self, vert: Vertex) -> VertexIndex
Adds the provided Vertex
to the mesh and returns it's VertexIndex
fn add_triangle(
&mut self,
a: VertexIndex,
b: VertexIndex,
c: VertexIndex
) -> FaceIndex
&mut self,
a: VertexIndex,
b: VertexIndex,
c: VertexIndex
) -> FaceIndex
Creates a new face and associated edges with the given vertex indices. Returns the index of the newly added face.
In debug builds we assert that all provided indices are valid.
fn add_adjacent_triangle(
&mut self,
c: VertexIndex,
twin_edge: EdgeIndex
) -> FaceIndex
&mut self,
c: VertexIndex,
twin_edge: EdgeIndex
) -> FaceIndex
Creates a new face and associated edges with the given a vertex index and a twin edge index. Returns the index of the newly added face.
In debug builds we assert that the all provided indices are valid.
fn faces(&self) -> Faces
Returns a Faces
iterator for this mesh.
let mesh = hedge::Mesh::new(); for index in mesh.faces() { let face = mesh.face(index); }
fn edges(&self, face: &Face) -> EdgeLoop
Returns an EdgeLoop
iterator for the edges around the specified face.
let mesh = hedge::Mesh::new(); for findex in mesh.faces() { let face = mesh.face(findex); for eindex in mesh.edges(face) { let edge = mesh.edge(eindex); } }
fn vertices(&self, face: &Face) -> EdgeLoopVertices
Returns an EdgeLoopVertices
iterator for the vertices around the specified face.
let mesh = hedge::Mesh::new(); for findex in mesh.faces() { let face = mesh.face(findex); for vindex in mesh.vertices(face) { let vertex = mesh.vertex(vindex); } }
fn face(&self, index: FaceIndex) -> &Face
fn face_fn(&self, index: FaceIndex) -> FaceFn
Returns a FaceFn
for the given index.
use hedge::{Mesh, Vertex}; let mut mesh = Mesh::new(); let v1 = mesh.add_vertex(Vertex::default()); let v2 = mesh.add_vertex(Vertex::default()); let v3 = mesh.add_vertex(Vertex::default()); let f1 = mesh.add_triangle(v1, v2, v3); assert!(mesh.face_fn(f1).edge().next().vertex().index == v2);
fn face_mut(&mut self, index: FaceIndex) -> Option<&mut Face>
Obtains a mutable reference to the Face
for the provided index.
fn edge(&self, index: EdgeIndex) -> &Edge
fn edge_fn(&self, index: EdgeIndex) -> EdgeFn
Returns an EdgeFn
for the given index.
fn edge_mut(&mut self, index: EdgeIndex) -> Option<&mut Edge>
Obtains a mutable reference to the Edge
for the provided index.
fn vertex(&self, index: VertexIndex) -> &Vertex
fn vertex_fn(&self, index: VertexIndex) -> VertexFn
Returns a VertexFn
for the given index.
fn vertex_mut(&mut self, index: VertexIndex) -> Option<&mut Vertex>
Obtains a mutable reference to the Vertex
for the provided index.