1 #include <gtest/gtest.h>
2 #include <Unittests/unittests_common.hh>
9 class OpenMeshTrimeshCirculatorFaceEdge :
public OpenMeshBase {
14 virtual void SetUp() {
18 virtual void TearDown() {
40 TEST_F(OpenMeshTrimeshCirculatorFaceEdge, FaceEdgeIterWithoutHolesIncrement) {
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[2]);
65 face_vhandles.push_back(vhandle[1]);
66 face_vhandles.push_back(vhandle[3]);
67 mesh_.add_face(face_vhandles);
69 face_vhandles.clear();
71 face_vhandles.push_back(vhandle[2]);
72 face_vhandles.push_back(vhandle[3]);
73 face_vhandles.push_back(vhandle[4]);
74 mesh_.add_face(face_vhandles);
76 face_vhandles.clear();
78 face_vhandles.push_back(vhandle[1]);
79 face_vhandles.push_back(vhandle[5]);
80 face_vhandles.push_back(vhandle[3]);
81 mesh_.add_face(face_vhandles);
101 EXPECT_EQ(4, fe_it->idx() ) <<
"Index wrong in FaceEdgeIter at initialization";
102 EXPECT_TRUE(fe_it.is_valid()) <<
"Iterator invalid in FaceEdgeIter at initialization";
104 EXPECT_EQ(1, fe_it->idx() ) <<
"Index wrong in FaceEdgeIter at step 1";
105 EXPECT_TRUE(fe_it.is_valid()) <<
"Iterator invalid in FaceEdgeIter at step 1";
107 EXPECT_EQ(3, fe_it->idx() ) <<
"Index wrong in FaceEdgeIter at step 2";
108 EXPECT_TRUE(fe_it.is_valid()) <<
"Iterator invalid in FaceEdgeIter at step 2";
110 EXPECT_EQ(4, fe_it->idx() ) <<
"Index wrong in FaceEdgeIter at end";
111 EXPECT_FALSE(fe_it.is_valid()) <<
"Iterator invalid in FaceEdgeIter at end";
112 EXPECT_TRUE( fe_it == fe_end ) <<
"End iterator for FaceEdgeIter not matching";
117 EXPECT_EQ(4, cfe_it->idx() ) <<
"Index wrong in ConstFaceEdgeIter at initialization";
118 EXPECT_TRUE(cfe_it.is_valid()) <<
"Iterator invalid in ConstFaceEdgeIter at initialization";
120 EXPECT_EQ(1, cfe_it->idx() ) <<
"Index wrong in ConstFaceEdgeIter at step 1";
121 EXPECT_TRUE(cfe_it.is_valid()) <<
"Iterator invalid in ConstFaceEdgeIter at step 1";
123 EXPECT_EQ(3, cfe_it->idx() ) <<
"Index wrong in ConstFaceEdgeIter at step 2";
124 EXPECT_TRUE(cfe_it.is_valid()) <<
"Iterator invalid in ConstFaceEdgeIter at step 2";
126 EXPECT_EQ(4, cfe_it->idx() ) <<
"Index wrong in ConstFaceEdgeIter at end";
127 EXPECT_FALSE(cfe_it.is_valid()) <<
"Iterator invalid in ConstFaceEdgeIter at end";
128 EXPECT_TRUE( cfe_it == cfe_end ) <<
"End iterator for ConstFaceEdgeIter not matching";
136 TEST_F(OpenMeshTrimeshCirculatorFaceEdge, CWAndCCWTest) {
151 std::vector<Mesh::VertexHandle> face_vhandles;
153 face_vhandles.push_back(vhandle[0]);
154 face_vhandles.push_back(vhandle[1]);
155 face_vhandles.push_back(vhandle[2]);
156 mesh_.add_face(face_vhandles);
158 face_vhandles.clear();
160 face_vhandles.push_back(vhandle[2]);
161 face_vhandles.push_back(vhandle[1]);
162 face_vhandles.push_back(vhandle[3]);
163 mesh_.add_face(face_vhandles);
165 face_vhandles.clear();
167 face_vhandles.push_back(vhandle[2]);
168 face_vhandles.push_back(vhandle[3]);
169 face_vhandles.push_back(vhandle[4]);
170 mesh_.add_face(face_vhandles);
172 face_vhandles.clear();
174 face_vhandles.push_back(vhandle[1]);
175 face_vhandles.push_back(vhandle[5]);
176 face_vhandles.push_back(vhandle[3]);
177 mesh_.add_face(face_vhandles);
194 int indices[4] = {4, 1, 3, 4};
196 std::reverse_copy(indices,indices+4,rev_indices);
199 Mesh::FaceEdgeCCWIter fe_ccwit = mesh_.fe_ccwbegin(mesh_.face_handle(1));
200 Mesh::FaceEdgeCCWIter fe_ccwend = mesh_.fe_ccwend(mesh_.face_handle(1));
202 for (;fe_ccwit != fe_ccwend; ++fe_ccwit, ++i)
204 EXPECT_EQ(indices[i], fe_ccwit->idx()) <<
"Index wrong in FaceEdgeCCWIter";
207 EXPECT_FALSE(fe_ccwit.is_valid()) <<
"Iterator invalid in FaceEdgeCCWIter at end";
208 EXPECT_TRUE( fe_ccwit == fe_ccwend ) <<
"End iterator for FaceEdgeCCWIter not matching";
211 Mesh::ConstFaceEdgeCCWIter cfe_ccwit = mesh_.cfe_ccwbegin(mesh_.face_handle(1));
212 Mesh::ConstFaceEdgeCCWIter cfe_ccwend = mesh_.cfe_ccwend(mesh_.face_handle(1));
214 for (;cfe_ccwit != cfe_ccwend; ++cfe_ccwit, ++i)
216 EXPECT_EQ(indices[i], cfe_ccwit->idx()) <<
"Index wrong in ConstFaceEdgeCCWIter";
219 EXPECT_FALSE(cfe_ccwit.is_valid()) <<
"Iterator invalid in ConstFaceEdgeCCWIter at end";
220 EXPECT_TRUE( cfe_ccwit == cfe_ccwend ) <<
"End iterator for ConstFaceEdgeCCWIter not matching";
223 Mesh::FaceEdgeCWIter fe_cwit = mesh_.fe_cwbegin(mesh_.face_handle(1));
224 Mesh::FaceEdgeCWIter fe_cwend = mesh_.fe_cwend(mesh_.face_handle(1));
226 for (;fe_cwit != fe_cwend; ++fe_cwit, ++i)
228 EXPECT_EQ(rev_indices[i], fe_cwit->idx()) <<
"Index wrong in FaceEdgeCWIter";
230 EXPECT_FALSE(fe_cwit.is_valid()) <<
"Iterator invalid in FaceEdgeCWIter at end";
231 EXPECT_TRUE( fe_cwit == fe_cwend ) <<
"End iterator for FaceEdgeCWIter not matching";
234 Mesh::ConstFaceEdgeCWIter cfe_cwit = mesh_.cfe_cwbegin(mesh_.face_handle(1));
235 Mesh::ConstFaceEdgeCWIter cfe_cwend = mesh_.cfe_cwend(mesh_.face_handle(1));
237 for (;cfe_cwit != cfe_cwend; ++cfe_cwit, ++i)
239 EXPECT_EQ(rev_indices[i], cfe_cwit->idx()) <<
"Index wrong in ConstFaceEdgeCWIter";
241 EXPECT_FALSE(cfe_cwit.is_valid()) <<
"Iterator invalid in ConstFaceEdgeCWIter at end";
242 EXPECT_TRUE( cfe_cwit == cfe_cwend ) <<
"End iterator for ConstFaceEdgeCWIter not matching";
251 Mesh::FaceEdgeCWIter fe_cwIter = mesh_.fe_cwbegin(mesh_.face_handle(1));
253 EXPECT_TRUE( fe_cwIter == Mesh::FaceEdgeCWIter(mesh_.fe_ccwbegin(mesh_.face_handle(1))) ) <<
"ccw to cw conversion failed";
254 EXPECT_TRUE( Mesh::FaceEdgeCCWIter(fe_cwIter) == mesh_.fe_ccwbegin(mesh_.face_handle(1)) ) <<
"cw to ccw conversion failed";
256 EXPECT_EQ( fe_cwIter->idx(), Mesh::FaceEdgeCCWIter(fe_cwIter)->idx()) <<
"iterators doesnt point on the same element";
259 fe_ccwend = mesh_.fe_ccwend(mesh_.face_handle(1));
261 EXPECT_EQ(fe_cwIter->idx(),fe_ccwend->idx()) <<
"iteratoes are not equal after inc/dec";
263 fe_ccwend = Mesh::FaceEdgeCCWIter(fe_cwIter);
264 EXPECT_EQ(fe_cwIter->idx(),fe_ccwend->idx())<<
"iterators doesnt point on the same element";
266 fe_cwIter = Mesh::FaceEdgeCWIter(mesh_.fe_ccwend(mesh_.face_handle(1)));
267 EXPECT_FALSE(fe_cwIter.is_valid()) <<
"end iterator is not invalid";
268 EXPECT_TRUE(Mesh::FaceEdgeCCWIter(mesh_.fe_cwend(mesh_.face_handle(1))) == mesh_.fe_ccwend(mesh_.face_handle(1))) <<
"end iterators are not equal";
Kernel::ConstFaceEdgeIter ConstFaceEdgeIter
Circulator.
Kernel::FaceEdgeIter FaceEdgeIter
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.