1 #include <gtest/gtest.h>
2 #include <Unittests/unittests_common.hh>
8 class OpenMeshTrimeshCirculatorVertexVertex :
public OpenMeshBase {
13 virtual void SetUp() {
17 virtual void TearDown() {
38 TEST_F(OpenMeshTrimeshCirculatorVertexVertex, VertexVertexIncrement) {
52 std::vector<Mesh::VertexHandle> face_vhandles;
54 face_vhandles.push_back(vhandle[0]);
55 face_vhandles.push_back(vhandle[1]);
56 face_vhandles.push_back(vhandle[2]);
57 mesh_.add_face(face_vhandles);
59 face_vhandles.clear();
61 face_vhandles.push_back(vhandle[1]);
62 face_vhandles.push_back(vhandle[3]);
63 face_vhandles.push_back(vhandle[4]);
64 mesh_.add_face(face_vhandles);
66 face_vhandles.clear();
68 face_vhandles.push_back(vhandle[0]);
69 face_vhandles.push_back(vhandle[3]);
70 face_vhandles.push_back(vhandle[1]);
71 mesh_.add_face(face_vhandles);
73 face_vhandles.clear();
75 face_vhandles.push_back(vhandle[2]);
76 face_vhandles.push_back(vhandle[1]);
77 face_vhandles.push_back(vhandle[4]);
78 mesh_.add_face(face_vhandles);
95 EXPECT_EQ(4, vv_it->idx() ) <<
"Index wrong in VertexVertexIter begin at initialization";
96 EXPECT_EQ(4, vv_end->idx() ) <<
"Index wrong in VertexVertexIter end at initialization";
97 EXPECT_TRUE(vv_it.is_valid()) <<
"Iterator invalid in VertexVertexIter at initialization";
101 EXPECT_EQ(3, vv_it->idx() ) <<
"Index wrong in VertexVertexIter step 1";
102 EXPECT_TRUE(vv_it.is_valid()) <<
"Iterator invalid in VertexVertexIter at step 1";
106 EXPECT_EQ(0, vv_it->idx() ) <<
"Index wrong in VertexVertexIter step 2";
107 EXPECT_TRUE(vv_it.is_valid()) <<
"Iterator invalid in VertexVertexIter at step 2";
111 EXPECT_EQ(2, vv_it->idx() ) <<
"Index wrong in VertexVertexIter step 3";
112 EXPECT_TRUE(vv_it.is_valid()) <<
"Iterator invalid in VertexVertexIter at step 3";
116 EXPECT_EQ(4, vv_it->idx() ) <<
"Index wrong in VertexVertexIter step 4";
117 EXPECT_FALSE(vv_it.is_valid()) <<
"Iterator still valid in VertexVertexIter at step 4";
118 EXPECT_TRUE( vv_it == vv_end ) <<
"Miss matched end iterator";
125 TEST_F(OpenMeshTrimeshCirculatorVertexVertex, VertexVertexBoundaryIncrement) {
139 std::vector<Mesh::VertexHandle> face_vhandles;
141 face_vhandles.push_back(vhandle[0]);
142 face_vhandles.push_back(vhandle[1]);
143 face_vhandles.push_back(vhandle[2]);
144 mesh_.add_face(face_vhandles);
146 face_vhandles.clear();
148 face_vhandles.push_back(vhandle[1]);
149 face_vhandles.push_back(vhandle[3]);
150 face_vhandles.push_back(vhandle[4]);
151 mesh_.add_face(face_vhandles);
153 face_vhandles.clear();
155 face_vhandles.push_back(vhandle[0]);
156 face_vhandles.push_back(vhandle[3]);
157 face_vhandles.push_back(vhandle[1]);
158 mesh_.add_face(face_vhandles);
160 face_vhandles.clear();
162 face_vhandles.push_back(vhandle[2]);
163 face_vhandles.push_back(vhandle[1]);
164 face_vhandles.push_back(vhandle[4]);
165 mesh_.add_face(face_vhandles);
182 EXPECT_EQ(4, vv_it->idx() ) <<
"Index wrong in VertexVertexIter begin at initialization";
183 EXPECT_EQ(4, vv_end->idx() ) <<
"Index wrong in VertexVertexIter end at initialization";
184 EXPECT_TRUE(vv_it.is_valid()) <<
"Iterator invalid in VertexVertexIter at initialization";
188 EXPECT_EQ(1, vv_it->idx() ) <<
"Index wrong in VertexVertexIter step 1";
189 EXPECT_TRUE(vv_it.is_valid()) <<
"Iterator invalid in VertexVertexIter at step 1";
193 EXPECT_EQ(0, vv_it->idx() ) <<
"Index wrong in VertexVertexIter step 2";
194 EXPECT_TRUE(vv_it.is_valid()) <<
"Iterator invalid in VertexVertexIter at step 2";
198 EXPECT_EQ(4, vv_it->idx() ) <<
"Index wrong in VertexVertexIter step 3";
199 EXPECT_FALSE(vv_it.is_valid()) <<
"Iterator invalid in VertexVertexIter at step 3";
200 EXPECT_TRUE( vv_it == vv_end ) <<
"Miss matched end iterator";
290 TEST_F(OpenMeshTrimeshCirculatorVertexVertex, CWAndCCWCheck) {
304 std::vector<Mesh::VertexHandle> face_vhandles;
306 face_vhandles.push_back(vhandle[0]);
307 face_vhandles.push_back(vhandle[1]);
308 face_vhandles.push_back(vhandle[2]);
309 mesh_.add_face(face_vhandles);
311 face_vhandles.clear();
313 face_vhandles.push_back(vhandle[1]);
314 face_vhandles.push_back(vhandle[3]);
315 face_vhandles.push_back(vhandle[4]);
316 mesh_.add_face(face_vhandles);
318 face_vhandles.clear();
320 face_vhandles.push_back(vhandle[0]);
321 face_vhandles.push_back(vhandle[3]);
322 face_vhandles.push_back(vhandle[1]);
323 mesh_.add_face(face_vhandles);
325 face_vhandles.clear();
327 face_vhandles.push_back(vhandle[2]);
328 face_vhandles.push_back(vhandle[1]);
329 face_vhandles.push_back(vhandle[4]);
330 mesh_.add_face(face_vhandles);
342 int indices[5] = {4, 2, 0, 3, 4};
344 std::reverse_copy(indices,indices+5,rev_indices);
349 Mesh::VertexVertexCCWIter vv_ccwit = mesh_.vv_ccwbegin(vh);
350 Mesh::VertexVertexCCWIter vv_ccwend = mesh_.vv_ccwend(vh);
352 for (;vv_ccwit != vv_ccwend; ++vv_ccwit, ++i)
354 EXPECT_EQ(indices[i], vv_ccwit->idx()) <<
"Index wrong in VertexVertexCCWIter";
357 EXPECT_FALSE(vv_ccwit.is_valid()) <<
"Iterator invalid in VertexVertexCCWIter at end";
358 EXPECT_TRUE( vv_ccwit == vv_ccwend ) <<
"End iterator for VertexVertexCCWIter not matching";
361 Mesh::ConstVertexVertexCCWIter cvv_ccwit = mesh_.cvv_ccwbegin(vh);
362 Mesh::ConstVertexVertexCCWIter cvv_ccwend = mesh_.cvv_ccwend(vh);
364 for (;cvv_ccwit != cvv_ccwend; ++cvv_ccwit, ++i)
366 EXPECT_EQ(indices[i], cvv_ccwit->idx()) <<
"Index wrong in ConstVertexVertexCCWIter";
369 EXPECT_FALSE(cvv_ccwit.is_valid()) <<
"Iterator invalid in ConstVertexVertexCCWIter at end";
370 EXPECT_TRUE( cvv_ccwit == cvv_ccwend ) <<
"End iterator for ConstVertexVertexCCWIter not matching";
373 Mesh::VertexVertexCWIter vv_cwit = mesh_.vv_cwbegin(vh);
374 Mesh::VertexVertexCWIter vv_cwend = mesh_.vv_cwend(vh);
376 for (;vv_cwit != vv_cwend; ++vv_cwit, ++i)
378 EXPECT_EQ(rev_indices[i], vv_cwit->idx()) <<
"Index wrong in VertexVertexCWIter";
380 EXPECT_FALSE(vv_cwit.is_valid()) <<
"Iterator invalid in VertexVertexCWIter at end";
381 EXPECT_TRUE( vv_cwit == vv_cwend ) <<
"End iterator for VertexVertexCWIter not matching";
384 Mesh::ConstVertexVertexCWIter cvv_cwit = mesh_.cvv_cwbegin(vh);
385 Mesh::ConstVertexVertexCWIter cvv_cwend = mesh_.cvv_cwend(vh);
387 for (;cvv_cwit != cvv_cwend; ++cvv_cwit, ++i)
389 EXPECT_EQ(rev_indices[i], cvv_cwit->idx()) <<
"Index wrong in ConstVertexVertexCWIter";
391 EXPECT_FALSE(cvv_cwit.is_valid()) <<
"Iterator invalid in ConstVertexVertexCWIter at end";
392 EXPECT_TRUE( cvv_cwit == cvv_cwend ) <<
"End iterator for ConstVertexVertexCWIter not matching";
401 Mesh::VertexVertexCWIter vv_cwIter = mesh_.vv_cwbegin(vh);
403 EXPECT_TRUE( vv_cwIter == Mesh::VertexVertexCWIter(mesh_.vv_ccwbegin(vh)) ) <<
"ccw to cw convvrsion failed";
404 EXPECT_TRUE( Mesh::VertexVertexCCWIter(vv_cwIter) == mesh_.vv_ccwbegin(vh) ) <<
"cw to ccw convvrsion failed";
406 EXPECT_EQ( vv_cwIter->idx(), Mesh::VertexVertexCCWIter(vv_cwIter)->idx()) <<
"iterators doesnt point on the same element";
409 vv_ccwend = mesh_.vv_ccwend(vh);
411 EXPECT_EQ(vv_cwIter->idx(),vv_ccwend->idx()) <<
"iteratoes are not equal after inc/dec";
413 vv_ccwend = Mesh::VertexVertexCCWIter(vv_cwIter);
414 EXPECT_EQ(vv_cwIter->idx(),vv_ccwend->idx())<<
"iterators doesnt point on the same element";
416 vv_cwIter = Mesh::VertexVertexCWIter(mesh_.vv_ccwend(vh));
417 EXPECT_FALSE(vv_cwIter.is_valid()) <<
"end iterator is not invalid";
418 EXPECT_TRUE(Mesh::VertexVertexCCWIter(mesh_.vv_cwend(vh)) == mesh_.vv_ccwend(vh)) <<
"end iterators are not equal";
Kernel::VertexVertexIter VertexVertexIter
Circulator.
Kernel::Point Point
Coordinate type.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.