Subversion Repositories gelsvn

Rev

Rev 178 | Blame | Compare with Previous | 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:
                
                /** Construct a face iterator from a face f.
                                This iterator moves around f starting from the (arbitrary) halfedge
                                indicated by f. */
                FaceCirculator(FaceIter f): 
                        last(f->last), 
                                 he(last),
                                 steps(0) {}

                /** Construct a face iterator from a halfedge h.
                                This iterator moves around f starting from h. */
                FaceCirculator(HalfEdgeIter h): 
                        last(h), 
                        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