[−][src]Struct tri_mesh::mesh::traversal::Walker
Used for easy and efficient traversal of the mesh. See Mesh for how to construct a walker and the examples below for instructions on how to use a walker.
Note: If you walk outside the mesh at some point, no error will be returned,
instead, all methods to extract an ID will return None
.
Examples
# 1
// Find the id of the vertex pointed to by a half-edge. let vertex_id = mesh.walker_from_halfedge(halfedge_id).vertex_id().unwrap();
# 2
let mut walker = mesh.walker_from_halfedge(halfedge_id); // Walk around the three sides of a face.. let result_halfedge_id = walker.as_next().as_next().next_id().unwrap(); // .. ending up at the same half-edge assert_eq!(halfedge_id, result_halfedge_id);
# 3
// Find one neighbouring face to the given face let neighbour_face_id = mesh.walker_from_face(face_id).into_twin().face_id().unwrap();
# 4
// Find the circumference of the face let mut walker = mesh.walker_from_face(face_id); let mut circumference = mesh.edge_length(walker.halfedge_id().unwrap()); walker.as_next(); circumference += mesh.edge_length(walker.halfedge_id().unwrap()); circumference += mesh.edge_length(walker.next_id().unwrap());
# 5
// Check if the half-edge is on the boundary of the mesh let mut walker = mesh.walker_from_halfedge(halfedge_id); let is_on_boundary = walker.face_id().is_none() || walker.as_twin().face_id().is_none();
# 6
// Compute the average edge length let mut avg_edge_length = 0.0f32; for halfedge_id in mesh.edge_iter() { let mut walker = mesh.walker_from_halfedge(halfedge_id); let p0 = mesh.vertex_position(walker.vertex_id().unwrap()); let p1 = mesh.vertex_position(walker.as_twin().vertex_id().unwrap()); avg_edge_length += (p0 - p1).magnitude(); } avg_edge_length /= mesh.no_edges() as f32;
Methods
impl<'a> Walker<'a>
[src]
pub fn into_next(self) -> Self
[src]
Walk to the next half-edge in the adjacent face.
pub fn into_previous(self) -> Self
[src]
Walk to the previous half-edge in the adjacent face.
pub fn into_twin(self) -> Self
[src]
Walk to the twin half-edge.
pub fn as_next(&mut self) -> &mut Self
[src]
Walk to the next half-edge in the adjacent face.
pub fn as_previous(&mut self) -> &mut Self
[src]
Walk to the previous half-edge in the adjacent face.
pub fn as_twin(&mut self) -> &mut Self
[src]
Walk to the twin half-edge.
pub fn vertex_id(&self) -> Option<VertexID>
[src]
Returns the id of the vertex pointed to by the current half-edge or None
if the walker has walked outside of the mesh at some point.
pub fn next_id(&self) -> Option<HalfEdgeID>
[src]
Returns the id of the next half-edge in the adjacent face or None
if the half-edge is at the boundary of the mesh
or if the walker has walked outside of the mesh at some point.
pub fn previous_id(&self) -> Option<HalfEdgeID>
[src]
Returns the id of the previous half-edge in the adjacent face or None
if the half-edge is at the boundary of the mesh
or if the walker has walked outside of the mesh at some point.
pub fn twin_id(&self) -> Option<HalfEdgeID>
[src]
Returns the id of the twin half-edge to the current half-edge or None
if the walker has walked outside of the mesh at some point.
pub fn halfedge_id(&self) -> Option<HalfEdgeID>
[src]
Returns the id of the current half-edge or None
if the walker has walked outside of the mesh at some point.
pub fn face_id(&self) -> Option<FaceID>
[src]
Returns the id of the adjacent face or None
if the half-edge is at the boundary of the mesh
or if the walker has walked outside of the mesh at some point.
Trait Implementations
impl<'a> Clone for Walker<'a>
[src]
fn clone(&self) -> Walker<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> Debug for Walker<'a>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,