### - fixed typedef problems

```- split unittests for uniform and adaptive subdivider

refs #261

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@756 fdac6126-5c0c-442c-9429-916003d36597```
parent 485356ab
 ... ... @@ -170,7 +170,7 @@ initialize( void ) template void CompositeT::refine(typename Mesh::FaceHandle& _fh) void CompositeT::refine(typename M::FaceHandle& _fh) { std::vector hh_vector; ... ... @@ -271,7 +271,7 @@ void CompositeT::refine(typename Mesh::FaceHandle& _fh) template void CompositeT::refine(typename Mesh::VertexHandle& _vh) void CompositeT::refine(typename M::VertexHandle& _vh) { // calculate next final level for vertex int new_vertex_state = generation(_vh) + l_rule()->number() + 1; ... ...
 ... ... @@ -172,11 +172,11 @@ public: /// Refine one face. void refine(typename Mesh::FaceHandle& _fh); void refine(typename M::FaceHandle& _fh); /// Raise one vertex to next final level. void refine(typename Mesh::VertexHandle& _vh); void refine(typename M::VertexHandle& _vh); /// Return subdivision split type (3 for 1-to-3 split, 4 for 1-to-4 split). ... ...
 ... ... @@ -9,7 +9,8 @@ #include "unittests_decimater.hh" #include "unittests_mc_decimater.hh" #include "unittests_mixed_decimater.hh" #include "unittests_subdivider.hh" #include "unittests_subdivider_uniform.hh" #include "unittests_subdivider_adaptive.hh" #include "unittests_trimesh_normal_calculations.hh" #include "unittests_trimesh_others.hh" #include "unittests_add_face.hh" ... ...
 #ifndef INCLUDE_UNITTESTS_SUBIVIDER_HH #define INCLUDE_UNITTESTS_SUBIVIDER_HH #ifndef INCLUDE_UNITTESTS_SUBIVIDER_ADAPTIVE_HH #define INCLUDE_UNITTESTS_SUBIVIDER_ADAPTIVE_HH #include #include #include #include #include #include class OpenMeshSubdivider_Poly : public OpenMeshBasePoly { class OpenMeshSubdividerAdaptive_Poly : public OpenMeshBasePoly { protected: ... ... @@ -28,7 +26,7 @@ class OpenMeshSubdivider_Poly : public OpenMeshBasePoly { //Mesh mesh_; }; class OpenMeshSubdivider_Triangle : public OpenMeshBase { class OpenMeshSubdividerAdaptive_Triangle : public OpenMeshBase { protected: ... ... @@ -54,199 +52,6 @@ class OpenMeshSubdivider_Triangle : public OpenMeshBase { * ==================================================================== */ /* */ TEST_F(OpenMeshSubdivider_Triangle, Subdivider_Loop) { mesh_.clear(); // Add some vertices Mesh::VertexHandle vhandle; vhandle = mesh_.add_vertex(Mesh::Point(0, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(0, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(0, 2, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 2, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 2, 0)); // Add eight faces std::vector face_vhandles; face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); // Test setup: // 6 === 7 === 8 // | / | / | // | / | / | // | / | / | // 3 === 4 === 5 // | / | \ | // | / | \ | // | / | \ | // 0 === 1 === 2 // Initialize subdivider OpenMesh::Subdivider::Uniform::Sqrt3T sqrt3; // Check setup EXPECT_EQ(9u, mesh_.n_vertices() ) << "Wrong number of vertices"; EXPECT_EQ(8u, mesh_.n_faces() ) << "Wrong number of faces"; // Execute 3 subdivision steps sqrt3.attach(mesh_); sqrt3( 3 ); sqrt3.detach(); // Check setup EXPECT_EQ(121u, mesh_.n_vertices() ) << "Wrong number of vertices after subdivision with sqrt3"; EXPECT_EQ(216u, mesh_.n_faces() ) << "Wrong number of faces after subdivision with sqrt3"; } /* * ==================================================================== * Define tests below * ==================================================================== */ /* */ TEST_F(OpenMeshSubdivider_Poly, Subdivider_CatmullClark) { mesh_.clear(); // Add some vertices Mesh::VertexHandle vhandle; vhandle = mesh_.add_vertex(Mesh::Point(0, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(0, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(0, 2, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 2, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 2, 0)); // Add four faces std::vector face_vhandles; face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); // Test setup: // 6 === 7 === 8 // | | | // | | | // | | | // 3 === 4 === 5 // | | | // | | | // | | | // 0 === 1 === 2 // Initialize subdivider OpenMesh::Subdivider::Uniform::CatmullClarkT catmull; // Check setup EXPECT_EQ(9u, mesh_.n_vertices() ) << "Wrong number of vertices"; EXPECT_EQ(4u, mesh_.n_faces() ) << "Wrong number of faces"; // Execute 3 subdivision steps catmull.attach(mesh_); catmull( 3 ); catmull.detach(); EXPECT_EQ(289u, mesh_.n_vertices() ) << "Wrong number of vertices after subdivision with catmull clark"; EXPECT_EQ(256u, mesh_.n_faces() ) << "Wrong number of faces after subdivision with catmull clark"; } struct MeshTraits : public OpenMesh::Subdivider::Adaptive::CompositeTraits { typedef OpenMesh::Vec3f Point; typedef OpenMesh::Vec3f Normal; ... ... @@ -257,8 +62,10 @@ struct MeshTraits : public OpenMesh::Subdivider::Adaptive::CompositeTraits { }; typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; typedef MyMesh::VertexHandle VHandle; typedef MyMesh::FaceHandle FHandle; TEST_F(OpenMeshSubdivider_Triangle, AdaptiveCompositeRefineVertex) { TEST_F(OpenMeshSubdividerAdaptive_Triangle, AdaptiveCompositeRefineVertex) { MyMesh mesh; mesh.request_vertex_status(); ... ... @@ -268,7 +75,7 @@ TEST_F(OpenMeshSubdivider_Triangle, AdaptiveCompositeRefineVertex) { mesh.request_face_normals(); // Add some vertices MyMesh::VertexHandle vhandle; VHandle vhandle; vhandle = mesh.add_vertex(MyMesh::Point(0, 0, 0)); vhandle = mesh.add_vertex(MyMesh::Point(0, 1, 0)); ... ... @@ -281,7 +88,7 @@ TEST_F(OpenMeshSubdivider_Triangle, AdaptiveCompositeRefineVertex) { vhandle = mesh.add_vertex(MyMesh::Point(2, 2, 0)); // Add eight faces std::vector face_vhandles; std::vector face_vhandles; face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); ... ... @@ -336,7 +143,7 @@ TEST_F(OpenMeshSubdivider_Triangle, AdaptiveCompositeRefineVertex) { face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); MyMesh::FaceHandle fh = mesh.add_face(face_vhandles); mesh.add_face(face_vhandles); //// Test setup: //// 6 === 7 === 8 ... ... @@ -373,7 +180,7 @@ TEST_F(OpenMeshSubdivider_Triangle, AdaptiveCompositeRefineVertex) { } TEST_F(OpenMeshSubdivider_Triangle, AdaptiveCompositeRefineFace) { TEST_F(OpenMeshSubdividerAdaptive_Triangle, AdaptiveCompositeRefineFace) { MyMesh mesh; mesh.request_vertex_status(); ... ... @@ -383,7 +190,7 @@ TEST_F(OpenMeshSubdivider_Triangle, AdaptiveCompositeRefineFace) { mesh.request_face_normals(); // Add some vertices MyMesh::VertexHandle vhandle; VHandle vhandle; vhandle = mesh.add_vertex(MyMesh::Point(0, 0, 0)); vhandle = mesh.add_vertex(MyMesh::Point(0, 1, 0)); ... ... @@ -396,8 +203,8 @@ TEST_F(OpenMeshSubdivider_Triangle, AdaptiveCompositeRefineFace) { vhandle = mesh.add_vertex(MyMesh::Point(2, 2, 0)); // Add eight faces std::vector face_vhandles; std::vector face_handles; std::vector face_vhandles; std::vector face_handles; face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); ... ... @@ -480,7 +287,7 @@ TEST_F(OpenMeshSubdivider_Triangle, AdaptiveCompositeRefineFace) { EXPECT_EQ(8u, mesh.n_faces() ) << "Wrong number of faces"; // execute adaptive composite subdivision std::vector::iterator it, end; std::vector::iterator it, end; it = face_handles.begin(); end = face_handles.end(); for (; it != end; ++it) ... ...
 #ifndef INCLUDE_UNITTESTS_SUBIVIDER_UNIFORM_HH #define INCLUDE_UNITTESTS_SUBIVIDER_UNIFORM_HH #include #include #include #include class OpenMeshSubdividerUniform_Poly : 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_; }; class OpenMeshSubdividerUniform_Triangle : 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_; }; /* * ==================================================================== * Define tests below * ==================================================================== */ /* */ TEST_F(OpenMeshSubdividerUniform_Triangle, Subdivider_Loop) { mesh_.clear(); // Add some vertices Mesh::VertexHandle vhandle; vhandle = mesh_.add_vertex(Mesh::Point(0, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(0, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(0, 2, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 2, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 2, 0)); // Add eight faces std::vector face_vhandles; face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); // Test setup: // 6 === 7 === 8 // | / | / | // | / | / | // | / | / | // 3 === 4 === 5 // | / | \ | // | / | \ | // | / | \ | // 0 === 1 === 2 // Initialize subdivider OpenMesh::Subdivider::Uniform::Sqrt3T sqrt3; // Check setup EXPECT_EQ(9u, mesh_.n_vertices() ) << "Wrong number of vertices"; EXPECT_EQ(8u, mesh_.n_faces() ) << "Wrong number of faces"; // Execute 3 subdivision steps sqrt3.attach(mesh_); sqrt3( 3 ); sqrt3.detach(); // Check setup EXPECT_EQ(121u, mesh_.n_vertices() ) << "Wrong number of vertices after subdivision with sqrt3"; EXPECT_EQ(216u, mesh_.n_faces() ) << "Wrong number of faces after subdivision with sqrt3"; } /* * ==================================================================== * Define tests below * ==================================================================== */ /* */ TEST_F(OpenMeshSubdividerUniform_Poly, Subdivider_CatmullClark) { mesh_.clear(); // Add some vertices Mesh::VertexHandle vhandle; vhandle = mesh_.add_vertex(Mesh::Point(0, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(0, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(0, 2, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(1, 2, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 0, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 1, 0)); vhandle = mesh_.add_vertex(Mesh::Point(2, 2, 0)); // Add four faces std::vector face_vhandles; face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); face_vhandles.clear(); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); face_vhandles.push_back(vhandle); mesh_.add_face(face_vhandles); // Test setup: // 6 === 7 === 8 // | | | // | | | // | | | // 3 === 4 === 5 // | | | // | | | // | | | // 0 === 1 === 2 // Initialize subdivider OpenMesh::Subdivider::Uniform::CatmullClarkT catmull; // Check setup EXPECT_EQ(9u, mesh_.n_vertices() ) << "Wrong number of vertices"; EXPECT_EQ(4u, mesh_.n_faces() ) << "Wrong number of faces"; // Execute 3 subdivision steps catmull.attach(mesh_); catmull( 3 ); catmull.detach(); EXPECT_EQ(289u, mesh_.n_vertices() ) << "Wrong number of vertices after subdivision with catmull clark"; EXPECT_EQ(256u, mesh_.n_faces() ) << "Wrong number of faces after subdivision with catmull clark"; } #endif // INCLUDE GUARD
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment