Rev 39 | Go to most recent revision | Blame | Last modification | View Log | RSS feed
#ifndef __FACECIRCULATOR_H__
#define __FACECIRCULATOR_H__
#include "Vertex.h"
#include "HalfEdge.h"
#include "Face.h"
namespace HMesh
{
/** \brief Circulator to move around a face.
A circulator is similar to an iterator.
The circulator maintains state telling us where we are on a face.
We can get the current vertex or halfedge. NOTE: convenience
functions for getting the opposite halfedge and adjacent face
would be nice. */
class FaceCirculator
{
HalfEdgeIter last;
HalfEdgeIter he;
int steps;
public:
FaceCirculator(FaceIter f):
last(f->last),
he(last),
steps(0) {}
/// Return current vertex pointed to by circulator.
VertexIter get_vertex() const { return he->vert;}
/// Return current halfedge pointed to by circulator
HalfEdgeIter get_halfedge() const { return he->next;}
/** Return current face pointed to by circulator. I.e.
The adjacent face across the current halfedge. */
FaceIter get_face() const {return he->next->opp->face;}
/// Increment circulator.
void operator++() {he=he->next;++steps;}
/// Increment circulator.
void operator++(int) {he=he->next;++steps;}
/// Has circulator come full circle?
bool end() const {return he==last && steps > 0;}
/// Return number of steps.
int no_steps() const {return steps;}
};
}
#endif