Commit 3d2472c0 authored by Jan Möbius's avatar Jan Möbius

Added missing file

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@601 fdac6126-5c0c-442c-9429-916003d36597
parent a3f36c2d
#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
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