1 #include <gtest/gtest.h>
2 #include <Unittests/unittests_common.hh>
9 class OpenMeshTrimeshCirculatorFaceHalfEdge :
public OpenMeshBase {
14 virtual void SetUp() {
18 virtual void TearDown() {
134 TEST_F(OpenMeshTrimeshCirculatorFaceHalfEdge, CWAndCCWTest) {
149 std::vector<Mesh::VertexHandle> face_vhandles;
151 face_vhandles.push_back(vhandle[0]);
152 face_vhandles.push_back(vhandle[1]);
153 face_vhandles.push_back(vhandle[2]);
154 mesh_.add_face(face_vhandles);
156 face_vhandles.clear();
158 face_vhandles.push_back(vhandle[2]);
159 face_vhandles.push_back(vhandle[1]);
160 face_vhandles.push_back(vhandle[3]);
161 mesh_.add_face(face_vhandles);
163 face_vhandles.clear();
165 face_vhandles.push_back(vhandle[2]);
166 face_vhandles.push_back(vhandle[3]);
167 face_vhandles.push_back(vhandle[4]);
168 mesh_.add_face(face_vhandles);
170 face_vhandles.clear();
172 face_vhandles.push_back(vhandle[1]);
173 face_vhandles.push_back(vhandle[5]);
174 face_vhandles.push_back(vhandle[3]);
175 mesh_.add_face(face_vhandles);
192 int indices[4] = {8, 3, 6, 8};
194 std::reverse_copy(indices,indices+4,rev_indices);
197 Mesh::FaceHalfedgeCCWIter fh_ccwit = mesh_.fh_ccwbegin(mesh_.face_handle(1));
198 Mesh::FaceHalfedgeCCWIter fh_ccwend = mesh_.fh_ccwend(mesh_.face_handle(1));
200 for (;fh_ccwit != fh_ccwend; ++fh_ccwit, ++i)
202 EXPECT_EQ(indices[i], fh_ccwit->idx()) <<
"Index wrong in FaceHalfedgeIter";
205 EXPECT_FALSE(fh_ccwit.is_valid()) <<
"Iterator invalid in FaceHalfedgeIter at end";
206 EXPECT_TRUE( fh_ccwit == fh_ccwend ) <<
"End iterator for FaceHalfedgeIter not matching";
209 Mesh::ConstFaceHalfedgeCCWIter cfh_ccwit = mesh_.cfh_ccwbegin(mesh_.face_handle(1));
210 Mesh::ConstFaceHalfedgeCCWIter cfh_ccwend = mesh_.cfh_ccwend(mesh_.face_handle(1));
212 for (;cfh_ccwit != cfh_ccwend; ++cfh_ccwit, ++i)
214 EXPECT_EQ(indices[i], cfh_ccwit->idx()) <<
"Index wrong in ConstFaceHalfedgeIter";
217 EXPECT_FALSE(cfh_ccwit.is_valid()) <<
"Iterator invalid in ConstFaceHalfedgeIter at end";
218 EXPECT_TRUE( cfh_ccwit == cfh_ccwend ) <<
"End iterator for ConstFaceHalfedgeIter not matching";
221 Mesh::FaceHalfedgeCWIter fh_cwit = mesh_.fh_cwbegin(mesh_.face_handle(1));
222 Mesh::FaceHalfedgeCWIter fh_cwend = mesh_.fh_cwend(mesh_.face_handle(1));
224 for (;fh_cwit != fh_cwend; ++fh_cwit, ++i)
226 EXPECT_EQ(rev_indices[i], fh_cwit->idx()) <<
"Index wrong in FaceHalfedgeCWIter";
228 EXPECT_FALSE(fh_cwit.is_valid()) <<
"Iterator invalid in FaceHalfedgeCWIter at end";
229 EXPECT_TRUE( fh_cwit == fh_cwend ) <<
"End iterator for FaceHalfedgeCWIter not matching";
232 Mesh::ConstFaceHalfedgeCWIter cfh_cwit = mesh_.cfh_cwbegin(mesh_.face_handle(1));
233 Mesh::ConstFaceHalfedgeCWIter cfh_cwend = mesh_.cfh_cwend(mesh_.face_handle(1));
235 for (;cfh_cwit != cfh_cwend; ++cfh_cwit, ++i)
237 EXPECT_EQ(rev_indices[i], cfh_cwit->idx()) <<
"Index wrong in ConstFaceHalfedgeCWIter";
239 EXPECT_FALSE(cfh_cwit.is_valid()) <<
"Iterator invalid in ConstFaceHalfedgeCWIter at end";
240 EXPECT_TRUE( cfh_cwit == cfh_cwend ) <<
"End iterator for ConstFaceHalfedgeCWIter not matching";
249 Mesh::FaceHalfedgeCWIter fh_cwIter = mesh_.fh_cwbegin(mesh_.face_handle(1));
251 EXPECT_TRUE( fh_cwIter == Mesh::FaceHalfedgeCWIter(mesh_.fh_ccwbegin(mesh_.face_handle(1))) ) <<
"ccw to cw conversion failed";
252 EXPECT_TRUE( Mesh::FaceHalfedgeCCWIter(fh_cwIter) == mesh_.fh_ccwbegin(mesh_.face_handle(1)) ) <<
"cw to ccw conversion failed";
254 EXPECT_EQ( fh_cwIter->idx(), Mesh::FaceHalfedgeCCWIter(fh_cwIter)->idx()) <<
"iterators doesnt point on the same element";
257 fh_ccwend = mesh_.fh_ccwend(mesh_.face_handle(1));
259 EXPECT_EQ(fh_cwIter->idx(),fh_ccwend->idx()) <<
"iteratoes are not equal after inc/dec";
261 fh_ccwend = Mesh::FaceHalfedgeCCWIter(fh_cwIter);
262 EXPECT_EQ(fh_cwIter->idx(),fh_ccwend->idx())<<
"iterators doesnt point on the same element";
264 fh_cwIter = Mesh::FaceHalfedgeCWIter(mesh_.fh_ccwend(mesh_.face_handle(1)));
265 EXPECT_FALSE(fh_cwIter.is_valid()) <<
"end iterator is not invalid";
266 EXPECT_TRUE(Mesh::FaceHalfedgeCCWIter(mesh_.fh_cwend(mesh_.face_handle(1))) == mesh_.fh_ccwend(mesh_.face_handle(1))) <<
"end iterators are not equal";
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.