### Collection Iterators

Use these routines to iterate over all of the elements in the mesh.

Note: Generally, modifying the mesh while iterating is allowed, but the new elements may or may not be iterated over, and previous elements might even appear again later later in the iteration after modifying.

SurfaceMesh::vertices()

Iterate over the vertices in a mesh.

for(Vertex v : mesh.vertices()) {
// do science here
}

SurfaceMesh::halfedges()

Iterate over all of the halfedges in a mesh (both real and imaginary, if the mesh has boundary).

for(Halfedge he : mesh.halfedges()) {
// do science here
}

SurfaceMesh::realHalfedges()

Iterate over the real halfedges in a mesh.

for(Halfedge he : mesh.realHalfedges()) {
// do science here
}
Note that on a boundary edge between vertices i <--> j, this set will only include a halfedge from i --> j, but not from j --> i (or vice versa).

SurfaceMesh::exteriorHalfedges()

Iterate over the exterior halfedges in a mesh. (only useful on ManifoldSurfaceMesh)

for(Halfedge he : mesh.exteriorHalfedges()) {
// do science here
}
Note that on a boundary edge between vertices i <--> j, this set will only include a halfedge from i --> j, but not from j --> i (or vice versa).

SurfaceMesh::edges()

Iterate over the edges in a mesh.

for(Edge e : mesh.edges()) {
// do science here
}

SurfaceMesh::faces()

Iterate over the faces in a mesh.

for(Face f : mesh.faces()) {
// do science here
}

## Neighborhood Iterators

Use these routines to iterate over the neighbors of a mesh element.

Note: neighborhoods on $\Delta$-complexes

The iterators in this section may have unexpected behavior in the advanced case of a $\Delta$-complex, when there are (e.g.) self-edges, or multiple edges between a pair of vertices. Essentially, these iterators always naively traverse the local neighborhood, even if that neighborhood might include duplicate elements.

For instance, if a $\Delta$-complex has multiple edges connecting vertex va to vertex vb, then iterating va.adjacentVertices() will return vb multiple times.

Of course, for ordinary triangle mesh they will behave as expected. See the Delta complex section for more information.

### Around a vertex

Vertex::outgoingHalfedges()

Iterate over the halfedges which point outward from a vertex.

for(Halfedge he : vert.outgoingHalfedges()) {
assert(he.vertex() == vert); // true
// do science here
}

Vertex::incomingHalfedges()

Iterate over the halfedges which point inward at a vertex.

for(Halfedge he : vert.incomingHalfedges()) {
assert(he.twin().vertex() == vert); // true
// do science here
}

Iterate over the vertices edge-connected to this vertex.

// do science here
}

Iterate over the edges incident on this vertex.

// do science here
}

Iterate over the faces incident on this vertex.

// do science here
}

### Around an edge

Iterate over the halfedges incident on this edge.

// do science here
}

Iterate over the (one or two) faces incident on this edge.

// do science here
}

### Around a face

Iterate over the vertices adjacent to a face.

// do science here
}

Iterate over the halfedges incident on a face.

// do science here
}

Iterate over the edges on the boundary of a face.

// do science here
}

Iterate over the faces adjacent to a face, across each edge.

// do science here
}

### Around a boundary loop

Iterate over the vertices adjacent to a boundary loop.

// do science here
}

Iterate over the (exterior) halfedges incident on a boundary loop.

// do science here
}

Iterate over the edges on the boundary of a boundary loop.

// do science here
}

## Accessors

Use these routines to access elements of the mesh by their index.

Warning

The indexing routines in the section are only valid when the mesh is compressed.

Halfedge SurfaceMesh::halfedge(size_t index)

Constructs a reference to the i’th halfedge in the mesh. 0 <= index < nHalfedges().

Vertex SurfaceMesh::vertex(size_t index)

Constructs a reference to the i’th vertex in the mesh. 0 <= index < nVertices().

Face SurfaceMesh::face(size_t index)

Constructs a reference to the i’th face in the mesh. 0 <= index < nFaces().

Edge SurfaceMesh::edge(size_t index)

Constructs a reference to the i’th edge in the mesh. 0 <= index < nEdges().

Face SurfaceMesh::face(size_t index)

Constructs a reference to the i’th face in the mesh. 0 <= index < nFaces().

Face SurfaceMesh::boundaryLoop(size_t index)

Constructs a reference to the i’th boundary loop in the mesh. 0 <= index < nBoundaryLoops().