1 #include <gtest/gtest.h> 2 #include <Unittests/unittests_common.hh> 8 class OpenMeshTrimeshCirculatorVertexIHalfEdge :
public OpenMeshBase {
13 virtual void SetUp() {
17 virtual void TearDown() {
37 TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexIncomingHalfedgeWithoutHolesIncrement) {
51 std::vector<Mesh::VertexHandle> face_vhandles;
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);
58 face_vhandles.clear();
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);
65 face_vhandles.clear();
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);
72 face_vhandles.clear();
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);
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
163 TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexOIncomingHalfedgeBoundaryIncrement) {
177 std::vector<Mesh::VertexHandle> face_vhandles;
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);
184 face_vhandles.clear();
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);
191 face_vhandles.clear();
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);
198 face_vhandles.clear();
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);
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";
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";
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";
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";
252 TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexIncomingHalfedgeDereferenceIncrement) {
265 std::vector<Mesh::VertexHandle> face_vhandles;
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);
272 face_vhandles.clear();
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);
279 face_vhandles.clear();
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);
286 face_vhandles.clear();
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);
306 Mesh::EdgeHandle eh = mesh_.edge_handle(*vih_it);
307 Mesh::HalfedgeHandle heh = *vih_it;
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";
401 TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, CWAndCCWCheck) {
415 std::vector<Mesh::VertexHandle> face_vhandles;
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);
422 face_vhandles.clear();
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);
429 face_vhandles.clear();
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);
436 face_vhandles.clear();
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);
453 int indices[4] = {14, 5, 2, 14};
455 std::reverse_copy(indices,indices+4,rev_indices);
460 Mesh::VertexIHalfedgeCCWIter vih_ccwit = mesh_.vih_ccwbegin(vh);
461 Mesh::VertexIHalfedgeCCWIter vih_ccwend = mesh_.vih_ccwend(vh);
463 for (;vih_ccwit != vih_ccwend; ++vih_ccwit, ++i)
465 EXPECT_EQ(indices[i], vih_ccwit->idx()) <<
"Index wrong in VertexIHalfedgeCCWIter";
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";
472 Mesh::ConstVertexIHalfedgeCCWIter cvih_ccwit = mesh_.cvih_ccwbegin(vh);
473 Mesh::ConstVertexIHalfedgeCCWIter cvih_ccwend = mesh_.cvih_ccwend(vh);
475 for (;cvih_ccwit != cvih_ccwend; ++cvih_ccwit, ++i)
477 EXPECT_EQ(indices[i], cvih_ccwit->idx()) <<
"Index wrong in ConstVertexIHalfedgeCCWIter";
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";
484 Mesh::VertexIHalfedgeCWIter vih_cwit = mesh_.vih_cwbegin(vh);
485 Mesh::VertexIHalfedgeCWIter vih_cwend = mesh_.vih_cwend(vh);
487 for (;vih_cwit != vih_cwend; ++vih_cwit, ++i)
489 EXPECT_EQ(rev_indices[i], vih_cwit->idx()) <<
"Index wrong in VertexIHalfedgeCWIter";
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";
495 Mesh::ConstVertexIHalfedgeCWIter cvih_cwit = mesh_.cvih_cwbegin(vh);
496 Mesh::ConstVertexIHalfedgeCWIter cvih_cwend = mesh_.cvih_cwend(vh);
498 for (;cvih_cwit != cvih_cwend; ++cvih_cwit, ++i)
500 EXPECT_EQ(rev_indices[i], cvih_cwit->idx()) <<
"Index wrong in ConstVertexIHalfedgeCWIter";
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";
512 Mesh::VertexIHalfedgeCWIter vih_cwIter = mesh_.vih_cwbegin(vh);
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";
517 EXPECT_EQ( vih_cwIter->idx(), Mesh::VertexIHalfedgeCCWIter(vih_cwIter)->idx()) <<
"iterators doesnt point on the same element";
520 vih_ccwend = mesh_.vih_ccwend(vh);
522 EXPECT_EQ(vih_cwIter->idx(),vih_ccwend->idx()) <<
"iteratoes are not equal after inc/dec";
524 vih_ccwend = Mesh::VertexIHalfedgeCCWIter(vih_cwIter);
525 EXPECT_EQ(vih_cwIter->idx(),vih_ccwend->idx())<<
"iterators doesnt point on the same element";
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";
Kernel::VertexIHalfedgeIter VertexIHalfedgeIter
Circulator.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Kernel::Point Point
Coordinate type.
Kernel::ConstVertexIHalfedgeIter ConstVertexIHalfedgeIter
Circulator.