OpenMesh: OpenMesh/Core/Mesh/gen/circulators_template.hh Source File

| OpenMesh

circulators_template.hh
1 //== CLASS DEFINITION =========================================================
2
3
8 template <class Mesh>
9 class CirculatorT
10 {
11 public:
12
13
14 //--- Typedefs ---
15
16 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
17
18 typedef TargetType value_type;
19 typedef TargetHandle value_handle;
20
21 #if IsConst
22 typedef const Mesh& mesh_ref;
23 typedef const Mesh* mesh_ptr;
24 typedef const TargetType& reference;
25 typedef const TargetType* pointer;
26 #else
27 typedef Mesh& mesh_ref;
28 typedef Mesh* mesh_ptr;
29 typedef TargetType& reference;
30 typedef TargetType* pointer;
31 #endif
32
33
34
36 CirculatorT() : mesh_(0), active_(false) {}
37
38
40 CirculatorT(mesh_ref _mesh, SourceHandle _start) :
41 mesh_(&_mesh),
42 start_(_mesh.halfedge_handle(_start)),
43 heh_(start_),
44 active_(false)
45 { post_init; }
46
47
49 CirculatorT(mesh_ref _mesh, HalfedgeHandle _heh) :
50 mesh_(&_mesh),
51 start_(_heh),
52 heh_(_heh),
53 active_(false)
54 { post_init; }
55
56
58 CirculatorT(const CirculatorT& _rhs) :
59 mesh_(_rhs.mesh_),
60 start_(_rhs.start_),
61 heh_(_rhs.heh_),
62 active_(_rhs.active_)
63 { post_init; }
64
65
67 CirculatorT& operator=(const CirculatorT<Mesh>& _rhs)
68 {
69 mesh_ = _rhs.mesh_;
70 start_ = _rhs.start_;
71 heh_ = _rhs.heh_;
72 active_ = _rhs.active_;
73 return *this;
74 }
75
76
77 #if IsConst
79 CirculatorT(const NonConstCircT<Mesh>& _rhs) :
80 mesh_(_rhs.mesh_),
81 start_(_rhs.start_),
82 heh_(_rhs.heh_),
83 active_(_rhs.active_)
84 { post_init; }
85
86
88 CirculatorT& operator=(const NonConstCircT<Mesh>& _rhs)
89 {
90 mesh_ = _rhs.mesh_;
91 start_ = _rhs.start_;
92 heh_ = _rhs.heh_;
93 active_ = _rhs.active_;
94 return *this;
95 }
96 #else
97 friend class ConstCircT<Mesh>;
98 #endif
99
100
102 bool operator==(const CirculatorT& _rhs) const {
103 return ((mesh_ == _rhs.mesh_) &&
104 (start_ == _rhs.start_) &&
105 (heh_ == _rhs.heh_) &&
106 (active_ == _rhs.active_));
107 }
108
109
111 bool operator!=(const CirculatorT& _rhs) const {
112 return !operator==(_rhs);
113 }
114
115
117 CirculatorT& operator++() {
118 assert(mesh_);
119 active_ = true;
120 increment;
121 return *this;
122 }
123
124
126 CirculatorT& operator--() {
127 assert(mesh_);
128 active_ = true;
129 decrement;
130 return *this;
131 }
132
133
138 HalfedgeHandle current_halfedge_handle() const {
139 return heh_;
140 }
141
142
144 TargetHandle handle() const {
145 assert(mesh_);
146 return get_handle;
147 }
148
149
151 operator TargetHandle() const {
152 assert(mesh_);
153 return get_handle;
154 }
155
156
158 reference operator*() const {
159 assert(mesh_);
160 return mesh_->deref(handle());
161 }
162
163
165 pointer operator->() const {
166 assert(mesh_);
167 return &mesh_->deref(handle());
168 }
169
170
177 operator bool() const {
178 return heh_.is_valid() && ((start_ != heh_) || (!active_));
179 }
180
181
182 private:
183
184 mesh_ptr mesh_;
185 HalfedgeHandle start_, heh_;
186 bool active_;
187 };
188
189
190
CirculatorT
Circulator.
Definition: circulators_template.hh:10
CirculatorT::operator--
CirculatorT & operator--()
Pre-Decrement (next ccw target)
Definition: circulators_template.hh:126
CirculatorT::operator++
CirculatorT & operator++()
Pre-Increment (next cw target)
Definition: circulators_template.hh:117
CirculatorT::CirculatorT
CirculatorT(mesh_ref _mesh, HalfedgeHandle _heh)
Construct with mesh and start halfedge.
Definition: circulators_template.hh:49
CirculatorT::operator==
bool operator==(const CirculatorT &_rhs) const
Equal ?
Definition: circulators_template.hh:102
CirculatorT::operator=
CirculatorT & operator=(const CirculatorT< Mesh > &_rhs)
Assignment operator.
Definition: circulators_template.hh:67
CirculatorT::operator*
reference operator*() const
Return a reference to the current target.
Definition: circulators_template.hh:158
CirculatorT::CirculatorT
CirculatorT(const CirculatorT &_rhs)
Copy constructor.
Definition: circulators_template.hh:58
CirculatorT::CirculatorT
CirculatorT()
Default constructor.
Definition: circulators_template.hh:36
CirculatorT::current_halfedge_handle
HalfedgeHandle current_halfedge_handle() const
Get the current halfedge.
Definition: circulators_template.hh:138
CirculatorT::handle
TargetHandle handle() const
Return the handle of the current target.
Definition: circulators_template.hh:144
CirculatorT::operator->
pointer operator->() const
Return a pointer to the current target.
Definition: circulators_template.hh:165
CirculatorT::CirculatorT
CirculatorT(mesh_ref _mesh, SourceHandle _start)
Construct with mesh and a SourceHandle.
Definition: circulators_template.hh:40
CirculatorT::operator!=
bool operator!=(const CirculatorT &_rhs) const
Not equal ?
Definition: circulators_template.hh:111
OpenMesh::PolyMesh_ArrayKernelT
Polygonal mesh based on the ArrayKernel.
Definition: PolyMesh_ArrayKernelT.hh:96
OpenMesh::PolyMeshT::HalfedgeHandle
Kernel::HalfedgeHandle HalfedgeHandle
Scalar type.
Definition: PolyMeshT.hh:137