Subversion Repositories gelsvn

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
39 bj 1
#ifndef __VERTEXCIRCULATOR_H__
2
#define __VERTEXCIRCULATOR_H__
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
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
		{
33
			assert(v->he != NULL_HALFEDGE_ITER);
34
		}
35
 
36
		/// Get current halfedge
37
		HalfEdgeIter get_halfedge() const { return he;}
38
 
39
		/// Get current vertex, i.e. the vertex pointed to by current halfege
40
		VertexIter get_vertex() const { return he->vert;}
41
 
42
 
43
		/// Get opposite halfedge, i.e. the one pointing towards us.
44
		HalfEdgeIter get_opp_halfedge() const { return he->opp;}
45
 
46
		/// Get the face of the current halfedge.
47
		FaceIter get_face() const { return he->face;}
48
 
49
		/** Move clockwise around vertex. */
50
		void operator++() 
51
		{
52
			assert(he->opp != NULL_HALFEDGE_ITER);
53
			he=he->opp->next;
54
			++steps;
55
		}
56
 
57
		/** Move clockwise around vertex. */
58
		void operator++(int) 
59
		{
60
			++(*this);
61
		}
62
 
63
		/// Has circulator come full circle?
64
		bool end() const {return (he==last && steps > 0);}
65
 
66
		/// Number of steps = valency.
67
		int no_steps() const {return steps;}
68
	};
69
 
70
 
71
 
72
}
73
#endif