Subversion Repositories gelsvn

Rev

Rev 39 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
39 bj 1
#ifndef __FACECIRCULATOR_H__
2
#define __FACECIRCULATOR_H__
3
 
4
#include "Vertex.h"
5
#include "HalfEdge.h"
6
#include "Face.h"
7
 
8
namespace HMesh
9
{
89 jab 10
	/** \brief Circulator to move around a face. 
11
 
12
	A circulator is similar to an iterator. 
13
	The circulator maintains state telling us where we are on a face.
14
	We can get the current vertex or halfedge. NOTE: convenience 
15
	functions for getting the opposite halfedge and adjacent face
16
	would be nice. */
39 bj 17
	class FaceCirculator
18
	{
19
		HalfEdgeIter last;
20
		HalfEdgeIter he;
21
		int steps;
22
 
23
		public:
24
 
25
		FaceCirculator(FaceIter f): 
26
			last(f->last), 
27
				 he(last),
28
				 steps(0) {}
29
 
30
		/// Return current vertex pointed to by circulator.
31
		VertexIter get_vertex() const { return he->vert;}
32
 
33
		/// Return current halfedge pointed to by circulator
34
		HalfEdgeIter get_halfedge() const { return he->next;}
35
 
36
		/** Return current face pointed to by circulator. I.e.
37
				The adjacent face across the current halfedge. */
38
		FaceIter get_face() const {return he->next->opp->face;}
39
 
40
		/// Increment circulator.
41
		void operator++() {he=he->next;++steps;}
42
 
43
		/// Increment circulator.
44
		void operator++(int) {he=he->next;++steps;}
45
 
46
		/// Has circulator come full circle?
47
		bool end() const {return he==last && steps > 0;}
48
 
49
		/// Return number of steps.
50
		int no_steps() const {return steps;}
51
	};
52
 
53
 
54
 
55
}
56
#endif