1 #include <gtest/gtest.h> 2 #include <Unittests/unittests_common.hh> 8 class OpenMeshTrimeshCirculatorVertexEdge :
public OpenMeshBase {
13 virtual void SetUp() {
17 virtual void TearDown() {
38 TEST_F(OpenMeshTrimeshCirculatorVertexEdge, VertexEdgeIterWithoutHolesIncrement) {
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);
92 EXPECT_EQ(5, ve_it->idx() ) <<
"Index wrong in VertexEdgeIter at initialization";
93 EXPECT_TRUE(ve_it.is_valid()) <<
"Iterator invalid in VertexEdgeIter at initialization";
95 EXPECT_EQ(3, ve_it->idx() ) <<
"Index wrong in VertexEdgeIter at step 1";
96 EXPECT_TRUE(ve_it.is_valid()) <<
"Iterator invalid in VertexEdgeIter at step 1";
98 EXPECT_EQ(0, ve_it->idx() ) <<
"Index wrong in VertexEdgeIter at step 2";
99 EXPECT_TRUE(ve_it.is_valid()) <<
"Iterator invalid in VertexEdgeIter at step 2";
101 EXPECT_EQ(1, ve_it->idx() ) <<
"Index wrong in VertexEdgeIter at step 3";
102 EXPECT_TRUE(ve_it.is_valid()) <<
"Iterator invalid in VertexEdgeIter at step 3";
104 EXPECT_EQ(5, ve_it->idx() ) <<
"Index wrong in VertexEdgeIter at end";
105 EXPECT_FALSE(ve_it.is_valid()) <<
"Iterator not invalid in VertexEdgeIter at end";
106 EXPECT_TRUE( ve_it == ve_end ) <<
"End iterator for VertexEdgeIter not matching";
111 EXPECT_EQ(5, cve_it->idx() ) <<
"Index wrong in ConstVertexEdgeIter at initialization";
112 EXPECT_TRUE(cve_it.is_valid()) <<
"Iterator invalid in ConstVertexEdgeIter at initialization";
114 EXPECT_EQ(3, cve_it->idx() ) <<
"Index wrong in ConstVertexEdgeIter at step 1";
115 EXPECT_TRUE(cve_it.is_valid()) <<
"Iterator invalid in ConstVertexEdgeIter at step 1";
117 EXPECT_EQ(0, cve_it->idx() ) <<
"Index wrong in ConstVertexEdgeIter at step 2";
118 EXPECT_TRUE(cve_it.is_valid()) <<
"Iterator invalid in ConstVertexEdgeIter at step 2";
120 EXPECT_EQ(1, cve_it->idx() ) <<
"Index wrong in ConstVertexEdgeIter at step 3";
121 EXPECT_TRUE(cve_it.is_valid()) <<
"Iterator invalid in ConstVertexEdgeIter at step 3";
123 EXPECT_EQ(5, cve_it->idx() ) <<
"Index wrong in ConstVertexEdgeIter at end";
124 EXPECT_FALSE(cve_it.is_valid()) <<
"Iterator not invalid in VertexEdgeIter at end";
125 EXPECT_TRUE( cve_it == cve_end ) <<
"End iterator for ConstVertexEdgeIter not matching";
131 TEST_F(OpenMeshTrimeshCirculatorVertexEdge, VertexEdgeIterBoundaryIncrement) {
145 std::vector<Mesh::VertexHandle> face_vhandles;
147 face_vhandles.push_back(vhandle[0]);
148 face_vhandles.push_back(vhandle[1]);
149 face_vhandles.push_back(vhandle[2]);
150 mesh_.add_face(face_vhandles);
152 face_vhandles.clear();
154 face_vhandles.push_back(vhandle[1]);
155 face_vhandles.push_back(vhandle[3]);
156 face_vhandles.push_back(vhandle[4]);
157 mesh_.add_face(face_vhandles);
159 face_vhandles.clear();
161 face_vhandles.push_back(vhandle[0]);
162 face_vhandles.push_back(vhandle[3]);
163 face_vhandles.push_back(vhandle[1]);
164 mesh_.add_face(face_vhandles);
166 face_vhandles.clear();
168 face_vhandles.push_back(vhandle[2]);
169 face_vhandles.push_back(vhandle[1]);
170 face_vhandles.push_back(vhandle[4]);
171 mesh_.add_face(face_vhandles);
185 EXPECT_EQ(7, ve_it->idx() ) <<
"Index wrong in VertexEdgeIter at initialization";
186 EXPECT_TRUE(ve_it.is_valid()) <<
"Iterator invalid in VertexEdgeIter at initialization";
188 EXPECT_EQ(1, ve_it->idx() ) <<
"Index wrong in VertexEdgeIter at step 1";
189 EXPECT_TRUE(ve_it.is_valid()) <<
"Iterator invalid in VertexEdgeIter at step 1";
191 EXPECT_EQ(2, ve_it->idx() ) <<
"Index wrong in VertexEdgeIter at step 2";
192 EXPECT_TRUE(ve_it.is_valid()) <<
"Iterator invalid in VertexEdgeIter at step 2";
194 EXPECT_EQ(7, ve_it->idx() ) <<
"Index wrong in VertexEdgeIter at step 3";
195 EXPECT_FALSE(ve_it.is_valid()) <<
"Iterator not invalid in VertexEdgeIter at end";
196 EXPECT_TRUE( ve_it == ve_end ) <<
"End iterator for VertexEdgeIter not matching";
287 TEST_F(OpenMeshTrimeshCirculatorVertexEdge, CWAndCCWCheck) {
301 std::vector<Mesh::VertexHandle> face_vhandles;
303 face_vhandles.push_back(vhandle[0]);
304 face_vhandles.push_back(vhandle[1]);
305 face_vhandles.push_back(vhandle[2]);
306 mesh_.add_face(face_vhandles);
308 face_vhandles.clear();
310 face_vhandles.push_back(vhandle[1]);
311 face_vhandles.push_back(vhandle[3]);
312 face_vhandles.push_back(vhandle[4]);
313 mesh_.add_face(face_vhandles);
315 face_vhandles.clear();
317 face_vhandles.push_back(vhandle[0]);
318 face_vhandles.push_back(vhandle[3]);
319 face_vhandles.push_back(vhandle[1]);
320 mesh_.add_face(face_vhandles);
322 face_vhandles.clear();
324 face_vhandles.push_back(vhandle[2]);
325 face_vhandles.push_back(vhandle[1]);
326 face_vhandles.push_back(vhandle[4]);
327 mesh_.add_face(face_vhandles);
339 int indices[5] = {5, 1, 0, 3, 5};
341 std::reverse_copy(indices,indices+5,rev_indices);
346 Mesh::VertexEdgeCCWIter ve_ccwit = mesh_.ve_ccwbegin(vh);
347 Mesh::VertexEdgeCCWIter ve_ccwend = mesh_.ve_ccwend(vh);
349 for (;ve_ccwit != ve_ccwend; ++ve_ccwit, ++i)
351 EXPECT_EQ(indices[i], ve_ccwit->idx()) <<
"Index wrong in VertexEdgeCCWIter";
354 EXPECT_FALSE(ve_ccwit.is_valid()) <<
"Iterator invalid in VertexEdgeCCWIter at end";
355 EXPECT_TRUE( ve_ccwit == ve_ccwend ) <<
"End iterator for VertexEdgeCCWIter not matching";
358 Mesh::ConstVertexEdgeCCWIter cve_ccwit = mesh_.cve_ccwbegin(vh);
359 Mesh::ConstVertexEdgeCCWIter cve_ccwend = mesh_.cve_ccwend(vh);
361 for (;cve_ccwit != cve_ccwend; ++cve_ccwit, ++i)
363 EXPECT_EQ(indices[i], cve_ccwit->idx()) <<
"Index wrong in ConstVertexEdgeCCWIter";
366 EXPECT_FALSE(cve_ccwit.is_valid()) <<
"Iterator invalid in ConstVertexEdgeCCWIter at end";
367 EXPECT_TRUE( cve_ccwit == cve_ccwend ) <<
"End iterator for ConstVertexEdgeCCWIter not matching";
370 Mesh::VertexEdgeCWIter ve_cwit = mesh_.ve_cwbegin(vh);
371 Mesh::VertexEdgeCWIter ve_cwend = mesh_.ve_cwend(vh);
373 for (;ve_cwit != ve_cwend; ++ve_cwit, ++i)
375 EXPECT_EQ(rev_indices[i], ve_cwit->idx()) <<
"Index wrong in VertexEdgeCWIter";
377 EXPECT_FALSE(ve_cwit.is_valid()) <<
"Iterator invalid in VertexEdgeCWIter at end";
378 EXPECT_TRUE( ve_cwit == ve_cwend ) <<
"End iterator for VertexEdgeCWIter not matching";
381 Mesh::ConstVertexEdgeCWIter cve_cwit = mesh_.cve_cwbegin(vh);
382 Mesh::ConstVertexEdgeCWIter cve_cwend = mesh_.cve_cwend(vh);
384 for (;cve_cwit != cve_cwend; ++cve_cwit, ++i)
386 EXPECT_EQ(rev_indices[i], cve_cwit->idx()) <<
"Index wrong in ConstVertexEdgeCWIter";
388 EXPECT_FALSE(cve_cwit.is_valid()) <<
"Iterator invalid in ConstVertexEdgeCWIter at end";
389 EXPECT_TRUE( cve_cwit == cve_cwend ) <<
"End iterator for ConstVertexEdgeCWIter not matching";
398 Mesh::VertexEdgeCWIter ve_cwIter = mesh_.ve_cwbegin(vh);
400 EXPECT_TRUE( ve_cwIter == Mesh::VertexEdgeCWIter(mesh_.ve_ccwbegin(vh)) ) <<
"ccw to cw conversion failed";
401 EXPECT_TRUE( Mesh::VertexEdgeCCWIter(ve_cwIter) == mesh_.ve_ccwbegin(vh) ) <<
"cw to ccw conversion failed";
403 EXPECT_EQ( ve_cwIter->idx(), Mesh::VertexEdgeCCWIter(ve_cwIter)->idx()) <<
"iterators doesnt point on the same element";
406 ve_ccwend = mesh_.ve_ccwend(vh);
408 EXPECT_EQ(ve_cwIter->idx(),ve_ccwend->idx()) <<
"iteratoes are not equal after inc/dec";
410 ve_ccwend = Mesh::VertexEdgeCCWIter(ve_cwIter);
411 EXPECT_EQ(ve_cwIter->idx(),ve_ccwend->idx())<<
"iterators doesnt point on the same element";
413 ve_cwIter = Mesh::VertexEdgeCWIter(mesh_.ve_ccwend(vh));
414 EXPECT_FALSE(ve_cwIter.is_valid()) <<
"end iterator is not invalid";
415 EXPECT_TRUE(Mesh::VertexEdgeCCWIter(mesh_.ve_cwend(vh)) == mesh_.ve_ccwend(vh)) <<
"end iterators are not equal";
Kernel::ConstVertexEdgeIter ConstVertexEdgeIter
Circulator.
Kernel::VertexEdgeIter VertexEdgeIter
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.