Struct tri_mesh::Walker

source ·
pub struct Walker<'a> { /* private fields */ }
Expand description

Used for easy and efficient traversal of the mesh. Also see Connectivity for common connectivity utility functionality.

Use Mesh::walker_from_vertex, Mesh::walker_from_halfedge or Mesh::walker_from_face 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 a 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.0f64;
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 f64;

Implementations

Walk to the next half-edge in the adjacent face.

Walk to the previous half-edge in the adjacent face.

Walk to the twin half-edge.

Walk to the next half-edge in the adjacent face.

Walk to the previous half-edge in the adjacent face.

Walk to the twin half-edge.

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.

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.

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.

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.

Returns the id of the current half-edge or None if the walker has walked outside of the mesh at some point.

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.