Subversion Repositories gelsvn

Rev

Rev 178 | 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:
178 bj 24
 
25
		/** Construct a face iterator from a face f.
26
				This iterator moves around f starting from the (arbitrary) halfedge
27
				indicated by f. */
39 bj 28
		FaceCirculator(FaceIter f): 
29
			last(f->last), 
30
				 he(last),
31
				 steps(0) {}
32
 
178 bj 33
		/** Construct a face iterator from a halfedge h.
34
				This iterator moves around f starting from h. */
35
		FaceCirculator(HalfEdgeIter h): 
36
			last(h), 
37
			he(last),
38
			steps(0) {}
39
 
39 bj 40
		/// Return current vertex pointed to by circulator.
41
		VertexIter get_vertex() const { return he->vert;}
42
 
331 jab 43
		/** Return current halfedge pointed to by circulator.
44
				This is the halfedge emanating from the current vertex NOT the 
45
				one pointing to the current vertex. */
39 bj 46
		HalfEdgeIter get_halfedge() const { return he->next;}
47
 
48
		/** Return current face pointed to by circulator. I.e.
49
				The adjacent face across the current halfedge. */
50
		FaceIter get_face() const {return he->next->opp->face;}
51
 
52
		/// Increment circulator.
53
		void operator++() {he=he->next;++steps;}
54
 
55
		/// Increment circulator.
56
		void operator++(int) {he=he->next;++steps;}
57
 
58
		/// Has circulator come full circle?
59
		bool end() const {return he==last && steps > 0;}
60
 
61
		/// Return number of steps.
62
		int no_steps() const {return steps;}
63
	};
64
 
65
 
66
 
67
}
68
#endif