HasIterators

Trait HasIterators 

Source
pub trait HasIterators: HasTopology {
Show 52 methods // Provided methods fn voh_ccw_iter(&self, v: VH) -> impl Iterator<Item = HH> { ... } fn voh_cw_iter(&self, v: VH) -> impl Iterator<Item = HH> { ... } fn vih_ccw_iter(&self, v: VH) -> impl Iterator<Item = HH> { ... } fn vih_cw_iter(&self, v: VH) -> impl Iterator<Item = HH> { ... } fn vf_ccw_iter(&self, v: VH) -> impl Iterator<Item = FH> { ... } fn vf_cw_iter(&self, v: VH) -> impl Iterator<Item = FH> { ... } fn vv_ccw_iter(&self, v: VH) -> impl Iterator<Item = VH> { ... } fn vv_cw_iter(&self, v: VH) -> impl Iterator<Item = VH> { ... } fn ve_ccw_iter(&self, v: VH) -> impl Iterator<Item = EH> { ... } fn ve_cw_iter(&self, v: VH) -> impl Iterator<Item = EH> { ... } fn ev_iter(&self, e: EH) -> impl Iterator<Item = VH> { ... } fn eh_iter(&self, e: EH) -> impl Iterator<Item = HH> { ... } fn ef_iter(&self, e: EH) -> impl Iterator<Item = FH> { ... } fn fh_ccw_iter(&self, f: FH) -> impl Iterator<Item = HH> { ... } fn fh_cw_iter(&self, f: FH) -> impl Iterator<Item = HH> { ... } fn fv_ccw_iter(&self, f: FH) -> impl Iterator<Item = VH> { ... } fn fv_cw_iter(&self, f: FH) -> impl Iterator<Item = VH> { ... } fn fe_ccw_iter(&self, f: FH) -> impl Iterator<Item = EH> { ... } fn fe_cw_iter(&self, f: FH) -> impl Iterator<Item = EH> { ... } fn ff_ccw_iter(&self, f: FH) -> impl Iterator<Item = FH> { ... } fn ff_cw_iter(&self, f: FH) -> impl Iterator<Item = FH> { ... } fn ccw_rotate_iter(&self, h: HH) -> impl Iterator<Item = HH> { ... } fn cw_rotate_iter(&self, h: HH) -> impl Iterator<Item = HH> { ... } fn loop_ccw_iter(&self, h: HH) -> impl Iterator<Item = HH> { ... } fn loop_cw_iter(&self, h: HH) -> impl Iterator<Item = HH> { ... } fn voh_ccw_iter_mut( &mut self, v: VH, ) -> impl Iterator<Item = (&mut Self, HH)> { ... } fn voh_cw_iter_mut( &mut self, v: VH, ) -> impl Iterator<Item = (&mut Self, HH)> { ... } fn vih_ccw_iter_mut( &mut self, v: VH, ) -> impl Iterator<Item = (&mut Self, HH)> { ... } fn vih_cw_iter_mut( &mut self, v: VH, ) -> impl Iterator<Item = (&mut Self, HH)> { ... } fn vv_ccw_iter_mut( &mut self, v: VH, ) -> impl Iterator<Item = (&mut Self, VH)> { ... } fn vv_cw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, VH)> { ... } fn ve_ccw_iter_mut( &mut self, v: VH, ) -> impl Iterator<Item = (&mut Self, EH)> { ... } fn ve_cw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, EH)> { ... } fn vf_ccw_iter_mut( &mut self, v: VH, ) -> impl Iterator<Item = (&mut Self, FH)> { ... } fn vf_cw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, FH)> { ... } fn fv_ccw_iter_mut( &mut self, f: FH, ) -> impl Iterator<Item = (&mut Self, VH)> { ... } fn fv_cw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, VH)> { ... } fn fh_ccw_iter_mut( &mut self, f: FH, ) -> impl Iterator<Item = (&mut Self, HH)> { ... } fn fh_cw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, HH)> { ... } fn fe_ccw_iter_mut( &mut self, f: FH, ) -> impl Iterator<Item = (&mut Self, EH)> { ... } fn fe_cw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, EH)> { ... } fn ff_ccw_iter_mut( &mut self, f: FH, ) -> impl Iterator<Item = (&mut Self, FH)> { ... } fn ff_cw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, FH)> { ... } fn ccw_rotate_iter_mut( &mut self, h: HH, ) -> impl Iterator<Item = (&mut Self, HH)> { ... } fn cw_rotate_iter_mut( &mut self, h: HH, ) -> impl Iterator<Item = (&mut Self, HH)> { ... } fn loop_ccw_iter_mut( &mut self, h: HH, ) -> impl Iterator<Item = (&mut Self, HH)> { ... } fn loop_cw_iter_mut( &mut self, h: HH, ) -> impl Iterator<Item = (&mut Self, HH)> { ... } fn triangulated_face_vertices(&self, f: FH) -> impl Iterator<Item = [VH; 3]> { ... } fn triangulated_loop_vertices( &self, hstart: HH, ) -> impl Iterator<Item = [VH; 3]> { ... } fn triangulated_vertices( &self, fstatus: &FPropBuf<Status>, ) -> impl Iterator<Item = [VH; 3]> { ... } fn find_halfedge(&self, from: VH, to: VH) -> Option<HH> { ... } fn adjust_outgoing_halfedge(&mut self, v: VH) { ... }
}
Expand description

This trait defines iterators to traverse the topology of a mesh.

§Working with mutable iterators

Iterators such as Self::loop_ccw_iter and other *_iter iterators borrow the mesh immutably. These are useful when iterating over the elements of the mesh without needing to modify the mesh. While the mesh is borrowed by the iterators, the borrow checker will not let you borrow the mesh again mutably, for as long as the iterator is alive. This is a problem if you’re trying to modify the mesh while iterating over it’s elements. In such scenarios, mutable iterators are useful. These functions end with *_iter_mut.

The *_iter_mut functions borrow the mesh mutably. Similar to immutable iterators, while the mutable iterator is alive, the borrow checker won’t let you mutably borrow the mesh again. But, unlike the immutable iterators, the mutable iterators don’t yield just the elements of the mesh. Instead the mutable iterators yield a tuple containing a mutable reference to the mesh, and the mesh element. You can modify the mesh using the mutable reference yielded by the mutable iterator. So essentially, the borrow checker is happy because the iterator borrows the mesh mutably and to modify the mesh, you borrow the mesh from the iterator. The borrows are chained instead of being simultaenous. This keeps the borrow checker happy, and ensures safety to some extent. Below is some example code that iterates over the vertices of face with index 2, and modifies their positions.

use alum::{PolyMeshF32, FH, HasIterators, HasTopology};

let mut boxmesh = PolyMeshF32::unit_box().expect("Cannot create a box");
assert_eq!(1.0, boxmesh.try_calc_volume().expect("Cannot compute volume"));
// Modify the mesh while using a mutable iterator - pull points closer to origin.
let f: FH = 2.into();
for (mesh, v) in boxmesh.fv_ccw_iter_mut(f) {
    // Inside this loop, while the iterator is alive, we cannot borrow `boxmesh`
    // because the iterator already borrowed `boxmesh` mutably. Instead we will use
    // the `mesh` mutable reference yielded by the iterator along with the halfedge.
    let mut pos = mesh.point(v).expect("Cannot read position");
    pos *= 0.75;
    mesh.set_point(v, pos);
}
// The iterator is not alive anymore, so we can borrow `boxmesh` again.
boxmesh.check_topology().expect("Topological errors found");
// Volume is smaller than one because we pulled the vertices closer to the origin.
assert!(1.0 > boxmesh.try_calc_volume().expect("Cannot compute volume"));

Despite enforcing the borrow checker rules, the mutable iterators can lead to problems when used incorrectly. Modifying the topology of the mesh while using mutable iterators is NOT advised, as this can lead to topological errors. Only do this if you’re know what you’re doing. This is akin to mutably iterating over a linked list while modifying the links between the elements of the linked list. You can easily create cycles, infinite loops and other problems if you’re not careful.

Provided Methods§

Source

fn voh_ccw_iter(&self, v: VH) -> impl Iterator<Item = HH>

Iterator over the outgoing halfedges around a vertex, going counter-clockwise.

Source

fn voh_cw_iter(&self, v: VH) -> impl Iterator<Item = HH>

Iterator over the outgoing halfedges around a vertex, going clockwise

Source

fn vih_ccw_iter(&self, v: VH) -> impl Iterator<Item = HH>

Iterator over the incoming halfedges around a vertex, going counter-clockwise

Source

fn vih_cw_iter(&self, v: VH) -> impl Iterator<Item = HH>

Iterator over the incoming halfedges around a vertex, going clockwise

Source

fn vf_ccw_iter(&self, v: VH) -> impl Iterator<Item = FH>

Iterator over the faces incident on a vertex, going counter-clockwise.

Source

fn vf_cw_iter(&self, v: VH) -> impl Iterator<Item = FH>

Iterator over the faces incident on a vertex, going clockwise.

Source

fn vv_ccw_iter(&self, v: VH) -> impl Iterator<Item = VH>

Iterator over the neighboring vertices around the given vertex, going counter-clockwise.

Source

fn vv_cw_iter(&self, v: VH) -> impl Iterator<Item = VH>

Iterator over the neighboring vertices around the given vertex, going clockwise.

Source

fn ve_ccw_iter(&self, v: VH) -> impl Iterator<Item = EH>

Iterator over the incident edges around an vertex, going counter-clockwise.

Source

fn ve_cw_iter(&self, v: VH) -> impl Iterator<Item = EH>

Iterator over the incident edges around a vertex, going clockwise.

Source

fn ev_iter(&self, e: EH) -> impl Iterator<Item = VH>

Iterator over the two vertices incident on the given edge.

Source

fn eh_iter(&self, e: EH) -> impl Iterator<Item = HH>

Iterator over the two halfedges corresponding to an edge.

Source

fn ef_iter(&self, e: EH) -> impl Iterator<Item = FH>

Iterator over the faces incident on an edge.

Source

fn fh_ccw_iter(&self, f: FH) -> impl Iterator<Item = HH>

Iterator over the halfedges of a face loop, going counter-clockwise.

Source

fn fh_cw_iter(&self, f: FH) -> impl Iterator<Item = HH>

Iterator over the halfedges of a face loop, going clockwise.

Source

fn fv_ccw_iter(&self, f: FH) -> impl Iterator<Item = VH>

Iterator over the vertices incident on a face, going counter-clockwise.

Source

fn fv_cw_iter(&self, f: FH) -> impl Iterator<Item = VH>

Iterator over the vertices incident on a face, going clockwise.

Source

fn fe_ccw_iter(&self, f: FH) -> impl Iterator<Item = EH>

Iterator over the edges incident on a face, going counter-clockwise.

Source

fn fe_cw_iter(&self, f: FH) -> impl Iterator<Item = EH>

Iterator over the edges incident on a face, going clockwise.

Source

fn ff_ccw_iter(&self, f: FH) -> impl Iterator<Item = FH>

Iterator over the neighboring faces arouund the given face, going counter-clockwise.

This includes the faces connected via a shared edge, but not those connected via a shared vertex.

Source

fn ff_cw_iter(&self, f: FH) -> impl Iterator<Item = FH>

Iterator over the neighboring faces around the given face, going clockwise.

This includes the faces connected via a shared edge, but not those connected via a shared vertex.

Source

fn ccw_rotate_iter(&self, h: HH) -> impl Iterator<Item = HH>

This is similar to Self::voh_ccw_iter around the tail of the given halfedge, except this iterator starts at the provided halfedge.

This is equivalent to a circular shifted Self::voh_ccw_iter of the vertex at the tail of this halfedge.

Source

fn cw_rotate_iter(&self, h: HH) -> impl Iterator<Item = HH>

This is similar to Self::voh_cw_iter around the tail of the given halfedge, except this iterator starts at the provided halfedge.

This is equivalent to a circular shifted Self::voh_cw_iter of the vertex at the tail of this halfedge.

Source

fn loop_ccw_iter(&self, h: HH) -> impl Iterator<Item = HH>

Counter-clockwise iterator over the halfedges in a loop.

The iterator will start at the given halfedge. If the halfedge has an incident face, this iterator is equivalent to a circular shifted Self::fh_ccw_iter of the incident face. If the halfedge is on the boundary, this iterator goes over the boundary loop counter-clockwise.

Source

fn loop_cw_iter(&self, h: HH) -> impl Iterator<Item = HH>

Counter-clockwise iterator over the halfedges in a loop.

The iterator will start at the given halfedge. If the halfedge has an incident face, this iterator is equivalent to a circular shifted Self::fh_cw_iter of the incident face. If the halfedge is on the boundary, this iterator goes over the boundary loop clockwise.

Source

fn voh_ccw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, HH)>

Iterator over the outgoing halfedges around a vertex, going counter-clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn voh_cw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, HH)>

Iterator over the outgoing halfedges around a vertex, going clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn vih_ccw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, HH)>

Iterator over the incoming halfedges around a vertex, going counter-clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn vih_cw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, HH)>

Iterator over the incoming halfedges around a vertex, going clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn vv_ccw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, VH)>

Mutable iterator over the neighboring vertices around the given vertex, going counter-clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn vv_cw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, VH)>

Mutable iterator over the neighboring vertices around the given vertex, going clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn ve_ccw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, EH)>

Iterator over the incident edges around a vertex, going counter-clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn ve_cw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, EH)>

Iterator over the incident edges around a vertex, going clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn vf_ccw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, FH)>

Iterator over the incident faces around a vertex, going counter-clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn vf_cw_iter_mut(&mut self, v: VH) -> impl Iterator<Item = (&mut Self, FH)>

Iterator over the incident faces around a vertex, going clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn fv_ccw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, VH)>

Iterator over the vertices incident on a face, going counter-clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn fv_cw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, VH)>

Iterator over the vertices incident on a face, going clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn fh_ccw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, HH)>

Iterator over the halfedges of a face loop, going counter-clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn fh_cw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, HH)>

Iterator over the halfedges in a face loop, going clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn fe_ccw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, EH)>

Iterator over the edges incident on a face, going counter-clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn fe_cw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, EH)>

Iterator over the edges incident on a face, going clockwise.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn ff_ccw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, FH)>

Iterator over the neighboring faces around a given face, going counter-clockwise.

This includes the faces connected via a shared edge, but not those connected via shared edge.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn ff_cw_iter_mut(&mut self, f: FH) -> impl Iterator<Item = (&mut Self, FH)>

Iterator over the neighboring faces around a given face, going clockwise.

This includes the faces connected via a shared edge, but not those connected via shared edge.

A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn ccw_rotate_iter_mut( &mut self, h: HH, ) -> impl Iterator<Item = (&mut Self, HH)>

This is similar to Self::voh_ccw_iter_mut around the tail of the given halfedge, except this iterator starts at the provided halfedge.

This is equivalent to a circular shifted Self::voh_ccw_iter_mut of the vertex at the tail of the given halfedge. A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn cw_rotate_iter_mut(&mut self, h: HH) -> impl Iterator<Item = (&mut Self, HH)>

This is similar to Self::voh_cw_iter_mut around the tail of the given halfedge, except this iterator starts at the provided halfedge.

This is equivalent to a circular shifted Self::voh_cw_iter_mut of the vertex at the tail of the given halfedge. A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn loop_ccw_iter_mut(&mut self, h: HH) -> impl Iterator<Item = (&mut Self, HH)>

Counter-clockwise iterator over the halfedges in a loop.

The iterator will start at the given halfedge. If the halfedge has an incident face, this iterator is equivalent to a circular shifted Self::fh_ccw_iter_mut of the incident face. If the halfedge is on the boundary, this iterator goes over the boundary loop counter-clockwise. A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn loop_cw_iter_mut(&mut self, h: HH) -> impl Iterator<Item = (&mut Self, HH)>

Counter-clockwise iterator over the halfedges in a loop.

The iterator will start at the given halfedge. If the halfedge has an incident face, this iterator is equivalent to a circular shifted Self::fh_cw_iter_mut of the incident face. If the halfedge is on the boundary, this iterator goes over the boundary loop clockwise. A mutable iterator allows modifying the mesh while iterating over its elements. See this section for an overview on mutable iterators.

Source

fn triangulated_face_vertices(&self, f: FH) -> impl Iterator<Item = [VH; 3]>

Iterator over the vertex triplets that represent a triangulation of the given face.

The triangulation does not take the shape of the face into account. It only accounts for the topology of the face.

use alum::{PolyMeshF32, Handle, HasTopology, HasIterators, Vec3};

let mut mesh = PolyMeshF32::new();
let verts = [Vec3(0.0, 0.0, 0.0), Vec3(1.0, 0.0, 0.0),
             Vec3(1.0, 1.0, 0.0), Vec3(0.0, 1.0, 0.0)];
mesh.add_vertices(&verts).expect("Cannot add vertices");
mesh.add_quad_face(0.into(), 1.into(), 2.into(), 3.into());
assert_eq!(mesh.triangulated_face_vertices(0.into())
               .flatten()
               .map(|v| v.index())
               .collect::<Vec<u32>>(), [3, 0, 1, 3, 1, 2]);
Source

fn triangulated_loop_vertices( &self, hstart: HH, ) -> impl Iterator<Item = [VH; 3]>

Iterator over the vertex triplets that represent a triangulation of the given loop. Unlike Self::triangulated_face_vertices, this can be used on face loops as well as boundary loops. For example, this can be used to fill a boundary loop with triangles.

The triangulation does not take the shape of the loop into account. It only accounts for the topology of the face.

Source

fn triangulated_vertices( &self, fstatus: &FPropBuf<Status>, ) -> impl Iterator<Item = [VH; 3]>

Iterator over the vertex triplets that represent a triangulation of this mesh. The triangulation of a face does not take it’s shape into account. It only accounts for the topology.

use alum::{PolyMeshF32, Handle, HasTopology, HasIterators, Vec3};

let mut mesh = PolyMeshF32::new();
let verts = [Vec3(0.0, 0.0, 0.0), Vec3(1.0, 0.0, 0.0),
             Vec3(1.0, 1.0, 0.0), Vec3(0.0, 1.0, 0.0)];
mesh.add_vertices(&verts).expect("Cannot add vertices");
mesh.add_quad_face(0.into(), 1.into(), 2.into(), 3.into());
let fstatus = mesh.face_status_prop();
let fstatus = fstatus.try_borrow().unwrap();
assert_eq!(mesh.triangulated_vertices(&fstatus)
               .flatten()
               .map(|v| v.index())
               .collect::<Vec<u32>>(), [3, 0, 1, 3, 1, 2]);
Source

fn find_halfedge(&self, from: VH, to: VH) -> Option<HH>

Find a halfedge spanning the vertices from and to, if one exists

Source

fn adjust_outgoing_halfedge(&mut self, v: VH)

Adjust the outgoing halfedge of a vertex, if necessary.

If a vertex is on the boundary, it’s outgoing halfedge MUST be a boundary halfedge.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<const DIM: usize, A> HasIterators for PolyMeshT<DIM, A>
where A: Adaptor<DIM>,