Subversion Repositories gelsvn

Rev

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

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