Subversion Repositories gelsvn

Rev

Rev 39 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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