1 #include <gtest/gtest.h>
2 #include <Unittests/unittests_common.hh>
9 class OpenMeshTrimeshCirculatorVertexFace :
public OpenMeshBase {
14 virtual void SetUp() {
18 virtual void TearDown() {
41 TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterWithHolesIncrement) {
55 std::vector<Mesh::VertexHandle> face_vhandles;
57 face_vhandles.push_back(vhandle[0]);
58 face_vhandles.push_back(vhandle[1]);
59 face_vhandles.push_back(vhandle[2]);
60 mesh_.add_face(face_vhandles);
62 face_vhandles.clear();
64 face_vhandles.push_back(vhandle[1]);
65 face_vhandles.push_back(vhandle[3]);
66 face_vhandles.push_back(vhandle[4]);
67 mesh_.add_face(face_vhandles);
81 EXPECT_EQ(0, vf_it->idx() ) <<
"Index wrong in VertexFaceIter at initialization";
82 EXPECT_TRUE(vf_it.is_valid()) <<
"Iterator invalid in VertexFaceIter at initialization";
84 EXPECT_EQ(1, vf_it->idx() ) <<
"Index wrong in VertexFaceIter at step 1";
85 EXPECT_TRUE(vf_it.is_valid()) <<
"Iterator invalid in VertexFaceIter at step 1";
87 EXPECT_FALSE(vf_it.is_valid() ) <<
"Index wrong in VertexFaceIter at end";
88 EXPECT_FALSE(vf_it.is_valid()) <<
"Iterator not invalid in VertexFaceIter at end";
89 EXPECT_TRUE( vf_it == vf_end ) <<
"End iterator for VertexFaceIter not matching";
94 EXPECT_EQ(0, cvf_it->idx() ) <<
"Index wrong in ConstVertexFaceIter at initialization";
95 EXPECT_TRUE(cvf_it.is_valid()) <<
"Iterator invalid in ConstVertexFaceIter at initialization";
97 EXPECT_EQ(1, cvf_it->idx() ) <<
"Index wrong in ConstVertexFaceIter at step one";
98 EXPECT_TRUE(cvf_it.is_valid()) <<
"Iterator invalid in ConstVertexFaceIter at step one";
100 EXPECT_FALSE(cvf_it.is_valid() ) <<
"Index wrong in ConstVertexFaceIter at end";
101 EXPECT_FALSE(cvf_it.is_valid()) <<
"Iterator not invalid in ConstVertexFaceIter at end";
102 EXPECT_TRUE( cvf_it == cvf_end ) <<
"End iterator for ConstVertexFaceIter not matching";
111 TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterWithoutHolesIncrement) {
125 std::vector<Mesh::VertexHandle> face_vhandles;
127 face_vhandles.push_back(vhandle[0]);
128 face_vhandles.push_back(vhandle[1]);
129 face_vhandles.push_back(vhandle[2]);
130 mesh_.add_face(face_vhandles);
132 face_vhandles.clear();
134 face_vhandles.push_back(vhandle[1]);
135 face_vhandles.push_back(vhandle[3]);
136 face_vhandles.push_back(vhandle[4]);
137 mesh_.add_face(face_vhandles);
139 face_vhandles.clear();
141 face_vhandles.push_back(vhandle[0]);
142 face_vhandles.push_back(vhandle[3]);
143 face_vhandles.push_back(vhandle[1]);
144 mesh_.add_face(face_vhandles);
146 face_vhandles.clear();
148 face_vhandles.push_back(vhandle[2]);
149 face_vhandles.push_back(vhandle[1]);
150 face_vhandles.push_back(vhandle[4]);
151 mesh_.add_face(face_vhandles);
162 mesh_.vf_begin(vhandle[1]);
167 EXPECT_EQ(3, vf_it->idx() ) <<
"Index wrong in VertexFaceIter at initialization";
168 EXPECT_TRUE(vf_it.is_valid()) <<
"Iterator invalid in VertexFaceIter at initialization";
170 EXPECT_EQ(1, vf_it->idx() ) <<
"Index wrong in VertexFaceIter at step 1";
171 EXPECT_TRUE(vf_it.is_valid()) <<
"Iterator invalid in VertexFaceIter at step 1";
173 EXPECT_EQ(2, vf_it->idx() ) <<
"Index wrong in VertexFaceIter at step 2";
174 EXPECT_TRUE(vf_it.is_valid()) <<
"Iterator invalid in VertexFaceIter at step 2";
176 EXPECT_EQ(0, vf_it->idx() ) <<
"Index wrong in VertexFaceIter at step 3";
177 EXPECT_TRUE(vf_it.is_valid()) <<
"Iterator invalid in VertexFaceIter at step 3";
179 EXPECT_FALSE(vf_it.is_valid()) <<
"Iterator not invalid in VertexFaceIter at end";
180 EXPECT_TRUE( vf_it == vf_end ) <<
"End iterator for VertexFaceIter not matching";
185 EXPECT_EQ(3, cvf_it->idx() ) <<
"Index wrong in ConstVertexFaceIter at initialization";
186 EXPECT_TRUE(cvf_it.is_valid()) <<
"Iterator invalid in ConstVertexFaceIter at initialization";
188 EXPECT_EQ(1, cvf_it->idx() ) <<
"Index wrong in ConstVertexFaceIter at step 1";
189 EXPECT_TRUE(cvf_it.is_valid()) <<
"Iterator invalid in ConstVertexFaceIter at step 1";
191 EXPECT_EQ(2, cvf_it->idx() ) <<
"Index wrong in ConstVertexFaceIter at step 2";
192 EXPECT_TRUE(cvf_it.is_valid()) <<
"Iterator invalid in ConstVertexFaceIter at step 2";
194 EXPECT_EQ(0, cvf_it->idx() ) <<
"Index wrong in ConstVertexFaceIter at step 3";
195 EXPECT_TRUE(cvf_it.is_valid()) <<
"Iterator invalid in ConstVertexFaceIter at step 3";
197 EXPECT_FALSE(cvf_it.is_valid()) <<
"Iterator not invalid in VertexFaceIter at end";
198 EXPECT_TRUE( cvf_it == cvf_end ) <<
"End iterator for ConstVertexFaceIter not matching";
206 TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterBoundaryIncrement) {
220 std::vector<Mesh::VertexHandle> face_vhandles;
222 face_vhandles.push_back(vhandle[0]);
223 face_vhandles.push_back(vhandle[1]);
224 face_vhandles.push_back(vhandle[2]);
225 mesh_.add_face(face_vhandles);
227 face_vhandles.clear();
229 face_vhandles.push_back(vhandle[1]);
230 face_vhandles.push_back(vhandle[3]);
231 face_vhandles.push_back(vhandle[4]);
232 mesh_.add_face(face_vhandles);
234 face_vhandles.clear();
236 face_vhandles.push_back(vhandle[0]);
237 face_vhandles.push_back(vhandle[3]);
238 face_vhandles.push_back(vhandle[1]);
239 mesh_.add_face(face_vhandles);
241 face_vhandles.clear();
243 face_vhandles.push_back(vhandle[2]);
244 face_vhandles.push_back(vhandle[1]);
245 face_vhandles.push_back(vhandle[4]);
246 mesh_.add_face(face_vhandles);
260 EXPECT_EQ(3, vf_it->idx() ) <<
"Index wrong in VertexFaceIter at initialization";
261 EXPECT_TRUE(vf_it.is_valid()) <<
"Iterator invalid in VertexFaceIter at initialization";
263 EXPECT_EQ(0, vf_it->idx() ) <<
"Index wrong in VertexFaceIter at step 1";
264 EXPECT_TRUE(vf_it.is_valid()) <<
"Iterator invalid in VertexFaceIter at step 1";
266 EXPECT_FALSE(vf_it.is_valid()) <<
"Iterator invalid in VertexFaceIter at step 2";
267 EXPECT_TRUE( vf_it == vf_end ) <<
"End iterator for VertexFaceIter not matching";
459 TEST_F(OpenMeshTrimeshCirculatorVertexFace, CWAndCCWCheck) {
473 std::vector<Mesh::VertexHandle> face_vhandles;
475 face_vhandles.push_back(vhandle[0]);
476 face_vhandles.push_back(vhandle[1]);
477 face_vhandles.push_back(vhandle[2]);
479 mesh_.add_face(face_vhandles);
481 face_vhandles.clear();
483 face_vhandles.push_back(vhandle[1]);
484 face_vhandles.push_back(vhandle[3]);
485 face_vhandles.push_back(vhandle[4]);
486 mesh_.add_face(face_vhandles);
488 face_vhandles.clear();
490 face_vhandles.push_back(vhandle[0]);
491 face_vhandles.push_back(vhandle[3]);
492 face_vhandles.push_back(vhandle[1]);
493 mesh_.add_face(face_vhandles);
495 face_vhandles.clear();
497 face_vhandles.push_back(vhandle[2]);
498 face_vhandles.push_back(vhandle[1]);
499 face_vhandles.push_back(vhandle[4]);
500 mesh_.add_face(face_vhandles);
512 int indices[5] = {3, 0, 2, 1, 3};
514 std::reverse_copy(indices,indices+5,rev_indices);
519 Mesh::VertexFaceCCWIter vf_ccwit = mesh_.vf_ccwbegin(vh);
520 Mesh::VertexFaceCCWIter vf_ccwend = mesh_.vf_ccwend(vh);
522 for (;vf_ccwit != vf_ccwend; ++vf_ccwit, ++i)
524 EXPECT_EQ(indices[i], vf_ccwit->idx()) <<
"Index wrong in VertexFaceCCWIter";
527 EXPECT_FALSE(vf_ccwit.is_valid()) <<
"Iterator invalid in VertexFaceCCWIter at end";
528 EXPECT_TRUE( vf_ccwit == vf_ccwend ) <<
"End iterator for VertexFaceCCWIter not matching";
531 Mesh::ConstVertexFaceCCWIter cvf_ccwit = mesh_.cvf_ccwbegin(vh);
532 Mesh::ConstVertexFaceCCWIter cvf_ccwend = mesh_.cvf_ccwend(vh);
534 for (;cvf_ccwit != cvf_ccwend; ++cvf_ccwit, ++i)
536 EXPECT_EQ(indices[i], cvf_ccwit->idx()) <<
"Index wrong in ConstVertexFaceCCWIter";
539 EXPECT_FALSE(cvf_ccwit.is_valid()) <<
"Iterator invalid in ConstVertexFaceCCWIter at end";
540 EXPECT_TRUE( cvf_ccwit == cvf_ccwend ) <<
"End iterator for ConstVertexFaceCCWIter not matching";
543 Mesh::VertexFaceCWIter vf_cwit = mesh_.vf_cwbegin(vh);
544 Mesh::VertexFaceCWIter vf_cwend = mesh_.vf_cwend(vh);
546 for (;vf_cwit != vf_cwend; ++vf_cwit, ++i)
548 EXPECT_EQ(rev_indices[i], vf_cwit->idx()) <<
"Index wrong in VertexFaceCWIter";
550 EXPECT_FALSE(vf_cwit.is_valid()) <<
"Iterator invalid in VertexFaceCWIter at end";
551 EXPECT_TRUE( vf_cwit == vf_cwend ) <<
"End iterator for VertexFaceCWIter not matching";
554 Mesh::ConstVertexFaceCWIter cvf_cwit = mesh_.cvf_cwbegin(vh);
555 Mesh::ConstVertexFaceCWIter cvf_cwend = mesh_.cvf_cwend(vh);
557 for (;cvf_cwit != cvf_cwend; ++cvf_cwit, ++i)
559 EXPECT_EQ(rev_indices[i], cvf_cwit->idx()) <<
"Index wrong in ConstVertexFaceCWIter";
561 EXPECT_FALSE(cvf_cwit.is_valid()) <<
"Iterator invalid in ConstVertexFaceCWIter at end";
562 EXPECT_TRUE( cvf_cwit == cvf_cwend ) <<
"End iterator for ConstVertexFaceCWIter not matching";
571 Mesh::VertexFaceCWIter vf_cwIter = mesh_.vf_cwbegin(vh);
573 EXPECT_TRUE( vf_cwIter == Mesh::VertexFaceCWIter(mesh_.vf_ccwbegin(vh)) ) <<
"ccw to cw conversion failed";
574 EXPECT_TRUE( Mesh::VertexFaceCCWIter(vf_cwIter) == mesh_.vf_ccwbegin(vh) ) <<
"cw to ccw conversion failed";
576 EXPECT_EQ( vf_cwIter->idx(), Mesh::VertexFaceCCWIter(vf_cwIter)->idx()) <<
"iterators doesnt point on the same element";
579 vf_ccwend = mesh_.vf_ccwend(vh);
581 EXPECT_EQ(vf_cwIter->idx(),vf_ccwend->idx()) <<
"iteratoes are not equal after inc/dec";
583 vf_ccwend = Mesh::VertexFaceCCWIter(vf_cwIter);
584 EXPECT_EQ(vf_cwIter->idx(),vf_ccwend->idx())<<
"iterators doesnt point on the same element";
586 vf_cwIter = Mesh::VertexFaceCWIter(mesh_.vf_ccwend(vh));
587 EXPECT_FALSE(vf_cwIter.is_valid()) <<
"end iterator is not invalid";
588 EXPECT_TRUE(Mesh::VertexFaceCCWIter(mesh_.vf_cwend(vh)) == mesh_.vf_ccwend(vh)) <<
"end iterators are not equal";
Kernel::Point Point
Coordinate type.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Kernel::ConstVertexFaceIter ConstVertexFaceIter
Circulator.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Kernel::VertexFaceIter VertexFaceIter
Circulator.