1 #include <gtest/gtest.h>
2 #include <Unittests/unittests_common.hh>
9 class OpenMeshTrimeshCirculatorFaceFace :
public OpenMeshBase {
14 virtual void SetUp() {
18 virtual void TearDown() {
39 TEST_F(OpenMeshTrimeshCirculatorFaceFace, FaceFaceIterWithHoles) {
53 std::vector<Mesh::VertexHandle> face_vhandles;
55 face_vhandles.push_back(vhandle[0]);
56 face_vhandles.push_back(vhandle[1]);
57 face_vhandles.push_back(vhandle[2]);
58 mesh_.add_face(face_vhandles);
60 face_vhandles.clear();
62 face_vhandles.push_back(vhandle[2]);
63 face_vhandles.push_back(vhandle[1]);
64 face_vhandles.push_back(vhandle[3]);
65 mesh_.add_face(face_vhandles);
67 face_vhandles.clear();
69 face_vhandles.push_back(vhandle[2]);
70 face_vhandles.push_back(vhandle[3]);
71 face_vhandles.push_back(vhandle[4]);
72 mesh_.add_face(face_vhandles);
87 EXPECT_EQ(2, ff_it->idx() ) <<
"Index wrong in FaceFaceIter at initialization";
88 EXPECT_TRUE(ff_it.is_valid()) <<
"Iterator invalid in FaceFaceIter at initialization";
90 EXPECT_EQ(0, ff_it->idx() ) <<
"Index wrong in FaceFaceIter at step 1";
91 EXPECT_TRUE(ff_it.is_valid()) <<
"Iterator invalid in FaceFaceIter at step 1";
93 EXPECT_EQ(2, ff_it->idx() ) <<
"Index wrong in FaceFaceIter at end";
94 EXPECT_FALSE(ff_it.is_valid()) <<
"Iterator invalid in FaceFaceIter at end";
95 EXPECT_TRUE( ff_it == ff_end ) <<
"End iterator for FaceFaceIter not matching";
100 EXPECT_EQ(2, cff_it->idx() ) <<
"Index wrong in ConstFaceFaceIter at initialization";
101 EXPECT_TRUE(cff_it.is_valid()) <<
"Iterator invalid in ConstFaceFaceIter at initialization";
103 EXPECT_EQ(0, cff_it->idx() ) <<
"Index wrong in ConstFaceFaceIter at step 1";
104 EXPECT_TRUE(cff_it.is_valid()) <<
"Iterator invalid in ConstFaceFaceIter at step 1";
106 EXPECT_EQ(2, cff_it->idx() ) <<
"Index wrong in ConstFaceFaceIter at end";
107 EXPECT_FALSE(cff_it.is_valid()) <<
"Iterator invalid in ConstFaceFaceIter at end";
108 EXPECT_TRUE( cff_it == cff_end ) <<
"End iterator for ConstFaceFaceIter not matching";
117 TEST_F(OpenMeshTrimeshCirculatorFaceFace, FaceFaceIterWithoutHoles) {
132 std::vector<Mesh::VertexHandle> face_vhandles;
134 face_vhandles.push_back(vhandle[0]);
135 face_vhandles.push_back(vhandle[1]);
136 face_vhandles.push_back(vhandle[2]);
137 mesh_.add_face(face_vhandles);
139 face_vhandles.clear();
141 face_vhandles.push_back(vhandle[2]);
142 face_vhandles.push_back(vhandle[1]);
143 face_vhandles.push_back(vhandle[3]);
144 mesh_.add_face(face_vhandles);
146 face_vhandles.clear();
148 face_vhandles.push_back(vhandle[2]);
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[1]);
156 face_vhandles.push_back(vhandle[5]);
157 face_vhandles.push_back(vhandle[3]);
158 mesh_.add_face(face_vhandles);
178 EXPECT_EQ(2, ff_it->idx() ) <<
"Index wrong in FaceFaceIter at initialization";
179 EXPECT_TRUE(ff_it.is_valid()) <<
"Iterator invalid in FaceFaceIter at initialization";
181 EXPECT_EQ(0, ff_it->idx() ) <<
"Index wrong in FaceFaceIter at step 1";
182 EXPECT_TRUE(ff_it.is_valid()) <<
"Iterator invalid in FaceFaceIter at step 1";
184 EXPECT_EQ(3, ff_it->idx() ) <<
"Index wrong in FaceFaceIter at step 2";
185 EXPECT_TRUE(ff_it.is_valid()) <<
"Iterator invalid in FaceFaceIter at step 2";
187 EXPECT_EQ(2, ff_it->idx() ) <<
"Index wrong in FaceFaceIter at end";
188 EXPECT_FALSE(ff_it.is_valid()) <<
"Iterator invalid in FaceFaceIter at end";
189 EXPECT_TRUE( ff_it == ff_end ) <<
"End iterator for FaceFaceIter not matching";
194 EXPECT_EQ(2, cff_it->idx() ) <<
"Index wrong in ConstFaceFaceIter at initialization";
195 EXPECT_TRUE(cff_it.is_valid()) <<
"Iterator invalid in ConstFaceFaceIter at initialization";
197 EXPECT_EQ(0, cff_it->idx() ) <<
"Index wrong in ConstFaceFaceIter at step 1";
198 EXPECT_TRUE(cff_it.is_valid()) <<
"Iterator invalid in ConstFaceFaceIter at step 1";
200 EXPECT_EQ(3, cff_it->idx() ) <<
"Index wrong in ConstFaceFaceIter at step 2";
201 EXPECT_TRUE(cff_it.is_valid()) <<
"Iterator invalid in ConstFaceFaceIter at step 2";
203 EXPECT_EQ(2, cff_it->idx() ) <<
"Index wrong in ConstFaceFaceIter at end";
204 EXPECT_FALSE(cff_it.is_valid()) <<
"Iterator invalid in ConstFaceFaceIter at end";
205 EXPECT_TRUE( cff_it == cff_end ) <<
"End iterator for ConstFaceFaceIter not matching";
212 TEST_F(OpenMeshTrimeshCirculatorFaceFace, CWAndCCWCheck) {
227 std::vector<Mesh::VertexHandle> face_vhandles;
229 face_vhandles.push_back(vhandle[0]);
230 face_vhandles.push_back(vhandle[1]);
231 face_vhandles.push_back(vhandle[2]);
232 mesh_.add_face(face_vhandles);
234 face_vhandles.clear();
236 face_vhandles.push_back(vhandle[2]);
237 face_vhandles.push_back(vhandle[1]);
238 face_vhandles.push_back(vhandle[3]);
239 mesh_.add_face(face_vhandles);
241 face_vhandles.clear();
243 face_vhandles.push_back(vhandle[2]);
244 face_vhandles.push_back(vhandle[3]);
245 face_vhandles.push_back(vhandle[4]);
246 mesh_.add_face(face_vhandles);
248 face_vhandles.clear();
250 face_vhandles.push_back(vhandle[1]);
251 face_vhandles.push_back(vhandle[5]);
252 face_vhandles.push_back(vhandle[3]);
253 mesh_.add_face(face_vhandles);
270 int indices[4] = {2, 0, 3, 2};
272 std::reverse_copy(indices,indices+4,rev_indices);
275 Mesh::FaceFaceCCWIter ff_ccwit = mesh_.ff_ccwbegin(mesh_.face_handle(1));
276 Mesh::FaceFaceCCWIter ff_ccwend = mesh_.ff_ccwend(mesh_.face_handle(1));
278 for (;ff_ccwit != ff_ccwend; ++ff_ccwit, ++i)
280 EXPECT_EQ(indices[i], ff_ccwit->idx()) <<
"Index wrong in FaceFaceCCWIter";
283 EXPECT_FALSE(ff_ccwit.is_valid()) <<
"Iterator invalid in FaceFaceCCWIter at end";
284 EXPECT_TRUE( ff_ccwit == ff_ccwend ) <<
"End iterator for FaceFaceCCWIter not matching";
287 Mesh::ConstFaceFaceCCWIter cff_ccwit = mesh_.cff_ccwbegin(mesh_.face_handle(1));
288 Mesh::ConstFaceFaceCCWIter cff_ccwend = mesh_.cff_ccwend(mesh_.face_handle(1));
290 for (;cff_ccwit != cff_ccwend; ++cff_ccwit, ++i)
292 EXPECT_EQ(indices[i], cff_ccwit->idx()) <<
"Index wrong in ConstFaceFaceCCWIter";
295 EXPECT_FALSE(cff_ccwit.is_valid()) <<
"Iterator invalid in ConstFaceFaceCCWIter at end";
296 EXPECT_TRUE( cff_ccwit == cff_ccwend ) <<
"End iterator for ConstFaceFaceCCWIter not matching";
299 Mesh::FaceFaceCWIter ff_cwit = mesh_.ff_cwbegin(mesh_.face_handle(1));
300 Mesh::FaceFaceCWIter ff_cwend = mesh_.ff_cwend(mesh_.face_handle(1));
302 for (;ff_cwit != ff_cwend; ++ff_cwit, ++i)
304 EXPECT_EQ(rev_indices[i], ff_cwit->idx()) <<
"Index wrong in FaceFaceCWIter";
306 EXPECT_FALSE(ff_cwit.is_valid()) <<
"Iterator invalid in FaceFaceCWIter at end";
307 EXPECT_TRUE( ff_cwit == ff_cwend ) <<
"End iterator for FaceFaceCWIter not matching";
310 Mesh::ConstFaceFaceCWIter cff_cwit = mesh_.cff_cwbegin(mesh_.face_handle(1));
311 Mesh::ConstFaceFaceCWIter cff_cwend = mesh_.cff_cwend(mesh_.face_handle(1));
313 for (;cff_cwit != cff_cwend; ++cff_cwit, ++i)
315 EXPECT_EQ(rev_indices[i], cff_cwit->idx()) <<
"Index wrong in ConstFaceFaceCWIter";
317 EXPECT_FALSE(cff_cwit.is_valid()) <<
"Iterator invalid in ConstFaceFaceCWIter at end";
318 EXPECT_TRUE( cff_cwit == cff_cwend ) <<
"End iterator for ConstFaceFaceCWIter not matching";
327 Mesh::FaceFaceCWIter ff_cwIter = mesh_.ff_cwbegin(mesh_.face_handle(1));
329 EXPECT_TRUE( ff_cwIter == Mesh::FaceFaceCWIter(mesh_.ff_ccwbegin(mesh_.face_handle(1))) ) <<
"ccw to cw conversion failed";
330 EXPECT_TRUE( Mesh::FaceFaceCCWIter(ff_cwIter) == mesh_.ff_ccwbegin(mesh_.face_handle(1)) ) <<
"cw to ccw conversion failed";
332 EXPECT_EQ( ff_cwIter->idx(), Mesh::FaceFaceCCWIter(ff_cwIter)->idx()) <<
"iterators doesnt point on the same element";
335 ff_ccwend = mesh_.ff_ccwend(mesh_.face_handle(1));
337 EXPECT_EQ(ff_cwIter->idx(),ff_ccwend->idx()) <<
"iteratoes are not equal after inc/dec";
339 ff_ccwend = Mesh::FaceFaceCCWIter(ff_cwIter);
340 EXPECT_EQ(ff_cwIter->idx(),ff_ccwend->idx())<<
"iterators doesnt point on the same element";
342 ff_cwIter = Mesh::FaceFaceCWIter(mesh_.ff_ccwend(mesh_.face_handle(1)));
343 EXPECT_FALSE(ff_cwIter.is_valid()) <<
"end iterator is not invalid";
344 EXPECT_TRUE(Mesh::FaceFaceCCWIter(mesh_.ff_cwend(mesh_.face_handle(1))) == mesh_.ff_ccwend(mesh_.face_handle(1))) <<
"end iterators are not equal";
354 TEST_F(OpenMeshTrimeshCirculatorFaceFace, FaceFaceIteratorHandleConversion) {
368 std::vector<Mesh::VertexHandle> face_vhandles;
370 face_vhandles.push_back(vhandle[0]);
371 face_vhandles.push_back(vhandle[2]);
372 face_vhandles.push_back(vhandle[1]);
373 Mesh::FaceHandle fh1 = mesh_.add_face(face_vhandles);
375 face_vhandles.clear();
377 face_vhandles.push_back(vhandle[0]);
378 face_vhandles.push_back(vhandle[3]);
379 face_vhandles.push_back(vhandle[2]);
380 mesh_.add_face(face_vhandles);
382 face_vhandles.clear();
393 EXPECT_EQ(4u , mesh_.n_vertices() ) <<
"Wrong number of vertices";
394 EXPECT_EQ(2u , mesh_.n_faces() ) <<
"Wrong number of faces";
401 Mesh::FaceHandle faceHandle1 = *face_iter;
403 EXPECT_EQ(1, faceHandle1.idx() ) <<
"Wrong face handle index when getting from iterator via handle";
Kernel::Point Point
Coordinate type.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Kernel::FaceFaceIter FaceFaceIter
Circulator.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Kernel::ConstFaceFaceIter ConstFaceFaceIter
Circulator.