Commit 0c4e7099 authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'bugVvrange' into 'master'

Bug vvrange

The bug is now fixed and checked by unittests.

See merge request !7
parents a6c14075 4c80b7e5
......@@ -202,7 +202,7 @@ class GenericCirculatorBaseT {
GenericCirculatorBaseT() : mesh_(0), lap_counter_(0) {}
GenericCirculatorBaseT(mesh_ref mesh, HalfedgeHandle heh, bool end = false) :
mesh_(&mesh), start_(heh), heh_(heh), lap_counter_(static_cast<int>(end)) {}
mesh_(&mesh), start_(heh), heh_(heh), lap_counter_(static_cast<int>(end && heh.is_valid())) {}
GenericCirculatorBaseT(const GenericCirculatorBaseT &rhs) :
mesh_(rhs.mesh_), start_(rhs.start_), heh_(rhs.heh_), lap_counter_(rhs.lap_counter_) {}
......
#include <gtest/gtest.h>
#include <Unittests/unittests_common.hh>
#include <OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.hh>
//#include <OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.hh>
namespace {
......@@ -67,6 +67,184 @@ TEST_F(OpenMesh_Triangle, cpp11_initializer_test) {
}
// ////////////////////////////////////////////////////////////////////
// C++11 Range tests
// ////////////////////////////////////////////////////////////////////
/**
* @brief TEST_F test the vertexrange behaviour on trimeshes
*/
TEST_F(OpenMesh_Triangle, cpp11_vertexrange_test) {
//check empty vertexrange
mesh_.clear();
for(Mesh::VertexHandle t : mesh_.vertices())
{
FAIL() << "The Vertexrange for an empty Mesh is not empty";
}
//add vertices to mesh
mesh_.add_vertex(Mesh::Point(0, 1, 0));
mesh_.add_vertex(Mesh::Point(1, 0, 0));
mesh_.add_vertex(Mesh::Point(2, 1, 0));
mesh_.add_vertex(Mesh::Point(0,-1, 0));
mesh_.add_vertex(Mesh::Point(2,-1, 0));
//check nonempty mesh vertexrange
int iteration_counter = 0;
for(Mesh::VertexHandle t : mesh_.vertices())
{
EXPECT_TRUE(t.is_valid());
++iteration_counter;
}
EXPECT_EQ(iteration_counter,5);
}
/**
* @brief TEST_F test the vertexrange behaviour on polymeshes
*/
TEST_F(OpenMesh_Poly, cpp11_vertexrange_test) {
//check empty vertexrange
mesh_.clear();
for(PolyMesh::VertexHandle t : mesh_.vertices())
{
FAIL() << "The Vertexrange for an empty Mesh is not empty";
}
//add vertices to mesh
mesh_.add_vertex(PolyMesh::Point(0, 1, 0));
mesh_.add_vertex(PolyMesh::Point(1, 0, 0));
mesh_.add_vertex(PolyMesh::Point(2, 1, 0));
mesh_.add_vertex(PolyMesh::Point(0,-1, 0));
mesh_.add_vertex(PolyMesh::Point(2,-1, 0));
//check nonempty mesh vertexrange
int iteration_counter = 0;
for(PolyMesh::VertexHandle t : mesh_.vertices())
{
EXPECT_TRUE(t.is_valid());
++iteration_counter;
}
EXPECT_EQ(iteration_counter,5);
}
/**
* @brief TEST_F test vvrange behaviour on trimeshes
*/
TEST_F(OpenMesh_Triangle, cpp11_vvrange_test) {
//check empty vv_range
mesh_.clear();
Mesh::VertexHandle vhandle[5];
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
for(Mesh::VertexHandle t : mesh_.vv_range(vhandle[0]))
{
FAIL() << "The vvrange for a single vertex in a TriMesh is not empty";
}
//add more vertices
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
// Add 4 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]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
//check nonempty vvrange
int iteration_counter = 0;
for(Mesh::VertexHandle t : mesh_.vv_range(vhandle[1]))
{
EXPECT_TRUE(t.is_valid());
++iteration_counter;
}
EXPECT_EQ(iteration_counter,4);
}
/**
* @brief TEST_F test the vvrange behaviour on polymeshes
*/
TEST_F(OpenMesh_Poly, cpp11_vvrange_test) {
//check empty vv_range
mesh_.clear();
Mesh::VertexHandle vhandle[5];
vhandle[0] = mesh_.add_vertex(PolyMesh::Point(0, 1, 0));
for(PolyMesh::VertexHandle t : mesh_.vv_range(vhandle[0]))
{
FAIL() << "The vvrange for a single vertex in a PolyMesh is not empty";
}
//add more vertices
vhandle[1] = mesh_.add_vertex(PolyMesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(PolyMesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(PolyMesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(PolyMesh::Point(2,-1, 0));
// Add 4 faces
std::vector<PolyMesh::VertexHandle> face_vhandles;
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
//check nonempty vvrange
int iteration_counter = 0;
for(PolyMesh::VertexHandle t : mesh_.vv_range(vhandle[1]))
{
EXPECT_TRUE(t.is_valid());
++iteration_counter;
}
EXPECT_EQ(iteration_counter,4);
}
#endif
}
Supports Markdown
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