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 __VERTEXCIRCULATOR_H__
1
#ifndef __VERTEXCIRCULATOR_H__
2
#define __VERTEXCIRCULATOR_H__
2
#define __VERTEXCIRCULATOR_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
 
8
 
9
namespace HMesh
9
namespace HMesh
10
{
10
{
11
	/** \brief Circulator for moving around a vertex.
11
	/** \brief Circulator for moving around a vertex.
12
 
12
 
13
	This circulator makes it easy to visit all faces edges and vertices 
13
	This circulator makes it easy to visit all faces edges and vertices 
14
	adjacent to a given vertex.
14
	adjacent to a given vertex.
15
	*/
15
	*/
16
 
16
 
17
	class VertexCirculator
17
	class VertexCirculator
18
	{
-
 
19
		HalfEdgeIter last;
-
 
20
		HalfEdgeIter he;
-
 
21
		int steps;
-
 
22
		bool failed_flag;
-
 
23
 
-
 
24
 
-
 
25
	public:
-
 
26
		
-
 
27
		VertexCirculator(VertexIter v): 
-
 
28
			last(v->he), 
-
 
29
				 he(last),
-
 
30
				 steps(0),
-
 
31
				 failed_flag(false)
-
 
32
		{
18
		{
33
			assert(v->he != NULL_HALFEDGE_ITER);
19
			HalfEdgeIter last;
-
 
20
			HalfEdgeIter he;
34
		}
21
			int steps;
-
 
22
			bool failed_flag;
35
 
23
 
36
		/// Get current halfedge
-
 
37
		HalfEdgeIter get_halfedge() const { return he;}
-
 
38
 
24
 
-
 
25
		public:
-
 
26
		
-
 
27
			/** Construct a vertex circulator from a vertex.
-
 
28
					This constructor creates a vertex circulator which starts at a random
-
 
29
					point in the one ring. */
-
 
30
			VertexCirculator(VertexIter v): 
-
 
31
				last(v->he), 
-
 
32
				he(last),
-
 
33
				steps(0),
-
 
34
				failed_flag(false)
-
 
35
				{
-
 
36
					assert(v->he != NULL_HALFEDGE_ITER);
-
 
37
				}
-
 
38
		
39
		/// Get current vertex, i.e. the vertex pointed to by current halfege
39
			/** Construct a vertex circulator from a halfedge.
-
 
40
					This constructor creates a vertex circulator which circles the 
-
 
41
					halfedge from which h emanates (i.e. h->opp->vert). 
-
 
42
					The circulator starts at the position indicated by h. */
-
 
43
			VertexCirculator(HalfEdgeIter h): 
-
 
44
				last(h), 
-
 
45
				he(last),
-
 
46
				steps(0),
-
 
47
				failed_flag(false)
-
 
48
				{
-
 
49
					assert(h != NULL_HALFEDGE_ITER);
-
 
50
				}
-
 
51
 
-
 
52
			/// Get current halfedge
40
		VertexIter get_vertex() const { return he->vert;}
53
			HalfEdgeIter get_halfedge() const { return he;}
41
 
54
 
-
 
55
			/// Get current vertex, i.e. the vertex pointed to by current halfege
-
 
56
			VertexIter get_vertex() const { return he->vert;}
42
 
57
 
43
		/// Get opposite halfedge, i.e. the one pointing towards us.
58
			/// Get opposite halfedge, i.e. the one pointing towards us.
44
		HalfEdgeIter get_opp_halfedge() const { return he->opp;}
59
			HalfEdgeIter get_opp_halfedge() const { return he->opp;}
45
 
60
 
46
		/// Get the face of the current halfedge.
61
			/// Get the face of the current halfedge.
47
		FaceIter get_face() const { return he->face;}
62
			FaceIter get_face() const { return he->face;}
48
	
63
	
49
		/** Move clockwise around vertex. */
64
			/** Move clockwise around vertex. */
50
		void operator++() 
65
			void operator++() 
51
		{
66
				{
52
			assert(he->opp != NULL_HALFEDGE_ITER);
67
					assert(he->opp != NULL_HALFEDGE_ITER);
53
			he=he->opp->next;
68
					he=he->opp->next;
54
			++steps;
69
					++steps;
55
		}
70
				}
56
 
71
 
57
		/** Move clockwise around vertex. */
72
			/** Move clockwise around vertex. */
58
		void operator++(int) 
73
			void operator++(int) 
59
		{
74
				{
60
			++(*this);
75
					++(*this);
61
		}
76
				}
62
 
77
 
63
		/// Has circulator come full circle?
78
			/// Has circulator come full circle?
64
		bool end() const {return (he==last && steps > 0);}
79
			bool end() const {return (he==last && steps > 0);}
65
 
80
 
66
		/// Number of steps = valency.
81
			/// Number of steps = valency.
67
		int no_steps() const {return steps;}
82
			int no_steps() const {return steps;}
68
	};
83
		};
69
 
84
 
70
 
85
 
71
 
86
 
72
}
87
}
73
#endif
88
#endif
74
 
89