Subversion Repositories gelsvn

Rev

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

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