#ifndef INCLUDE_UNITTESTS_OpenMeshAddFaceTriangleMesh_HH #define INCLUDE_UNITTESTS_OpenMeshAddFaceTriangleMesh_HH #include #include #include class OpenMeshAddFaceTriangleMesh : public OpenMeshBase { protected: // This function is called before each test is run virtual void SetUp() { // Do some initial stuff with the member data here... } // This function is called after all tests are through virtual void TearDown() { // Do some final stuff with the member data here... } // Member already defined in OpenMeshBase //Mesh mesh_; }; class OpenMeshAddFacePolyMesh : public OpenMeshBasePoly { protected: // This function is called before each test is run virtual void SetUp() { // Do some initial stuff with the member data here... } // This function is called after all tests are through virtual void TearDown() { // Do some final stuff with the member data here... } // Member already defined in OpenMeshBase //Mesh mesh_; }; /* * ==================================================================== * Define tests below * ==================================================================== */ /* Adds two triangles to a tri mesh */ TEST_F(OpenMeshAddFaceTriangleMesh, AddTrianglesToTrimesh) { 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[2]); face_vhandles.push_back(vhandle[1]); face_vhandles.push_back(vhandle[0]); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle[2]); face_vhandles.push_back(vhandle[0]); face_vhandles.push_back(vhandle[3]); mesh_.add_face(face_vhandles); // Test setup: // 1 === 2 // | / | // | / | // | / | // 0 === 3 // Check setup EXPECT_EQ(4, mesh_.n_vertices() ) << "Wrong number of vertices"; EXPECT_EQ(2, mesh_.n_faces() ) << "Wrong number of faces"; } /* Adds a quad to a trimesh (should be triangulated afterwards) */ TEST_F(OpenMeshAddFaceTriangleMesh, AddQuadToTrimesh) { 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[1]); face_vhandles.push_back(vhandle[2]); face_vhandles.push_back(vhandle[3]); mesh_.add_face(face_vhandles); // Test setup: // 1 === 2 // | / | // | / | // | / | // 0 === 3 // Check setup EXPECT_EQ(4, mesh_.n_vertices() ) << "Wrong number of vertices"; EXPECT_EQ(2, mesh_.n_faces() ) << "Wrong number of faces"; } /* Adds a quad to a polymesh (should be a quad afterwards) */ TEST_F(OpenMeshAddFacePolyMesh, AddQuadToPolymesh) { 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[1]); face_vhandles.push_back(vhandle[2]); face_vhandles.push_back(vhandle[3]); mesh_.add_face(face_vhandles); // Test setup: // 1 === 2 // | | // | | // | | // 0 === 3 // Check setup EXPECT_EQ(4, mesh_.n_vertices() ) << "Wrong number of vertices"; EXPECT_EQ(1, mesh_.n_faces() ) << "Wrong number of faces"; } #endif // INCLUDE GUARD