Developer Documentation

unittests_trimesh_circulator_vertex_ohalfedge.cc
1 #include <gtest/gtest.h>
2 #include <Unittests/unittests_common.hh>
3
4 #include <iostream>
5
6 namespace {
7
8 class OpenMeshTrimeshCirculatorVertexOHalfEdge : public OpenMeshBase {
9
10 protected:
11
12 // This function is called before each test is run
13 virtual void SetUp() {
14 }
15
16 // This function is called after all tests are through
17 virtual void TearDown() {
18
19 // Do some final stuff with the member data here...
20 }
21
22
23 // Member already defined in OpenMeshBase
24 //Mesh mesh_;
25 };
26
27 /*
28 * ====================================================================
29 * Define tests below
30 * ====================================================================
31 */
32
33
34 /*
35 * Small VertexFaceOutgoingHalfedgeIterator Test without holes in it
36 */
37 TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOutgoingHalfedgeWithoutHolesIncrement) {
38
39 mesh_.clear();
40
41 // Add some vertices
42 Mesh::VertexHandle vhandle[5];
43
44 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
45 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
46 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
47 vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
48 vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
49
50 // Add two faces
51 std::vector<Mesh::VertexHandle> face_vhandles;
52
53 face_vhandles.push_back(vhandle[0]);
54 face_vhandles.push_back(vhandle[1]);
55 face_vhandles.push_back(vhandle[2]);
56 mesh_.add_face(face_vhandles);
57
58 face_vhandles.clear();
59
60 face_vhandles.push_back(vhandle[1]);
61 face_vhandles.push_back(vhandle[3]);
62 face_vhandles.push_back(vhandle[4]);
63 mesh_.add_face(face_vhandles);
64
65 face_vhandles.clear();
66
67 face_vhandles.push_back(vhandle[0]);
68 face_vhandles.push_back(vhandle[3]);
69 face_vhandles.push_back(vhandle[1]);
70 mesh_.add_face(face_vhandles);
71
72 face_vhandles.clear();
73
74 face_vhandles.push_back(vhandle[2]);
75 face_vhandles.push_back(vhandle[1]);
76 face_vhandles.push_back(vhandle[4]);
77 mesh_.add_face(face_vhandles);
78
79 /* Test setup:
80 0 ==== 2
81 |\ 0 /|
82 | \ / |
83 |2 1 3|
84 | / \ |
85 |/ 1 \|
86 3 ==== 4 */
87 // Starting halfedge is 1->4
88
89
90 // Iterate around vertex 1 at the middle (with holes in between)
91 Mesh::VertexOHalfedgeIter voh_it = mesh_.voh_begin(vhandle[1]);
92 Mesh::VertexOHalfedgeIter voh_end = mesh_.voh_end(vhandle[1]);
93
94 EXPECT_EQ(11, voh_it->idx() ) << "Index wrong in VertexOHalfedgeIter begin at initialization";
95 EXPECT_EQ(11, voh_end->idx() ) << "Index wrong in VertexOHalfedgeIter end at initialization";
96 EXPECT_EQ(3, mesh_.face_handle(*voh_it).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter begin at initialization";
97 EXPECT_TRUE(voh_it.is_valid()) << "Iterator invalid in VertexOHalfedgeIter at initialization";
98
99 ++voh_it ;
100
101 EXPECT_EQ(6, voh_it->idx() ) << "Index wrong in VertexOHalfedgeIter step 1";
102 EXPECT_EQ(1, mesh_.face_handle(*voh_it).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 1";
103 EXPECT_TRUE(voh_it.is_valid()) << "Iterator invalid in VertexOHalfedgeIter at step 1";
104
105 ++voh_it ;
106
107 EXPECT_EQ(1, voh_it->idx() ) << "Index wrong in VertexOHalfedgeIter step 2";
108 EXPECT_EQ(2, mesh_.face_handle(*voh_it).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 2";
109 EXPECT_TRUE(voh_it.is_valid()) << "Iterator invalid in VertexOHalfedgeIter at step 2";
110
111 ++voh_it ;
112
113 EXPECT_EQ(2, voh_it->idx() ) << "Index wrong in VertexOHalfedgeIter step 3";
114 EXPECT_EQ(0, mesh_.face_handle(*voh_it).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 3";
115 EXPECT_TRUE(voh_it.is_valid()) << "Iterator invalid in VertexOHalfedgeIter at step 3";
116
117 ++voh_it ;
118
119 EXPECT_EQ(11, voh_it->idx() ) << "Index wrong in VertexOHalfedgeIter step 4";
120 EXPECT_EQ(3, mesh_.face_handle(*voh_it).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 4";
121 EXPECT_FALSE(voh_it.is_valid()) << "Iterator still valid in VertexOHalfedgeIter at step 4";
122 EXPECT_TRUE( voh_it == voh_end ) << "Miss matched end iterator";
123
124 // Iterate around vertex 1 at the middle (with holes in between)
125 Mesh::ConstVertexOHalfedgeIter cvoh_it = mesh_.cvoh_begin(vhandle[1]);
126 Mesh::ConstVertexOHalfedgeIter cvoh_end = mesh_.cvoh_end(vhandle[1]);
127
128 EXPECT_EQ(11, cvoh_it->idx() ) << "Index wrong in ConstVertexOHalfedgeIter begin at initialization";
129 EXPECT_EQ(11, cvoh_end->idx() ) << "Index wrong in ConstVertexOHalfedgeIter end at initialization";
130 EXPECT_EQ(3, mesh_.face_handle(*cvoh_it).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter begin at initialization";
131 EXPECT_TRUE(cvoh_it.is_valid()) << "Iterator invalid in ConstVertexOHalfedgeIter at initialization";
132
133 ++cvoh_it ;
134
135 EXPECT_EQ(6, cvoh_it->idx() ) << "Index wrong in ConstVertexOHalfedgeIter step 1";
136 EXPECT_EQ(1, mesh_.face_handle(*cvoh_it).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter step 1";
137 EXPECT_TRUE(cvoh_it.is_valid()) << "Iterator invalid in ConstVertexOHalfedgeIter at step 1";
138
139 ++cvoh_it ;
140
141 EXPECT_EQ(1, cvoh_it->idx() ) << "Index wrong in ConstVertexOHalfedgeIter step 2";
142 EXPECT_EQ(2, mesh_.face_handle(*cvoh_it).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter step 2";
143 EXPECT_TRUE(cvoh_it.is_valid()) << "Iterator invalid in ConstVertexOHalfedgeIter at step 2";
144
145 ++cvoh_it ;
146
147 EXPECT_EQ(2, cvoh_it->idx() ) << "Index wrong in ConstVertexOHalfedgeIter step 3";
148 EXPECT_EQ(0, mesh_.face_handle(*cvoh_it).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter step 3";
149 EXPECT_TRUE(cvoh_it.is_valid()) << "Iterator invalid in ConstVertexOHalfedgeIter at step 3";
150
151 ++cvoh_it ;
152
153 EXPECT_EQ(11, cvoh_it->idx() ) << "Index wrong in ConstVertexOHalfedgeIter step 4";
154 EXPECT_EQ(3, mesh_.face_handle(*cvoh_it).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter step 4";
155 EXPECT_FALSE(cvoh_it.is_valid()) << "Iterator still valid in ConstVertexOHalfedgeIter at step 4";
156 EXPECT_TRUE( cvoh_it == cvoh_end ) << "Miss matched end iterator";
157
158 }
159
160 /*
161 * Small VertexFaceOutgoingHalfedgeIterator Test
162 */
163 TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOutgoingHalfedgeBoundaryIncrement) {
164
165 mesh_.clear();
166
167 // Add some vertices
168 Mesh::VertexHandle vhandle[5];
169
170 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
171 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
172 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
173 vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
174 vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
175
176 // Add two faces
177 std::vector<Mesh::VertexHandle> face_vhandles;
178
179 face_vhandles.push_back(vhandle[0]);
180 face_vhandles.push_back(vhandle[1]);
181 face_vhandles.push_back(vhandle[2]);
182 mesh_.add_face(face_vhandles);
183
184 face_vhandles.clear();
185
186 face_vhandles.push_back(vhandle[1]);
187 face_vhandles.push_back(vhandle[3]);
188 face_vhandles.push_back(vhandle[4]);
189 mesh_.add_face(face_vhandles);
190
191 face_vhandles.clear();
192
193 face_vhandles.push_back(vhandle[0]);
194 face_vhandles.push_back(vhandle[3]);
195 face_vhandles.push_back(vhandle[1]);
196 mesh_.add_face(face_vhandles);
197
198 face_vhandles.clear();
199
200 face_vhandles.push_back(vhandle[2]);
201 face_vhandles.push_back(vhandle[1]);
202 face_vhandles.push_back(vhandle[4]);
203 mesh_.add_face(face_vhandles);
204
205 /* Test setup:
206 0 ==== 2
207 |\ 0 /|
208 | \ / |
209 |2 1 3|
210 | / \ |
211 |/ 1 \|
212 3 ==== 4 */
213 // Starting halfedge is 1->4
214
215
216 // Iterate around vertex 1 at the middle (with holes in between)
217 Mesh::VertexOHalfedgeIter voh_it = mesh_.voh_begin(vhandle[2]);
218 Mesh::VertexOHalfedgeIter voh_end = mesh_.voh_end(vhandle[2]);
219
220 EXPECT_EQ(15, voh_it->idx() ) << "Index wrong in VertexOHalfedgeIter begin at initialization";
221 EXPECT_EQ(15, voh_end->idx() ) << "Index wrong in VertexOHalfedgeIter end at initialization";
222 EXPECT_EQ(-1, mesh_.face_handle(*voh_it).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter begin at initialization";
223 EXPECT_TRUE(voh_it.is_valid()) << "Iterator invalid in VertexOHalfedgeIter at initialization";
224
225 ++voh_it ;
226
227 EXPECT_EQ(3, voh_it->idx() ) << "Index wrong in VertexOHalfedgeIter step 1";
228 EXPECT_EQ(3, mesh_.face_handle(*voh_it).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 1";
229 EXPECT_TRUE(voh_it.is_valid()) << "Iterator invalid in VertexOHalfedgeIter at step 1";
230
231 ++voh_it ;
232
233 EXPECT_EQ(4, voh_it->idx() ) << "Index wrong in VertexOHalfedgeIter step 2";
234 EXPECT_EQ(0, mesh_.face_handle(*voh_it).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 2";
235 EXPECT_TRUE(voh_it.is_valid()) << "Iterator invalid in VertexOHalfedgeIter at step 2";
236
237 ++voh_it ;
238
239 EXPECT_EQ(15, voh_it->idx() ) << "Index wrong in VertexOHalfedgeIter step 3";
240 EXPECT_EQ(-1, mesh_.face_handle(*voh_it).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 3";
241 EXPECT_FALSE(voh_it.is_valid()) << "Iterator still valid in VertexOHalfedgeIter at step 3";
242 EXPECT_TRUE( voh_it == voh_end ) << "Miss matched end iterator";
243
244 }
245
246
247
248 /*
249 * Small Test to check dereferencing the iterator
250 * No real result
251 */
252 TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOutgoingHalfedgeDereferenceIncrement) {
253
254 mesh_.clear();
255
256 // Add some vertices
257 Mesh::VertexHandle vhandle[5];
258
259 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
260 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
261 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
262 vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
263 vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
264
265 std::vector<Mesh::VertexHandle> face_vhandles;
266
267 face_vhandles.push_back(vhandle[0]);
268 face_vhandles.push_back(vhandle[1]);
269 face_vhandles.push_back(vhandle[2]);
270 mesh_.add_face(face_vhandles);
271
272 face_vhandles.clear();
273
274 face_vhandles.push_back(vhandle[1]);
275 face_vhandles.push_back(vhandle[3]);
276 face_vhandles.push_back(vhandle[4]);
277 mesh_.add_face(face_vhandles);
278
279 face_vhandles.clear();
280
281 face_vhandles.push_back(vhandle[0]);
282 face_vhandles.push_back(vhandle[3]);
283 face_vhandles.push_back(vhandle[1]);
284 mesh_.add_face(face_vhandles);
285
286 face_vhandles.clear();
287
288 face_vhandles.push_back(vhandle[2]);
289 face_vhandles.push_back(vhandle[1]);
290 face_vhandles.push_back(vhandle[4]);
291 mesh_.add_face(face_vhandles);
292
293 /* Test setup:
294 0 ==== 2
295 |\ 0 /|
296 | \ / |
297 |2 1 3|
298 | / \ |
299 |/ 1 \|
300 3 ==== 4 */
301
302 // Iterate around vertex 1 at the middle (with holes in between)
303 Mesh::VertexOHalfedgeIter voh_it = mesh_.voh_iter(vhandle[1]);
304
305 // TODO: If called without handle, it won't build
306 Mesh::EdgeHandle eh = mesh_.edge_handle(*voh_it);
307 Mesh::HalfedgeHandle heh = *voh_it;
308 Mesh::VertexHandle vh2 = mesh_.to_vertex_handle(*voh_it);
309
310 EXPECT_EQ(eh.idx() , 5 ) << "Wrong edge handle after dereferencing";
311 EXPECT_EQ(heh.idx() , 11 ) << "Wrong half edge handle after dereferencing";
312 EXPECT_EQ(vh2.idx() , 4 ) << "Wrong vertex handle after dereferencing";
313
314 }
315
316 /*
317 * Test if the end iterator stays invalid after one lap
318 * DISABLED as long as the normal iterators using old behavior
319 */
320 //TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOHalfEdgeIterCheckInvalidationAtEnds) {
321 //
322 // mesh_.clear();
323 //
324 // // Add some vertices
325 // Mesh::VertexHandle vhandle[5];
326 //
327 // vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
328 // vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
329 // vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
330 // vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
331 // vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
332 //
333 // // Add two faces
334 // std::vector<Mesh::VertexHandle> face_vhandles;
335 //
336 // face_vhandles.push_back(vhandle[0]);
337 // face_vhandles.push_back(vhandle[1]);
338 // face_vhandles.push_back(vhandle[2]);
339 // Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles);
340 //
341 // face_vhandles.clear();
342 //
343 // face_vhandles.push_back(vhandle[1]);
344 // face_vhandles.push_back(vhandle[3]);
345 // face_vhandles.push_back(vhandle[4]);
346 // mesh_.add_face(face_vhandles);
347 //
348 // face_vhandles.clear();
349 //
350 // face_vhandles.push_back(vhandle[0]);
351 // face_vhandles.push_back(vhandle[3]);
352 // face_vhandles.push_back(vhandle[1]);
353 // mesh_.add_face(face_vhandles);
354 //
355 // face_vhandles.clear();
356 //
357 // face_vhandles.push_back(vhandle[2]);
358 // face_vhandles.push_back(vhandle[1]);
359 // face_vhandles.push_back(vhandle[4]);
360 // mesh_.add_face(face_vhandles);
361 //
362 // /* Test setup:
363 // 0 ==== 2
364 // |\ 0 /|
365 // | \ / |
366 // |2 1 3|
367 // | / \ |
368 // |/ 1 \|
369 // 3 ==== 4 */
370 //
371 //
372 // // Check if the end iterator stays invalid after end
373 // Mesh::VertexOHalfedgeIter endIter = mesh_.voh_end(vhandle[1]);
374 // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
375 // ++endIter ;
376 // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
377 //
378 // endIter = mesh_.voh_end(vhandle[1]);
379 // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
380 // --endIter;
381 // EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
382 // EXPECT_EQ(2,endIter->idx()) << "EndIter points on the wrong element";
383 //
384 //
385 // // Check if the start iterator decrement is invalid
386 // Mesh::VertexOHalfedgeIter startIter = mesh_.voh_begin(vhandle[1]);
387 // EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid";
388 // --startIter;
389 // EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
390 //
391 // // Check if the start iterator becomes valid
392 // ++startIter;
393 // EXPECT_TRUE(startIter.is_valid()) << "StartIter is invalid after re-incrementing";
394 // EXPECT_EQ(startIter->idx(), mesh_.voh_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
395 //
396 //}
397
398 /*
399 * Test CW and CCW iterators
400 */
401 TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, CWAndCCWCheck) {
402
403 mesh_.clear();
404
405 // Add some vertices
406 Mesh::VertexHandle vhandle[5];
407
408 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
409 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
410 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
411 vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
412 vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
413
414 // Add two faces
415 std::vector<Mesh::VertexHandle> face_vhandles;
416
417 face_vhandles.push_back(vhandle[0]);
418 face_vhandles.push_back(vhandle[1]);
419 face_vhandles.push_back(vhandle[2]);
420 mesh_.add_face(face_vhandles);
421
422 face_vhandles.clear();
423
424 face_vhandles.push_back(vhandle[1]);
425 face_vhandles.push_back(vhandle[3]);
426 face_vhandles.push_back(vhandle[4]);
427 mesh_.add_face(face_vhandles);
428
429 face_vhandles.clear();
430
431 face_vhandles.push_back(vhandle[0]);
432 face_vhandles.push_back(vhandle[3]);
433 face_vhandles.push_back(vhandle[1]);
434 mesh_.add_face(face_vhandles);
435
436 face_vhandles.clear();
437
438 face_vhandles.push_back(vhandle[2]);
439 face_vhandles.push_back(vhandle[1]);
440 face_vhandles.push_back(vhandle[4]);
441 mesh_.add_face(face_vhandles);
442
443 /* Test setup:
444 0 ==== 2
445 |\ 0 /|
446 | \ / |
447 |2 1 3|
448 | / \ |
449 |/ 1 \|
450 3 ==== 4 */
451
452
453 int indices[5] = {11, 2, 1, 6, 11};
454 int rev_indices[5];
455 std::reverse_copy(indices,indices+5,rev_indices);
456
457 Mesh::VertexHandle vh = vhandle[1];
458
459 //CCW
460 Mesh::VertexOHalfedgeCCWIter voh_ccwit = mesh_.voh_ccwbegin(vh);
461 Mesh::VertexOHalfedgeCCWIter voh_ccwend = mesh_.voh_ccwend(vh);
462 size_t i = 0;
463 for (;voh_ccwit != voh_ccwend; ++voh_ccwit, ++i)
464 {
465 EXPECT_EQ(indices[i], voh_ccwit->idx()) << "Index wrong in VertexOHalfedgeCCWIter";
466 }
467
468 EXPECT_FALSE(voh_ccwit.is_valid()) << "Iterator invalid in VertexOHalfedgeCCWIter at end";
469 EXPECT_TRUE( voh_ccwit == voh_ccwend ) << "End iterator for VertexOHalfedgeCCWIter not matching";
470
471 //constant CCW
472 Mesh::ConstVertexOHalfedgeCCWIter cvoh_ccwit = mesh_.cvoh_ccwbegin(vh);
473 Mesh::ConstVertexOHalfedgeCCWIter cvoh_ccwend = mesh_.cvoh_ccwend(vh);
474 i = 0;
475 for (;cvoh_ccwit != cvoh_ccwend; ++cvoh_ccwit, ++i)
476 {
477 EXPECT_EQ(indices[i], cvoh_ccwit->idx()) << "Index wrong in ConstVertexOHalfedgeCCWIter";
478 }
479
480 EXPECT_FALSE(cvoh_ccwit.is_valid()) << "Iterator invalid in ConstVertexOHalfedgeCCWIter at end";
481 EXPECT_TRUE( cvoh_ccwit == cvoh_ccwend ) << "End iterator for ConstVertexOHalfedgeCCWIter not matching";
482
483 //CW
484 Mesh::VertexOHalfedgeCWIter voh_cwit = mesh_.voh_cwbegin(vh);
485 Mesh::VertexOHalfedgeCWIter voh_cwend = mesh_.voh_cwend(vh);
486 i = 0;
487 for (;voh_cwit != voh_cwend; ++voh_cwit, ++i)
488 {
489 EXPECT_EQ(rev_indices[i], voh_cwit->idx()) << "Index wrong in VertexOHalfedgeCWIter";
490 }
491 EXPECT_FALSE(voh_cwit.is_valid()) << "Iterator invalid in VertexOHalfedgeCWIter at end";
492 EXPECT_TRUE( voh_cwit == voh_cwend ) << "End iterator for VertexOHalfedgeCWIter not matching";
493
494 //constant CW
495 Mesh::ConstVertexOHalfedgeCWIter cvoh_cwit = mesh_.cvoh_cwbegin(vh);
496 Mesh::ConstVertexOHalfedgeCWIter cvoh_cwend = mesh_.cvoh_cwend(vh);
497 i = 0;
498 for (;cvoh_cwit != cvoh_cwend; ++cvoh_cwit, ++i)
499 {
500 EXPECT_EQ(rev_indices[i], cvoh_cwit->idx()) << "Index wrong in ConstVertexOHalfedgeCWIter";
501 }
502 EXPECT_FALSE(cvoh_cwit.is_valid()) << "Iterator invalid in ConstVertexOHalfedgeCWIter at end";
503 EXPECT_TRUE( cvoh_cwit == cvoh_cwend ) << "End iterator for ConstVertexOHalfedgeCWIter not matching";
504
505 /*
506 * conversion properties:
507 * a) cw_begin == CWIter(ccw_begin())
508 * b) cw_iter->idx() == CCWIter(cw_iter)->idx() for valid iterators
509 * c) --cw_iter == CWIter(++ccwIter) for valid iterators
510 * d) cw_end == CWIter(ccw_end()) => --cw_end != CWIter(++ccw_end()) *
511 */
512 Mesh::VertexOHalfedgeCWIter voh_cwIter = mesh_.voh_cwbegin(vh);
513 // a)
514 EXPECT_TRUE( voh_cwIter == Mesh::VertexOHalfedgeCWIter(mesh_.voh_ccwbegin(vh)) ) << "ccw to cw conversion failed";
515 EXPECT_TRUE( Mesh::VertexOHalfedgeCCWIter(voh_cwIter) == mesh_.voh_ccwbegin(vh) ) << "cw to ccw conversion failed";
516 // b)
517 EXPECT_EQ( voh_cwIter->idx(), Mesh::VertexOHalfedgeCCWIter(voh_cwIter)->idx()) << "iterators doesnt point on the same element";
518 // c)
519 ++voh_cwIter;
520 voh_ccwend = mesh_.voh_ccwend(vh);
521 --voh_ccwend;
522 EXPECT_EQ(voh_cwIter->idx(),voh_ccwend->idx()) << "iteratoes are not equal after inc/dec";
523 // additional conversion check
524 voh_ccwend = Mesh::VertexOHalfedgeCCWIter(voh_cwIter);
525 EXPECT_EQ(voh_cwIter->idx(),voh_ccwend->idx())<< "iterators doesnt point on the same element";
526 // d)
527 voh_cwIter = Mesh::VertexOHalfedgeCWIter(mesh_.voh_ccwend(vh));
528 EXPECT_FALSE(voh_cwIter.is_valid()) << "end iterator is not invalid";
529 EXPECT_TRUE(Mesh::VertexOHalfedgeCCWIter(mesh_.voh_cwend(vh)) == mesh_.voh_ccwend(vh)) << "end iterators are not equal";
530
531
532 }
533
534
535
536
537 }
OpenMesh::PolyMeshT::VertexOHalfedgeIter
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:163
OpenMesh::PolyMeshT::Point
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:112
OpenMesh::PolyMeshT::add_vertex
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Definition: PolyMeshT.hh:235
OpenMesh::PolyMeshT::VertexHandle
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:136
OpenMeshBase
Definition: unittests_common.hh:26
OpenMesh::PolyMeshT::ConstVertexOHalfedgeIter
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:173