Subversion Repositories gelsvn

Rev

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