Developer Documentation

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