Developer Documentation
unittests_trimesh_circulator_vertex_ihalfedge.cc
1 #include <gtest/gtest.h>
2 #include <Unittests/unittests_common.hh>
3 
4 #include <iostream>
5 
6 namespace {
7 
8 class OpenMeshTrimeshCirculatorVertexIHalfEdge : 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 VertexFaceIterator Test without holes in it
36  */
37 TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexIncomingHalfedgeWithoutHolesIncrement) {
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  // Iterate around vertex 1 at the middle (with holes in between)
90  Mesh::VertexIHalfedgeIter vih_it = mesh_.vih_begin(vhandle[1]);
91  Mesh::VertexIHalfedgeIter vih_end = mesh_.vih_end(vhandle[1]);
92 
93  EXPECT_EQ(10, vih_it->idx() ) << "Index wrong in VertexIHalfedgeIter begin at initialization";
94  EXPECT_EQ(10, vih_end->idx() ) << "Index wrong in VertexIHalfedgeIter end at initialization";
95  EXPECT_EQ(1, mesh_.face_handle(*vih_it).idx() ) << "Corresponding face Index wrong in VertexIHalfedgeIter begin at initialization";
96  EXPECT_TRUE(vih_it.is_valid()) << "Iterator invalid in VertexIHalfedgeIter at initialization";
97 
98  ++vih_it ;
99 
100  EXPECT_EQ(7, vih_it->idx() ) << "Index wrong in VertexIHalfedgeIter step 1";
101  EXPECT_EQ(2, mesh_.face_handle(*vih_it).idx() ) << "Corresponding face Index wrong in VertexIHalfedgeIter step 1";
102  EXPECT_TRUE(vih_it.is_valid()) << "Iterator invalid in VertexIHalfedgeIter at step 1";
103 
104  ++vih_it ;
105 
106  EXPECT_EQ(0, vih_it->idx() ) << "Index wrong in VertexIHalfedgeIter step 2";
107  EXPECT_EQ(0, mesh_.face_handle(*vih_it).idx() ) << "Corresponding face Index wrong in VertexIHalfedgeIter step 2";
108  EXPECT_TRUE(vih_it.is_valid()) << "Iterator invalid in VertexIHalfedgeIter at step 2";
109 
110  ++vih_it ;
111 
112  EXPECT_EQ(3, vih_it->idx() ) << "Index wrong in VertexIHalfedgeIter step 3";
113  EXPECT_EQ(3, mesh_.face_handle(*vih_it).idx() ) << "Corresponding face Index wrong in VertexIHalfedgeIter step 3";
114  EXPECT_TRUE(vih_it.is_valid()) << "Iterator invalid in VertexIHalfedgeIter at step 3";
115 
116  ++vih_it ;
117 
118  EXPECT_EQ(10, vih_it->idx() ) << "Index wrong in VertexIHalfedgeIter step 4";
119  EXPECT_EQ(1, mesh_.face_handle(*vih_it).idx() ) << "Corresponding face Index wrong in VertexIHalfedgeIter step 4";
120  EXPECT_FALSE(vih_it.is_valid()) << "Iterator still valid in VertexIHalfedgeIter at step 4";
121  EXPECT_TRUE( vih_it == vih_end ) << "Miss matched end iterator";
122 
123 
124  // Iterate around vertex 1 at the middle (with holes in between)
125  Mesh::ConstVertexIHalfedgeIter cvih_it = mesh_.cvih_begin(vhandle[1]);
126  Mesh::ConstVertexIHalfedgeIter cvoh_end = mesh_.cvih_end(vhandle[1]);
127 
128  EXPECT_EQ(10, cvih_it->idx() ) << "Index wrong in ConstVertexIHalfedgeIter begin at initialization";
129  EXPECT_EQ(10, cvoh_end->idx() ) << "Index wrong in ConstVertexIHalfedgeIter end at initialization";
130  EXPECT_EQ(1, mesh_.face_handle(*cvih_it).idx() ) << "Corresponding face Index wrong in ConstVertexIHalfedgeIter begin at initialization";
131  EXPECT_TRUE(cvih_it.is_valid()) << "Iterator invalid in ConstVertexIHalfedgeIter at initialization";
132 
133  ++cvih_it ;
134 
135  EXPECT_EQ(7, cvih_it->idx() ) << "Index wrong in ConstVertexIHalfedgeIter step 1";
136  EXPECT_EQ(2, mesh_.face_handle(*cvih_it).idx() ) << "Corresponding face Index wrong in ConstVertexIHalfedgeIter step 1";
137  EXPECT_TRUE(cvih_it.is_valid()) << "Iterator invalid in ConstVertexIHalfedgeIter at step 1";
138 
139  ++cvih_it ;
140 
141  EXPECT_EQ(0, cvih_it->idx() ) << "Index wrong in ConstVertexIHalfedgeIter step 2";
142  EXPECT_EQ(0, mesh_.face_handle(*cvih_it).idx() ) << "Corresponding face Index wrong in ConstVertexIHalfedgeIter step 2";
143  EXPECT_TRUE(cvih_it.is_valid()) << "Iterator invalid in ConstVertexIHalfedgeIter at step 2";
144 
145  ++cvih_it ;
146 
147  EXPECT_EQ(3, cvih_it->idx() ) << "Index wrong in ConstVertexIHalfedgeIter step 3";
148  EXPECT_EQ(3, mesh_.face_handle(*cvih_it).idx() ) << "Corresponding face Index wrong in ConstVertexIHalfedgeIter step 3";
149  EXPECT_TRUE(cvih_it.is_valid()) << "Iterator invalid in ConstVertexIHalfedgeIter at step 3";
150 
151  ++cvih_it ;
152 
153  EXPECT_EQ(10, cvih_it->idx() ) << "Index wrong in ConstVertexIHalfedgeIter step 4";
154  EXPECT_EQ(1, mesh_.face_handle(*cvih_it).idx() ) << "Corresponding face Index wrong in ConstVertexIHalfedgeIter step 4";
155  EXPECT_FALSE(cvih_it.is_valid()) << "Iterator still valid in ConstVertexIHalfedgeIter at step 4";
156  EXPECT_TRUE( cvih_it == cvoh_end ) << "Miss matched end iterator";
157 
158 }
159 
160 /*
161  * Small VertexFaceOutgoingHalfedgeIterator Test
162  */
163 TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexOIncomingHalfedgeBoundaryIncrement) {
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::VertexIHalfedgeIter vih_it = mesh_.vih_begin(vhandle[2]);
218  Mesh::VertexIHalfedgeIter vih_end = mesh_.vih_end(vhandle[2]);
219 
220  EXPECT_EQ(14, vih_it->idx() ) << "Index wrong in VertexIHalfedgeIter begin at initialization";
221  EXPECT_EQ(14, vih_end->idx() ) << "Index wrong in VertexIHalfedgeIter end at initialization";
222  EXPECT_EQ(3, mesh_.face_handle(*vih_it).idx() ) << "Corresponding face Index wrong in VertexIHalfedgeIter begin at initialization";
223  EXPECT_TRUE(vih_it.is_valid()) << "Iterator invalid in VertexIHalfedgeIter at initialization";
224 
225  ++vih_it ;
226 
227  EXPECT_EQ(2, vih_it->idx() ) << "Index wrong in VertexIHalfedgeIter step 1";
228  EXPECT_EQ(0, mesh_.face_handle(*vih_it).idx() ) << "Corresponding face Index wrong in VertexIHalfedgeIter step 1";
229  EXPECT_TRUE(vih_it.is_valid()) << "Iterator invalid in VertexIHalfedgeIter at step 1";
230 
231  ++vih_it ;
232 
233  EXPECT_EQ(5, vih_it->idx() ) << "Index wrong in VertexIHalfedgeIter step 2";
234  EXPECT_EQ(-1, mesh_.face_handle(*vih_it).idx() ) << "Corresponding face Index wrong in VertexIHalfedgeIter step 2";
235  EXPECT_TRUE(vih_it.is_valid()) << "Iterator invalid in VertexIHalfedgeIter at step 2";
236 
237  ++vih_it ;
238 
239  EXPECT_EQ(14, vih_it->idx() ) << "Index wrong in VertexIHalfedgeIter step 3";
240  EXPECT_EQ(3, mesh_.face_handle(*vih_it).idx() ) << "Corresponding face Index wrong in VertexIHalfedgeIter step 3";
241  EXPECT_FALSE(vih_it.is_valid()) << "Iterator still valid in VertexIHalfedgeIter at step 3";
242  EXPECT_TRUE( vih_it == vih_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(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexIncomingHalfedgeDereferenceIncrement) {
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::VertexIHalfedgeIter vih_it = mesh_.vih_iter(vhandle[1]);
304 
305  // TODO: If called without handle, it won't build
306  Mesh::EdgeHandle eh = mesh_.edge_handle(*vih_it);
307  Mesh::HalfedgeHandle heh = *vih_it;
308  Mesh::VertexHandle vh2 = mesh_.to_vertex_handle(*vih_it);
309 
310  EXPECT_EQ(eh.idx() , 5 ) << "Wrong edge handle after dereferencing";
311  EXPECT_EQ(heh.idx() , 10 ) << "Wrong half edge handle after dereferencing";
312  EXPECT_EQ(vh2.idx() , 1 ) << "Wrong vertex handle after dereferencing";
313 }
314 
315 /*
316  * Test if the end iterator stays invalid after one lap
317  * DISABLED as long as the normal iterators using old behavior
318  */
319 //TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexIHalfEdgeIterCheckInvalidationAtEnds) {
320 //
321 // mesh_.clear();
322 //
323 // // Add some vertices
324 // Mesh::VertexHandle vhandle[5];
325 //
326 // vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
327 // vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
328 // vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
329 // vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
330 // vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
331 //
332 // // Add two faces
333 // std::vector<Mesh::VertexHandle> face_vhandles;
334 //
335 // face_vhandles.push_back(vhandle[0]);
336 // face_vhandles.push_back(vhandle[1]);
337 // face_vhandles.push_back(vhandle[2]);
338 // Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles);
339 //
340 // face_vhandles.clear();
341 //
342 // face_vhandles.push_back(vhandle[1]);
343 // face_vhandles.push_back(vhandle[3]);
344 // face_vhandles.push_back(vhandle[4]);
345 // mesh_.add_face(face_vhandles);
346 //
347 // face_vhandles.clear();
348 //
349 // face_vhandles.push_back(vhandle[0]);
350 // face_vhandles.push_back(vhandle[3]);
351 // face_vhandles.push_back(vhandle[1]);
352 // mesh_.add_face(face_vhandles);
353 //
354 // face_vhandles.clear();
355 //
356 // face_vhandles.push_back(vhandle[2]);
357 // face_vhandles.push_back(vhandle[1]);
358 // face_vhandles.push_back(vhandle[4]);
359 // mesh_.add_face(face_vhandles);
360 //
361 // /* Test setup:
362 // 0 ==== 2
363 // |\ 0 /|
364 // | \ / |
365 // |2 1 3|
366 // | / \ |
367 // |/ 1 \|
368 // 3 ==== 4 */
369 //
370 //
371 // // Check if the end iterator stays invalid after end
372 // Mesh::VertexIHalfedgeIter endIter = mesh_.vih_end(vhandle[1]);
373 // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
374 // ++endIter ;
375 // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
376 //
377 // // Check if the end iterators becomes valid after decrement
378 // endIter = mesh_.vih_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(3,endIter->idx()) << "EndIter points on the wrong element";
383 //
384 //
385 // // Check if the start iterator decrement is invalid
386 // Mesh::VertexIHalfedgeIter startIter = mesh_.vih_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()) << "StarIter is invalid after re-incrementing";
394 // EXPECT_EQ(startIter->idx(), mesh_.vih_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
395 //
396 //}
397 
398 /*
399  * Test CW and CCW iterators
400  */
401 TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, 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[4] = {14, 5, 2, 14};
454  int rev_indices[4];
455  std::reverse_copy(indices,indices+4,rev_indices);
456 
457  Mesh::VertexHandle vh = vhandle[2];
458 
459  //CCW
460  Mesh::VertexIHalfedgeCCWIter vih_ccwit = mesh_.vih_ccwbegin(vh);
461  Mesh::VertexIHalfedgeCCWIter vih_ccwend = mesh_.vih_ccwend(vh);
462  size_t i = 0;
463  for (;vih_ccwit != vih_ccwend; ++vih_ccwit, ++i)
464  {
465  EXPECT_EQ(indices[i], vih_ccwit->idx()) << "Index wrong in VertexIHalfedgeCCWIter";
466  }
467 
468  EXPECT_FALSE(vih_ccwit.is_valid()) << "Iterator invalid in VertexIHalfedgeCCWIter at end";
469  EXPECT_TRUE( vih_ccwit == vih_ccwend ) << "End iterator for VertexIHalfedgeCCWIter not matching";
470 
471  //constant CCW
472  Mesh::ConstVertexIHalfedgeCCWIter cvih_ccwit = mesh_.cvih_ccwbegin(vh);
473  Mesh::ConstVertexIHalfedgeCCWIter cvih_ccwend = mesh_.cvih_ccwend(vh);
474  i = 0;
475  for (;cvih_ccwit != cvih_ccwend; ++cvih_ccwit, ++i)
476  {
477  EXPECT_EQ(indices[i], cvih_ccwit->idx()) << "Index wrong in ConstVertexIHalfedgeCCWIter";
478  }
479 
480  EXPECT_FALSE(cvih_ccwit.is_valid()) << "Iterator invalid in ConstVertexIHalfedgeCCWIter at end";
481  EXPECT_TRUE( cvih_ccwit == cvih_ccwend ) << "End iterator for ConstVertexIHalfedgeCCWIter not matching";
482 
483  //CW
484  Mesh::VertexIHalfedgeCWIter vih_cwit = mesh_.vih_cwbegin(vh);
485  Mesh::VertexIHalfedgeCWIter vih_cwend = mesh_.vih_cwend(vh);
486  i = 0;
487  for (;vih_cwit != vih_cwend; ++vih_cwit, ++i)
488  {
489  EXPECT_EQ(rev_indices[i], vih_cwit->idx()) << "Index wrong in VertexIHalfedgeCWIter";
490  }
491  EXPECT_FALSE(vih_cwit.is_valid()) << "Iterator invalid in VertexIHalfedgeCWIter at end";
492  EXPECT_TRUE( vih_cwit == vih_cwend ) << "End iterator for VertexIHalfedgeCWIter not matching";
493 
494  //constant CW
495  Mesh::ConstVertexIHalfedgeCWIter cvih_cwit = mesh_.cvih_cwbegin(vh);
496  Mesh::ConstVertexIHalfedgeCWIter cvih_cwend = mesh_.cvih_cwend(vh);
497  i = 0;
498  for (;cvih_cwit != cvih_cwend; ++cvih_cwit, ++i)
499  {
500  EXPECT_EQ(rev_indices[i], cvih_cwit->idx()) << "Index wrong in ConstVertexIHalfedgeCWIter";
501  }
502  EXPECT_FALSE(cvih_cwit.is_valid()) << "Iterator invalid in ConstVertexIHalfedgeCWIter at end";
503  EXPECT_TRUE( cvih_cwit == cvih_cwend ) << "End iterator for ConstVertexIHalfedgeCWIter 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::VertexIHalfedgeCWIter vih_cwIter = mesh_.vih_cwbegin(vh);
513  // a)
514  EXPECT_TRUE( vih_cwIter == Mesh::VertexIHalfedgeCWIter(mesh_.vih_ccwbegin(vh)) ) << "ccw to cw conversion failed";
515  EXPECT_TRUE( Mesh::VertexIHalfedgeCCWIter(vih_cwIter) == mesh_.vih_ccwbegin(vh) ) << "cw to ccw conversion failed";
516  // b)
517  EXPECT_EQ( vih_cwIter->idx(), Mesh::VertexIHalfedgeCCWIter(vih_cwIter)->idx()) << "iterators doesnt point on the same element";
518  // c)
519  ++vih_cwIter;
520  vih_ccwend = mesh_.vih_ccwend(vh);
521  --vih_ccwend;
522  EXPECT_EQ(vih_cwIter->idx(),vih_ccwend->idx()) << "iteratoes are not equal after inc/dec";
523  // additional conversion check
524  vih_ccwend = Mesh::VertexIHalfedgeCCWIter(vih_cwIter);
525  EXPECT_EQ(vih_cwIter->idx(),vih_ccwend->idx())<< "iterators doesnt point on the same element";
526  // d)
527  vih_cwIter = Mesh::VertexIHalfedgeCWIter(mesh_.vih_ccwend(vh));
528  EXPECT_FALSE(vih_cwIter.is_valid()) << "end iterator is not invalid";
529  EXPECT_TRUE(Mesh::VertexIHalfedgeCCWIter(mesh_.vih_cwend(vh)) == mesh_.vih_ccwend(vh)) << "end iterators are not equal";
530 
531 
532 }
533 
534 
535 }
Kernel::VertexIHalfedgeIter VertexIHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:167
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:139
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Definition: PolyMeshT.hh:236
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:115
Kernel::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:177