Rev 67 | Blame | Compare with Previous | 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:
VertexCirculator(VertexIter v):
last(v->he),
he(last),
steps(0),
failed_flag(false)
{
assert(v->he != 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