Added missing file
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@601 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
172
src/Unittests/unittests_add_face.hh
Normal file
172
src/Unittests/unittests_add_face.hh
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
#ifndef INCLUDE_UNITTESTS_OpenMeshAddFaceTriangleMesh_HH
|
||||||
|
#define INCLUDE_UNITTESTS_OpenMeshAddFaceTriangleMesh_HH
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <Unittests/unittests_common.hh>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
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<Mesh::VertexHandle> 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<Mesh::VertexHandle> 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<Mesh::VertexHandle> 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
|
||||||
Reference in New Issue
Block a user