1 #include <gtest/gtest.h> 2 #include <Unittests/unittests_common.hh> 8 class OpenMeshTrimeshCirculatorVertexOHalfEdge :
public OpenMeshBase {
13 virtual void SetUp() {
17 virtual void TearDown() {
37 TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOutgoingHalfedgeWithoutHolesIncrement) {
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);
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
163 TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOutgoingHalfedgeBoundaryIncrement) {
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(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";
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";
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";
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";
252 TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOutgoingHalfedgeDereferenceIncrement) {
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(*voh_it);
307 Mesh::HalfedgeHandle heh = *voh_it;
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";
401 TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, 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[5] = {11, 2, 1, 6, 11};
455 std::reverse_copy(indices,indices+5,rev_indices);
460 Mesh::VertexOHalfedgeCCWIter voh_ccwit = mesh_.voh_ccwbegin(vh);
461 Mesh::VertexOHalfedgeCCWIter voh_ccwend = mesh_.voh_ccwend(vh);
463 for (;voh_ccwit != voh_ccwend; ++voh_ccwit, ++i)
465 EXPECT_EQ(indices[i], voh_ccwit->idx()) <<
"Index wrong in VertexOHalfedgeCCWIter";
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";
472 Mesh::ConstVertexOHalfedgeCCWIter cvoh_ccwit = mesh_.cvoh_ccwbegin(vh);
473 Mesh::ConstVertexOHalfedgeCCWIter cvoh_ccwend = mesh_.cvoh_ccwend(vh);
475 for (;cvoh_ccwit != cvoh_ccwend; ++cvoh_ccwit, ++i)
477 EXPECT_EQ(indices[i], cvoh_ccwit->idx()) <<
"Index wrong in ConstVertexOHalfedgeCCWIter";
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";
484 Mesh::VertexOHalfedgeCWIter voh_cwit = mesh_.voh_cwbegin(vh);
485 Mesh::VertexOHalfedgeCWIter voh_cwend = mesh_.voh_cwend(vh);
487 for (;voh_cwit != voh_cwend; ++voh_cwit, ++i)
489 EXPECT_EQ(rev_indices[i], voh_cwit->idx()) <<
"Index wrong in VertexOHalfedgeCWIter";
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";
495 Mesh::ConstVertexOHalfedgeCWIter cvoh_cwit = mesh_.cvoh_cwbegin(vh);
496 Mesh::ConstVertexOHalfedgeCWIter cvoh_cwend = mesh_.cvoh_cwend(vh);
498 for (;cvoh_cwit != cvoh_cwend; ++cvoh_cwit, ++i)
500 EXPECT_EQ(rev_indices[i], cvoh_cwit->idx()) <<
"Index wrong in ConstVertexOHalfedgeCWIter";
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";
512 Mesh::VertexOHalfedgeCWIter voh_cwIter = mesh_.voh_cwbegin(vh);
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";
517 EXPECT_EQ( voh_cwIter->idx(), Mesh::VertexOHalfedgeCCWIter(voh_cwIter)->idx()) <<
"iterators doesnt point on the same element";
520 voh_ccwend = mesh_.voh_ccwend(vh);
522 EXPECT_EQ(voh_cwIter->idx(),voh_ccwend->idx()) <<
"iteratoes are not equal after inc/dec";
524 voh_ccwend = Mesh::VertexOHalfedgeCCWIter(voh_cwIter);
525 EXPECT_EQ(voh_cwIter->idx(),voh_ccwend->idx())<<
"iterators doesnt point on the same element";
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";
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Kernel::ConstVertexOHalfedgeIter ConstVertexOHalfedgeIter
Circulator.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
Kernel::Point Point
Coordinate type.