Rev 89 | Blame | Last modification | View Log | RSS feed
#ifndef __VERTEXCIRCULATOR_H__
#define __VERTEXCIRCULATOR_H__
#include "Vertex.h"
#include "HalfEdge.h"
#include "Face.h"
namespace HMesh
{
/** \brief Circulator for moving around a vertex.
This circulator makes it easy to visit all faces edges and vertices
adjacent to a given vertex.
*/
class VertexCirculator
{
HalfEdgeIter last;
HalfEdgeIter he;
int steps;
bool failed_flag;
public:
/** Construct a vertex circulator from a vertex.
This constructor creates a vertex circulator which starts at a random
point in the one ring. */
VertexCirculator(VertexIter v):
last(v->he),
he(last),
steps(0),
failed_flag(false)
{
assert(v->he != NULL_HALFEDGE_ITER);
}
/** Construct a vertex circulator from a halfedge.
This constructor creates a vertex circulator which circles the
halfedge from which h emanates (i.e. h->opp->vert).
The circulator starts at the position indicated by h. */
VertexCirculator(HalfEdgeIter h):
last(h),
he(last),
steps(0),
failed_flag(false)
{
assert(h != NULL_HALFEDGE_ITER);
}
/// Get current halfedge
HalfEdgeIter get_halfedge() const { return he;}
/// Get current vertex, i.e. the vertex pointed to by current halfege
VertexIter get_vertex() const { return he->vert;}
/// Get opposite halfedge, i.e. the one pointing towards us.
HalfEdgeIter get_opp_halfedge() const { return he->opp;}
/// Get the face of the current halfedge.
FaceIter get_face() const { return he->face;}
/** Move clockwise around vertex. */
void operator++()
{
assert(he->opp != NULL_HALFEDGE_ITER);
he=he->opp->next;
++steps;
}
/** Move clockwise around vertex. */
void operator++(int)
{
++(*this);
}
/// Has circulator come full circle?
bool end() const {return (he==last && steps > 0);}
/// Number of steps = valency.
int no_steps() const {return steps;}
};
}
#endif