511 |
s042372 |
1 |
/*
|
|
|
2 |
* Written by Christian Thode Larsen 2009-2010
|
|
|
3 |
* Contact: thode2d@gmail.com
|
|
|
4 |
* Based on original work by J. Andreas Baerentzen
|
|
|
5 |
* Inspired by OpenMesh (www.openmesh.org)
|
|
|
6 |
*/
|
|
|
7 |
|
|
|
8 |
#ifndef __HMESH_ITERATORS_H__
|
|
|
9 |
#define __HMESH_ITERATORS_H__
|
|
|
10 |
|
|
|
11 |
#include "ConnectivityKernel.h"
|
|
|
12 |
|
|
|
13 |
namespace HMesh
|
|
|
14 |
{
|
|
|
15 |
class VertexIDIterator
|
|
|
16 |
{
|
|
|
17 |
public:
|
|
|
18 |
/// constructor (default: skipping enabled)
|
|
|
19 |
VertexIDIterator(const ConnectivityKernel& _ck, VertexID _id, bool _skip = true);
|
|
|
20 |
|
|
|
21 |
/// prefix increment
|
|
|
22 |
VertexIDIterator& operator ++();
|
|
|
23 |
/// postfix increment
|
|
|
24 |
VertexIDIterator& operator ++(int);
|
|
|
25 |
/// prefix decrement
|
|
|
26 |
VertexIDIterator& operator --();
|
|
|
27 |
/// postfix decrement
|
|
|
28 |
VertexIDIterator& operator --(int);
|
|
|
29 |
|
|
|
30 |
/// equal to
|
|
|
31 |
bool operator ==(const VertexIDIterator& other) const;
|
|
|
32 |
/// not equal to
|
|
|
33 |
bool operator !=(const VertexIDIterator& other) const;
|
|
|
34 |
|
|
|
35 |
/// indirection
|
|
|
36 |
VertexID operator *();
|
|
|
37 |
/// member by pointer
|
|
|
38 |
VertexID* operator ->();
|
|
|
39 |
/// cast
|
|
|
40 |
//operator VertexID() const;
|
|
|
41 |
|
|
|
42 |
private:
|
|
|
43 |
const ConnectivityKernel* ck;
|
|
|
44 |
VertexID id;
|
|
|
45 |
bool skip;
|
|
|
46 |
};
|
|
|
47 |
|
|
|
48 |
class FaceIDIterator
|
|
|
49 |
{
|
|
|
50 |
public:
|
|
|
51 |
/// constructor (default: skipping enabled)
|
|
|
52 |
FaceIDIterator(const ConnectivityKernel& _ck, FaceID _id, bool _skip = true);
|
|
|
53 |
|
|
|
54 |
/// prefix increment
|
|
|
55 |
FaceIDIterator& operator ++();
|
|
|
56 |
/// postfix increment
|
|
|
57 |
FaceIDIterator& operator ++(int);
|
|
|
58 |
/// prefix decrement
|
|
|
59 |
FaceIDIterator& operator --();
|
|
|
60 |
/// postfix decrement
|
|
|
61 |
FaceIDIterator& operator --(int);
|
|
|
62 |
|
|
|
63 |
/// equal to
|
|
|
64 |
bool operator ==(const FaceIDIterator& other) const;
|
|
|
65 |
/// not equal to
|
|
|
66 |
bool operator !=(const FaceIDIterator& other) const;
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
/// indirection
|
|
|
70 |
FaceID operator *();
|
|
|
71 |
/// member by pointer
|
|
|
72 |
FaceID* operator ->();
|
|
|
73 |
/// cast
|
|
|
74 |
//operator FaceID() const;
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
private:
|
|
|
78 |
const ConnectivityKernel* ck;
|
|
|
79 |
FaceID id;
|
|
|
80 |
bool skip;
|
|
|
81 |
};
|
|
|
82 |
|
|
|
83 |
class HalfEdgeIDIterator
|
|
|
84 |
{
|
|
|
85 |
public:
|
|
|
86 |
/// constructor (default: skipping enabled)
|
|
|
87 |
HalfEdgeIDIterator(const ConnectivityKernel& _ck, HalfEdgeID _id, bool _skip = true);
|
|
|
88 |
|
|
|
89 |
/// prefix increment
|
|
|
90 |
HalfEdgeIDIterator& operator ++();
|
|
|
91 |
/// postfix increment
|
|
|
92 |
HalfEdgeIDIterator& operator ++(int);
|
|
|
93 |
/// prefix decrement
|
|
|
94 |
HalfEdgeIDIterator& operator --();
|
|
|
95 |
/// postfix decrement
|
|
|
96 |
HalfEdgeIDIterator& operator --(int);
|
|
|
97 |
|
|
|
98 |
/// equal to
|
|
|
99 |
bool operator ==(const HalfEdgeIDIterator& other) const;
|
|
|
100 |
/// not equal to
|
|
|
101 |
bool operator !=(const HalfEdgeIDIterator& other) const;
|
|
|
102 |
|
|
|
103 |
/// indirection
|
|
|
104 |
HalfEdgeID operator *();
|
|
|
105 |
/// member by pointer
|
|
|
106 |
HalfEdgeID* operator ->();
|
|
|
107 |
/// cast
|
|
|
108 |
//operator HalfEdgeID() const;
|
|
|
109 |
|
|
|
110 |
private:
|
|
|
111 |
const ConnectivityKernel* ck;
|
|
|
112 |
HalfEdgeID id;
|
|
|
113 |
bool skip;
|
|
|
114 |
};
|
|
|
115 |
|
|
|
116 |
inline VertexIDIterator::VertexIDIterator(const ConnectivityKernel& _ck, VertexID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
inline VertexIDIterator& VertexIDIterator::operator ++()
|
|
|
120 |
{
|
|
|
121 |
id = ck->vertices_next(id, skip);
|
|
|
122 |
return *this;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
inline VertexIDIterator& VertexIDIterator::operator ++(int)
|
|
|
126 |
{ return ++(*this); }
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
inline VertexIDIterator& VertexIDIterator::operator --()
|
|
|
130 |
{
|
|
|
131 |
id = ck->vertices_prev(id, skip);
|
|
|
132 |
return *this;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
inline VertexIDIterator& VertexIDIterator::operator --(int)
|
|
|
136 |
{ return --(*this); }
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
inline bool VertexIDIterator::operator ==(const VertexIDIterator& other) const
|
|
|
140 |
{ return ck == other.ck && id == other.id; }
|
|
|
141 |
|
|
|
142 |
inline bool VertexIDIterator::operator !=(const VertexIDIterator& other) const
|
|
|
143 |
{ return ck == other.ck && id == other.id; }
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
inline VertexID VertexIDIterator::operator *()
|
|
|
147 |
{ return id; }
|
|
|
148 |
|
|
|
149 |
inline VertexID* VertexIDIterator::operator ->()
|
|
|
150 |
{ return &id; }
|
|
|
151 |
|
|
|
152 |
//inline VertexIDIterator::operator VertexID() const
|
|
|
153 |
//{ return id; }
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
inline FaceIDIterator::FaceIDIterator(const ConnectivityKernel& _ck, FaceID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
inline FaceIDIterator& FaceIDIterator::operator ++()
|
|
|
161 |
{
|
|
|
162 |
id = ck->faces_next(id, skip);
|
|
|
163 |
return *this;
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
inline FaceIDIterator& FaceIDIterator::operator ++(int)
|
|
|
167 |
{ return ++(*this); }
|
|
|
168 |
|
|
|
169 |
inline FaceIDIterator& FaceIDIterator::operator --()
|
|
|
170 |
{
|
|
|
171 |
id = ck->faces_prev(id, skip);
|
|
|
172 |
return *this;
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
inline FaceIDIterator& FaceIDIterator::operator --(int)
|
|
|
176 |
{ return --(*this); }
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
inline bool FaceIDIterator::operator ==(const FaceIDIterator& other) const
|
|
|
180 |
{ return ck == other.ck && id == other.id; }
|
|
|
181 |
|
|
|
182 |
inline bool FaceIDIterator::operator !=(const FaceIDIterator& other) const
|
|
|
183 |
{ return ck == other.ck && id == other.id; }
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
inline FaceID FaceIDIterator::operator *()
|
|
|
187 |
{ return id; }
|
|
|
188 |
|
|
|
189 |
inline FaceID* FaceIDIterator::operator ->()
|
|
|
190 |
{return &id; }
|
|
|
191 |
|
|
|
192 |
//inline FaceIDIterator::operator FaceID() const
|
|
|
193 |
//{ return id; }
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
inline HalfEdgeIDIterator::HalfEdgeIDIterator(const ConnectivityKernel& _ck, HalfEdgeID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator ++()
|
|
|
200 |
{
|
|
|
201 |
id = ck->halfedges_next(id, skip);
|
|
|
202 |
return *this;
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator ++(int)
|
|
|
206 |
{ return ++(*this); }
|
|
|
207 |
|
|
|
208 |
inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator --()
|
|
|
209 |
{
|
|
|
210 |
id = ck->halfedges_prev(id, skip);
|
|
|
211 |
return *this;
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator --(int)
|
|
|
215 |
{ return --(*this); }
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
inline bool HalfEdgeIDIterator::operator ==(const HalfEdgeIDIterator& other) const
|
|
|
219 |
{ return ck == other.ck && id == other.id; }
|
|
|
220 |
|
|
|
221 |
inline bool HalfEdgeIDIterator::operator !=(const HalfEdgeIDIterator& other) const
|
|
|
222 |
{ return ck == other.ck && id == other.id; }
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
inline HalfEdgeID HalfEdgeIDIterator::operator *()
|
|
|
226 |
{ return id; }
|
|
|
227 |
|
|
|
228 |
inline HalfEdgeID* HalfEdgeIDIterator::operator ->()
|
|
|
229 |
{ return &id; }
|
|
|
230 |
|
|
|
231 |
//inline HalfEdgeIDIterator::operator HalfEdgeID() const
|
|
|
232 |
//{ return id; }
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
#endif
|