From 330ec3d133d0b940e3c244e41a7cfba6faede98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Fri, 22 Jun 2012 12:50:36 +0000 Subject: [PATCH] Added unittest for getting handles and faces from the iterator git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@608 fdac6126-5c0c-442c-9429-916003d36597 --- .../unittests_trimesh_circulators.hh | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/Unittests/unittests_trimesh_circulators.hh b/src/Unittests/unittests_trimesh_circulators.hh index 9f7ad5f0..564b773a 100644 --- a/src/Unittests/unittests_trimesh_circulators.hh +++ b/src/Unittests/unittests_trimesh_circulators.hh @@ -20,6 +20,7 @@ class OpenMeshCirculators : public OpenMeshBase { // Do some final stuff with the member data here... } + // Member already defined in OpenMeshBase //Mesh mesh_; }; @@ -510,8 +511,73 @@ TEST_F(OpenMeshCirculators, FaceFaceIterWithoutHoles) { } +/* + * Small FaceFaceIterator Test for getting handles and faces from the facefaceiterator + */ +TEST_F(OpenMeshCirculators, FaceFaceIteratorHandleConversion) { + + mesh_.clear(); + + // Add some vertices + Mesh::VertexHandle vhandle[4]; + + vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 0, 0)); + vhandle[1] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); + vhandle[2] = mesh_.add_vertex(Mesh::Point(1, 1, 0)); + vhandle[3] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); + // Add two faces + std::vector face_vhandles; + face_vhandles.push_back(vhandle[0]); + face_vhandles.push_back(vhandle[2]); + face_vhandles.push_back(vhandle[1]); + Mesh::FaceHandle fh1 = mesh_.add_face(face_vhandles); + + face_vhandles.clear(); + + face_vhandles.push_back(vhandle[0]); + face_vhandles.push_back(vhandle[3]); + face_vhandles.push_back(vhandle[2]); + Mesh::FaceHandle fh2 = mesh_.add_face(face_vhandles); + + face_vhandles.clear(); + + /* Test setup: + * + * 1 -------- 2 + * | f0 / | + * | / f1 | + * 0 -------- 3 + */ + + // Check setup + EXPECT_EQ(4, mesh_.n_vertices() ) << "Wrong number of vertices"; + EXPECT_EQ(2, mesh_.n_faces() ) << "Wrong number of faces"; + + + Mesh::ConstFaceFaceIter face_iter = mesh_.cff_iter(fh1); + + + // Get the face via the handle + Mesh::FaceHandle faceHandle1 = mesh_.handle(*face_iter); + const Mesh::Face& face1 = mesh_.face(faceHandle1); + + EXPECT_EQ(1, faceHandle1.idx() ) << "Wrong face handle index when getting from iterator via handle"; + + // Get the face via the face itself + const Mesh::Face& face = *face_iter; + Mesh::FaceHandle fh = mesh_.handle(face); + + + EXPECT_EQ(1, fh.idx() ) << "Wrong face handle index when getting from iterator via face"; + + bool correct = (&face == &face1); + + // Compare the faces + EXPECT_TRUE(correct) << "The faces are different although both ways should give the same one"; + +} #endif // INCLUDE GUARD