Subversion Repositories gelsvn

Rev

Rev 178 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
448 jab 1
#ifndef __HMESH_VERTEXCIRCULATOR_H__
2
#define __HMESH_VERTEXCIRCULATOR_H__
39 bj 3
 
4
#include "Vertex.h"
5
#include "HalfEdge.h"
6
#include "Face.h"
7
 
8
 
9
namespace HMesh
10
{
89 jab 11
	/** \brief Circulator for moving around a vertex.
39 bj 12
 
89 jab 13
	This circulator makes it easy to visit all faces edges and vertices 
14
	adjacent to a given vertex.
15
	*/
16
 
39 bj 17
	class VertexCirculator
178 bj 18
		{
19
			HalfEdgeIter last;
20
			HalfEdgeIter he;
21
			int steps;
22
			bool failed_flag;
39 bj 23
 
24
 
178 bj 25
		public:
39 bj 26
 
178 bj 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
			/** 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
				}
39 bj 51
 
178 bj 52
			/// Get current halfedge
53
			HalfEdgeIter get_halfedge() const { return he;}
39 bj 54
 
178 bj 55
			/// Get current vertex, i.e. the vertex pointed to by current halfege
56
			VertexIter get_vertex() const { return he->vert;}
39 bj 57
 
178 bj 58
			/// Get opposite halfedge, i.e. the one pointing towards us.
59
			HalfEdgeIter get_opp_halfedge() const { return he->opp;}
39 bj 60
 
178 bj 61
			/// Get the face of the current halfedge.
62
			FaceIter get_face() const { return he->face;}
39 bj 63
 
178 bj 64
			/** Move clockwise around vertex. */
65
			void operator++() 
66
				{
67
					assert(he->opp != NULL_HALFEDGE_ITER);
68
					he=he->opp->next;
69
					++steps;
70
				}
39 bj 71
 
178 bj 72
			/** Move clockwise around vertex. */
73
			void operator++(int) 
74
				{
75
					++(*this);
76
				}
39 bj 77
 
178 bj 78
			/// Has circulator come full circle?
79
			bool end() const {return (he==last && steps > 0);}
39 bj 80
 
178 bj 81
			/// Number of steps = valency.
82
			int no_steps() const {return steps;}
83
		};
39 bj 84
 
85
 
86
 
87
}
88
#endif