Subversion Repositories gelsvn

Rev

Details | 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
{
10
	/** Move around a face. A circulator is similar to an iterator. 
11
			The circulator maintains state telling us where we are on a face.
12
			We can get the current vertex or halfedge. NOTE: convenience 
13
			functions for getting the opposite halfedge and adjacent face
14
			would be nice. */
15
	class FaceCirculator
16
	{
17
		HalfEdgeIter last;
18
		HalfEdgeIter he;
19
		int steps;
20
 
21
		public:
22
 
23
		FaceCirculator(FaceIter f): 
24
			last(f->last), 
25
				 he(last),
26
				 steps(0) {}
27
 
28
		/// Return current vertex pointed to by circulator.
29
		VertexIter get_vertex() const { return he->vert;}
30
 
31
		/// Return current halfedge pointed to by circulator
32
		HalfEdgeIter get_halfedge() const { return he->next;}
33
 
34
		/** Return current face pointed to by circulator. I.e.
35
				The adjacent face across the current halfedge. */
36
		FaceIter get_face() const {return he->next->opp->face;}
37
 
38
		/// Increment circulator.
39
		void operator++() {he=he->next;++steps;}
40
 
41
		/// Increment circulator.
42
		void operator++(int) {he=he->next;++steps;}
43
 
44
		/// Has circulator come full circle?
45
		bool end() const {return he==last && steps > 0;}
46
 
47
		/// Return number of steps.
48
		int no_steps() const {return steps;}
49
	};
50
 
51
 
52
 
53
}
54
#endif