From 3d2472c072ddb4f03778622314d53d4ff6b3b2dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Thu, 21 Jun 2012 08:10:00 +0000 Subject: [PATCH] Added missing file git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@601 fdac6126-5c0c-442c-9429-916003d36597 --- src/Unittests/unittests_add_face.hh | 172 ++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 src/Unittests/unittests_add_face.hh diff --git a/src/Unittests/unittests_add_face.hh b/src/Unittests/unittests_add_face.hh new file mode 100644 index 00000000..ca9959f9 --- /dev/null +++ b/src/Unittests/unittests_add_face.hh @@ -0,0 +1,172 @@ +#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