Subversion Repositories gelsvn

Rev

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

Rev 331 Rev 448
1
#ifndef __FACECIRCULATOR_H__
1
#ifndef __HMESH_FACECIRCULATOR_H__
2
#define __FACECIRCULATOR_H__
2
#define __HMESH_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 
44
				This is the halfedge emanating from the current vertex NOT the 
45
				one pointing to the current vertex. */
45
				one pointing to the current vertex. */
46
		HalfEdgeIter get_halfedge() const { return he->next;}
46
		HalfEdgeIter get_halfedge() const { return he->next;}
47
 
47
 
48
		/** Return current face pointed to by circulator. I.e.
48
		/** Return current face pointed to by circulator. I.e.
49
				The adjacent face across the current halfedge. */
49
				The adjacent face across the current halfedge. */
50
		FaceIter get_face() const {return he->next->opp->face;}
50
		FaceIter get_face() const {return he->next->opp->face;}
51
	
51
	
52
		/// Increment circulator.
52
		/// Increment circulator.
53
		void operator++() {he=he->next;++steps;}
53
		void operator++() {he=he->next;++steps;}
54
 
54
 
55
		/// Increment circulator.
55
		/// Increment circulator.
56
		void operator++(int) {he=he->next;++steps;}
56
		void operator++(int) {he=he->next;++steps;}
57
 
57
 
58
		/// Has circulator come full circle?
58
		/// Has circulator come full circle?
59
		bool end() const {return he==last && steps > 0;}
59
		bool end() const {return he==last && steps > 0;}
60
	
60
	
61
		/// Return number of steps.
61
		/// Return number of steps.
62
		int no_steps() const {return steps;}
62
		int no_steps() const {return steps;}
63
	};
63
	};
64
 
64
 
65
 
65
 
66
 
66
 
67
}
67
}
68
#endif
68
#endif
69
 
69