Subversion Repositories gelsvn

Rev

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

Rev 39 Rev 89
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
	/** Circulator for moving around a vertex.  */
11
	/** \brief Circulator for moving around a vertex.
-
 
12
 
-
 
13
	This circulator makes it easy to visit all faces edges and vertices 
-
 
14
	adjacent to a given vertex.
-
 
15
	*/
12
 
16
 
13
	class VertexCirculator
17
	class VertexCirculator
14
	{
18
	{
15
		HalfEdgeIter last;
19
		HalfEdgeIter last;
16
		HalfEdgeIter he;
20
		HalfEdgeIter he;
17
		int steps;
21
		int steps;
18
		bool failed_flag;
22
		bool failed_flag;
19
 
23
 
20
 
24
 
21
	public:
25
	public:
22
		
26
		
23
		VertexCirculator(VertexIter v): 
27
		VertexCirculator(VertexIter v): 
24
			last(v->he), 
28
			last(v->he), 
25
				 he(last),
29
				 he(last),
26
				 steps(0),
30
				 steps(0),
27
				 failed_flag(false)
31
				 failed_flag(false)
28
		{
32
		{
29
			assert(v->he != NULL_HALFEDGE_ITER);
33
			assert(v->he != NULL_HALFEDGE_ITER);
30
		}
34
		}
31
 
35
 
32
		/// Get current halfedge
36
		/// Get current halfedge
33
		HalfEdgeIter get_halfedge() const { return he;}
37
		HalfEdgeIter get_halfedge() const { return he;}
34
 
38
 
35
		/// Get current vertex, i.e. the vertex pointed to by current halfege
39
		/// Get current vertex, i.e. the vertex pointed to by current halfege
36
		VertexIter get_vertex() const { return he->vert;}
40
		VertexIter get_vertex() const { return he->vert;}
37
 
41
 
38
 
42
 
39
		/// Get opposite halfedge, i.e. the one pointing towards us.
43
		/// Get opposite halfedge, i.e. the one pointing towards us.
40
		HalfEdgeIter get_opp_halfedge() const { return he->opp;}
44
		HalfEdgeIter get_opp_halfedge() const { return he->opp;}
41
 
45
 
42
		/// Get the face of the current halfedge.
46
		/// Get the face of the current halfedge.
43
		FaceIter get_face() const { return he->face;}
47
		FaceIter get_face() const { return he->face;}
44
	
48
	
45
		/** Move clockwise around vertex. */
49
		/** Move clockwise around vertex. */
46
		void operator++() 
50
		void operator++() 
47
		{
51
		{
48
			assert(he->opp != NULL_HALFEDGE_ITER);
52
			assert(he->opp != NULL_HALFEDGE_ITER);
49
			he=he->opp->next;
53
			he=he->opp->next;
50
			++steps;
54
			++steps;
51
		}
55
		}
52
 
56
 
53
		/** Move clockwise around vertex. */
57
		/** Move clockwise around vertex. */
54
		void operator++(int) 
58
		void operator++(int) 
55
		{
59
		{
56
			++(*this);
60
			++(*this);
57
		}
61
		}
58
 
62
 
59
		/// Has circulator come full circle?
63
		/// Has circulator come full circle?
60
		bool end() const {return (he==last && steps > 0);}
64
		bool end() const {return (he==last && steps > 0);}
61
 
65
 
62
		/// Number of steps = valency.
66
		/// Number of steps = valency.
63
		int no_steps() const {return steps;}
67
		int no_steps() const {return steps;}
64
	};
68
	};
65
 
69
 
66
 
70
 
67
 
71
 
68
}
72
}
69
#endif
73
#endif
70
 
74