.. role:: blue :class: blue Mesh Iterators ============== .. _Mesh_Iterators_: .. kernel version: 118027 There are several types of iterators available for working with the mesh topology. They are located in the header files *halfedge_iterators.h* and *halfedge_range_iterators.h*: 1. :blue:`EdgeFanIterator` is the iterator for traversing the edges of the vertex fan in a counterclockwise direction (see Fig. 1). Example of use: .. code-block:: cpp for( EdgeFanIterator it( halfedge, iEd ); !it.Done(); ++it ) ; for( EdgeFanIterator it( halfedge, iVx, true ); !it.Done(); ++it ) { if( it.Edge() < SYS_MAX_T ) { ... } if( it.Twin() < SYS_MAX_T ) { ... } } .. figure:: ../../pictures/P.2.2.1.png :width: 18cm :align: center Fig. 1 2. :blue:`EdgeFacetIterator` is the iterator for traversing facet edges, starting from the facet edge in a counterclockwise direction (see Fig. 2). Example of use: .. code-block:: cpp for( EdgeFacetIterator it( halfedge, iFacet ); !it.Done(); ++it ) { const MbHalfedgeEdge & ed = halfedge.Edge( it.Edge() ); } 3. :blue:`EdgesAroundFacetBegEndPair` AllEdgesAroundFacet( *size_t* iFacet ) const; Range based iterator for traversing facet edges, starting from the facet edge in a counterclockwise direction. Example of use: .. code-block:: cpp for( const MbHalfedgeEdge & ed : halfedge.AllEdgesAroundFacet( iFacet ) ) { ... } .. figure:: ../../pictures/P.2.2.2.png :width: 15cm :align: center Fig. 2 4. :blue:`VerticesAroundFacetBegEndPair` AllVerticesAroundFacet( *size_t* iF ) const; It is the iterator for traversing all vertices around the facet, starting from the vertex belonging to the edge defining the facet in a counterclockwise order (see Fig. 3). Example of use: .. code-block:: cpp for( const MbHalfedgeVertex & v : halfedge.AllVerticesAroundFacet( iFacet ) ) { ... } .. figure:: ../../pictures/P.2.2.3.png :width: 15cm :align: center Fig. 3 5. :blue:`EdgesAroundVertexBegEndPair` AllEdgesAroundVertex( *size_t* iV ) const; It is the iterator for traversing all edges (incoming and outgoing) adjacent to a given vertex, starting with the edge that defines the vertex (see Fig. 4). The traversal order is counterclockwise, alternating incoming and outgoing edges. Example of use: .. code-block:: cpp for( const MbHalfedgeEdge & ed : halfedge.AllEdgesAroundVertex( iVx ) ) { ... } .. figure:: ../../pictures/P.2.2.4.png :width: 18cm :align: center Fig. 4 6. :blue:`VerticesAroundVertexBegEndPair` AllVerticesAroundVertex( *size_t* iV ) const; It is the iterator for traversing all vertices adjacent to a given vertex (see Fig. 5). The order of traversal is counterclockwise, the first vertex is adjacent along the edge that defines the vertex. Example of use: .. code-block:: cpp for( const MbHalfedgeVertex & v : halfedge.AllVerticesAroundVertex( iVx ) ) { ... } .. figure:: ../../pictures/P.2.2.5.png :width: 18cm :align: center Fig. 5 7. :blue:`FacetsAroundVertexBegEndPair` AllFacetsAroundVertex( *size_t* iV ) const; It is the iterator for traversing all facets including the specified vertex (see Fig. 6). The traversal order is counterclockwise, the first facet includes the edge defining the vertex. Example of use: .. code-block:: cpp for( const MbHalfedgeFacet & f : halfedge.AllFacetsAroundVertex( iVx ) ) { ... } .. figure:: ../../pictures/P.2.2.6.png :width: 18cm :align: center Fig. 6