Subversion Repositories gelsvn

Rev

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

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