Fade2D Documentation pages v2.16.7
Delaunay Features
GEOM_FADE2D::TriangleAroundVertexIterator Class Reference

Iterator for all triangles around a given vertex. More...

#include <TriangleAroundVertexIterator.h>

Public Member Functions

 TriangleAroundVertexIterator (const Point2 *pPnt_)
 Constructor. More...
 
 TriangleAroundVertexIterator (const TriangleAroundVertexIterator &it)
 Copy constructor. More...
 
 TriangleAroundVertexIterator (Point2 *pPnt_, Triangle2 *pTr_)
 Constructor. More...
 
bool operator!= (const TriangleAroundVertexIterator &rhs)
 Compare the current iterator with another iterator. More...
 
Triangle2operator* ()
 Returns the current triangle (or NULL) More...
 
TriangleAroundVertexIteratoroperator++ ()
 Move the iterator to the next triangle (counterclockwise order) More...
 
TriangleAroundVertexIteratoroperator-- ()
 Move the iterator to the previous triangle (clockwise order) More...
 
TriangleAroundVertexIteratoroperator= (const TriangleAroundVertexIterator &other)
 Assignment operator. More...
 
bool operator== (const TriangleAroundVertexIterator &rhs)
 Compare the current iterator with another iterator. More...
 
Triangle2previewNextTriangle ()
 Preview the next triangle (CCW direction). More...
 
Triangle2previewPrevTriangle ()
 Preview the previous triangle (CW direction). More...
 

Protected Attributes

const Point2pPnt
 
Triangle2pSavedTr
 
Triangle2pTr
 

Detailed Description

The TriangleAroundVertexIterator iterates over all triangles incident to a given vertex (Point2 pointer) of a Fade_2D instance. The iteration can be performed in counterclockwise order using operator++() or in clockwise order using operator--().

Left: The iterator visits the triangles in CCW or CW order. Right: When the iterator at a border vertex points to NULL, another increment/decrement moves it to the next triangle.

A usage example is:

Point2* pVtx=...; // A vertex in the triangulation
TriangleAroundVertexIterator tavi(pVtx); // Iterator to traverse the incident triangles
TriangleAroundVertexIterator taviStop(tavi); // Make a copy to remember the stopping triangle
do
{
Triangle2* pT(*tavi);
if(pT==NULL)
{
// The iterator points to NULL because pVtx is a border vertex. A subsequent
// increment will move the iterator to the next triangle.
std::cout<<"pT=NULL"<<std::endl;
continue;
}
std::cout<<"pT="<<pT<<std::endl;
} while(++tavi!=taviStop);
TriangleAroundVertexIterator(const Point2 *pPnt_)
Constructor.
Definition: TriangleAroundVertexIterator.h:92
See also
Fade_2D::getIncidentTriangles() is a simple method to retrieve all incident triangles.

Constructor & Destructor Documentation

◆ TriangleAroundVertexIterator() [1/3]

GEOM_FADE2D::TriangleAroundVertexIterator::TriangleAroundVertexIterator ( const Point2 pPnt_)
inlineexplicit

Constructor

Parameters
pPnt_The vertex whose incident triangles are traversed by the iterator.

The iterator is initialized to point to an arbitrary triangle (not NULL).

◆ TriangleAroundVertexIterator() [2/3]

GEOM_FADE2D::TriangleAroundVertexIterator::TriangleAroundVertexIterator ( Point2 pPnt_,
Triangle2 pTr_ 
)
inline
Parameters
pPnt_The vertex whose incident triangles are traversed by the iterator.
pTr_The triangle to which the iterator initially points.

◆ TriangleAroundVertexIterator() [3/3]

GEOM_FADE2D::TriangleAroundVertexIterator::TriangleAroundVertexIterator ( const TriangleAroundVertexIterator it)
inline
Parameters
itThe iterator to be copied.

This constructor creates a copy of the iterator it.

Member Function Documentation

◆ operator!=()

bool GEOM_FADE2D::TriangleAroundVertexIterator::operator!= ( const TriangleAroundVertexIterator rhs)
inline

Compares the center and the current triangle of the iterator and the given iterator (rhs).

Returns
true if the iterators point to different triangles or vertices, false otherwise.

◆ operator*()

Triangle2* GEOM_FADE2D::TriangleAroundVertexIterator::operator* ( )
inline

Dereferencing the iterator returns a pointer to the triangle currently pointed to by the iterator.

Warning
This method might return NULL if the iterator is at the border of a triangulation.

◆ operator++()

TriangleAroundVertexIterator& GEOM_FADE2D::TriangleAroundVertexIterator::operator++ ( )
inline

Advances the iterator to the next triangle in counterclockwise (CCW) order.

Warning
If the iterator is at the border of a triangulation, operator++() can move the iterator beyond the triangulation, causing it to point to NULL. A subsequent call to operator++() will move the iterator to the next triangle in counterclockwise order.

◆ operator--()

TriangleAroundVertexIterator& GEOM_FADE2D::TriangleAroundVertexIterator::operator-- ( )
inline

Advances the iterator to the previous triangle in clockwise (CW) order.

Warning
If the iterator is at the border of a triangulation, operator--() can move the iterator beyond the triangulation, causing it to point to NULL. A subsequent call to operator--() will move the iterator to the next triangle in clockwise order.

◆ operator=()

TriangleAroundVertexIterator& GEOM_FADE2D::TriangleAroundVertexIterator::operator= ( const TriangleAroundVertexIterator other)
inline
Parameters
otherThe iterator to be assigned.

This operator assigns the state of the iterator other to the current iterator.

◆ operator==()

bool GEOM_FADE2D::TriangleAroundVertexIterator::operator== ( const TriangleAroundVertexIterator rhs)
inline

Compares the center and the current triangle of the iterator and the given iterator (rhs).

Returns
true if the iterators point to the same vertex and triangle, false otherwise.

◆ previewNextTriangle()

Triangle2* GEOM_FADE2D::TriangleAroundVertexIterator::previewNextTriangle ( )
inline

This method returns the triangle the iterator would point to if it were incremented.

Returns
A pointer to the next triangle (in counterclockwise direction), without modifying the current position.
Warning
This method might return NULL if the iterator is at the border of a triangulation.

◆ previewPrevTriangle()

Triangle2* GEOM_FADE2D::TriangleAroundVertexIterator::previewPrevTriangle ( )
inline

This method returns the triangle the iterator would point to if it were decremented.

Returns
A pointer to the previous triangle (in clockwise direction), without modifying the current position.
Warning
This method might return NULL if the iterator is at the border of a triangulation.

The documentation for this class was generated from the following file: