1 #include <gtest/gtest.h> 2 #include <Unittests/unittests_common.hh> 8 class OpenMeshTrimeshCirculatorFaceVertex :
public OpenMeshBase {
13 virtual void SetUp() {
17 virtual void TearDown() {
38 TEST_F(OpenMeshTrimeshCirculatorFaceVertex, FaceVertexIterWithoutIncrement) {
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::FaceHandle fh0 = 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);
91 EXPECT_EQ(0, fh0.idx() ) <<
"Index wrong in FaceVertexIter at initialization";
96 EXPECT_EQ(0, fv_it->idx() ) <<
"Index wrong in FaceVertexIter at initialization";
97 EXPECT_TRUE(fv_it.is_valid()) <<
"Iterator invalid in FaceVertexIter at initialization";
99 EXPECT_EQ(1, fv_it->idx() ) <<
"Index wrong in FaceVertexIter at step 1";
100 EXPECT_TRUE(fv_it.is_valid()) <<
"Iterator invalid in FaceVertexIter at step 1";
102 EXPECT_EQ(2, fv_it->idx() ) <<
"Index wrong in FaceVertexIter at step 2";
103 EXPECT_TRUE(fv_it.is_valid()) <<
"Iterator invalid in FaceVertexIter at step 2";
105 EXPECT_EQ(0, fv_it->idx() ) <<
"Index wrong in FaceVertexIter at step 3";
106 EXPECT_FALSE(fv_it.is_valid()) <<
"Iterator invalid in FaceVertexIter at step 3";
107 EXPECT_TRUE( fv_it == fv_end ) <<
"End iterator for FaceVertexIter not matching";
112 EXPECT_EQ(0, cfv_it->idx() ) <<
"Index wrong in ConstFaceVertexIter at initialization";
113 EXPECT_TRUE(cfv_it.is_valid()) <<
"Iterator invalid in ConstFaceVertexIter at initialization";
115 EXPECT_EQ(1, cfv_it->idx() ) <<
"Index wrong in ConstFaceVertexIter at step 1";
116 EXPECT_TRUE(cfv_it.is_valid()) <<
"Iterator invalid in ConstFaceVertexIter at step 1";
118 EXPECT_EQ(2, cfv_it->idx() ) <<
"Index wrong in ConstFaceVertexIter at step 2";
119 EXPECT_TRUE(cfv_it.is_valid()) <<
"Iterator invalid in ConstFaceVertexIter at step 2";
121 EXPECT_EQ(0, cfv_it->idx() ) <<
"Index wrong in ConstFaceVertexIter at step 3";
122 EXPECT_FALSE(cfv_it.is_valid()) <<
"Iterator invalid in ConstFaceVertexIter at step 3";
123 EXPECT_TRUE( cfv_it == cfv_end ) <<
"End iterator for ConstFaceVertexIter not matching";
212 TEST_F(OpenMeshTrimeshCirculatorFaceVertex, CWAndCCWCheck) {
226 std::vector<Mesh::VertexHandle> face_vhandles;
228 face_vhandles.push_back(vhandle[0]);
229 face_vhandles.push_back(vhandle[1]);
230 face_vhandles.push_back(vhandle[2]);
231 Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles);
233 face_vhandles.clear();
235 face_vhandles.push_back(vhandle[1]);
236 face_vhandles.push_back(vhandle[3]);
237 face_vhandles.push_back(vhandle[4]);
238 mesh_.add_face(face_vhandles);
240 face_vhandles.clear();
242 face_vhandles.push_back(vhandle[0]);
243 face_vhandles.push_back(vhandle[3]);
244 face_vhandles.push_back(vhandle[1]);
245 mesh_.add_face(face_vhandles);
247 face_vhandles.clear();
249 face_vhandles.push_back(vhandle[2]);
250 face_vhandles.push_back(vhandle[1]);
251 face_vhandles.push_back(vhandle[4]);
252 mesh_.add_face(face_vhandles);
264 int indices[4] = {0, 1, 2, 0};
266 std::reverse_copy(indices,indices+4,rev_indices);
269 Mesh::FaceVertexCCWIter fv_ccwit = mesh_.fv_ccwbegin(fh0);
270 Mesh::FaceVertexCCWIter fv_ccwend = mesh_.fv_ccwend(fh0);
272 for (;fv_ccwit != fv_ccwend; ++fv_ccwit, ++i)
274 EXPECT_EQ(indices[i], fv_ccwit->idx()) <<
"Index wrong in FaceVertexCCWIter";
277 EXPECT_FALSE(fv_ccwit.is_valid()) <<
"Iterator invalid in FaceVertexCCWIter at end";
278 EXPECT_TRUE( fv_ccwit == fv_ccwend ) <<
"End iterator for FaceVertexCCWIter not matching";
281 Mesh::ConstFaceVertexCCWIter cfv_ccwit = mesh_.cfv_ccwbegin(fh0);
282 Mesh::ConstFaceVertexCCWIter cfv_ccwend = mesh_.cfv_ccwend(fh0);
284 for (;cfv_ccwit != cfv_ccwend; ++cfv_ccwit, ++i)
286 EXPECT_EQ(indices[i], cfv_ccwit->idx()) <<
"Index wrong in ConstFaceVertexCCWIter";
289 EXPECT_FALSE(cfv_ccwit.is_valid()) <<
"Iterator invalid in ConstFaceVertexCCWIter at end";
290 EXPECT_TRUE( cfv_ccwit == cfv_ccwend ) <<
"End iterator for ConstFaceVertexCCWIter not matching";
293 Mesh::FaceVertexCWIter fv_cwit = mesh_.fv_cwbegin(fh0);
294 Mesh::FaceVertexCWIter fv_cwend = mesh_.fv_cwend(fh0);
296 for (;fv_cwit != fv_cwend; ++fv_cwit, ++i)
298 EXPECT_EQ(rev_indices[i], fv_cwit->idx()) <<
"Index wrong in FaceVertexCWIter";
300 EXPECT_FALSE(fv_cwit.is_valid()) <<
"Iterator invalid in FaceVertexCWIter at end";
301 EXPECT_TRUE( fv_cwit == fv_cwend ) <<
"End iterator for FaceVertexCWIter not matching";
304 Mesh::ConstFaceVertexCWIter cfv_cwit = mesh_.cfv_cwbegin(fh0);
305 Mesh::ConstFaceVertexCWIter cfv_cwend = mesh_.cfv_cwend(fh0);
307 for (;cfv_cwit != cfv_cwend; ++cfv_cwit, ++i)
309 EXPECT_EQ(rev_indices[i], cfv_cwit->idx()) <<
"Index wrong in ConstFaceVertexCWIter";
311 EXPECT_FALSE(cfv_cwit.is_valid()) <<
"Iterator invalid in ConstFaceVertexCWIter at end";
312 EXPECT_TRUE( cfv_cwit == cfv_cwend ) <<
"End iterator for ConstFaceVertexCWIter not matching";
321 Mesh::FaceVertexCWIter fv_cwIter = mesh_.fv_cwbegin(mesh_.face_handle(1));
323 EXPECT_TRUE( fv_cwIter == Mesh::FaceVertexCWIter(mesh_.fv_ccwbegin(mesh_.face_handle(1))) ) <<
"ccw to cw conversion failed";
324 EXPECT_TRUE( Mesh::FaceVertexCCWIter(fv_cwIter) == mesh_.fv_ccwbegin(mesh_.face_handle(1)) ) <<
"cw to ccw conversion failed";
326 EXPECT_EQ( fv_cwIter->idx(), Mesh::FaceVertexCCWIter(fv_cwIter)->idx()) <<
"iterators doesnt point on the same element";
329 fv_ccwend = mesh_.fv_ccwend(mesh_.face_handle(1));
331 EXPECT_EQ(fv_cwIter->idx(),fv_ccwend->idx()) <<
"iteratoes are not equal after inc/dec";
333 fv_ccwend = Mesh::FaceVertexCCWIter(fv_cwIter);
334 EXPECT_EQ(fv_cwIter->idx(),fv_ccwend->idx())<<
"iterators doesnt point on the same element";
336 fv_cwIter = Mesh::FaceVertexCWIter(mesh_.fv_ccwend(mesh_.face_handle(1)));
337 EXPECT_FALSE(fv_cwIter.is_valid()) <<
"end iterator is not invalid";
338 EXPECT_TRUE(Mesh::FaceVertexCCWIter(mesh_.fv_cwend(mesh_.face_handle(1))) == mesh_.fv_ccwend(mesh_.face_handle(1))) <<
"end iterators are not equal";
Kernel::FaceVertexIter FaceVertexIter
Circulator.
Kernel::ConstFaceVertexIter ConstFaceVertexIter
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.