add_vertex and new_vertex parameters changed to by value
This commit is contained in:
@@ -206,11 +206,8 @@ public:
|
||||
*
|
||||
* \sa new_vertex(), new_vertex_dirty()
|
||||
*
|
||||
* \attention Be careful to not use a reference to a point in the mesh itself here.
|
||||
* as a resize of the underlying vector might invalidate this reference
|
||||
* and cause a segfault.
|
||||
*/
|
||||
inline SmartVertexHandle new_vertex(const Point& _p)
|
||||
inline SmartVertexHandle new_vertex(const Point _p)
|
||||
{
|
||||
VertexHandle vh(Kernel::new_vertex());
|
||||
this->set_point(vh, _p);
|
||||
@@ -226,9 +223,9 @@ public:
|
||||
* new_vertex(const Point &) saves reallocation and reinitialization of
|
||||
* property memory.
|
||||
*
|
||||
* \sa new_vertex(const Point &)
|
||||
* \sa new_vertex(const Point )
|
||||
*/
|
||||
inline SmartVertexHandle new_vertex_dirty(const Point& _p)
|
||||
inline SmartVertexHandle new_vertex_dirty(const Point _p)
|
||||
{
|
||||
VertexHandle vh(Kernel::new_vertex_dirty());
|
||||
this->set_point(vh, _p);
|
||||
@@ -237,16 +234,12 @@ public:
|
||||
|
||||
/** Alias for new_vertex(const Point&).
|
||||
*
|
||||
* \attention Be careful to not use a reference to a point in the mesh itself here.
|
||||
* as a resize of the underlying vector might invalidate this reference
|
||||
* and cause a segfault.
|
||||
*
|
||||
*/
|
||||
inline SmartVertexHandle add_vertex(const Point& _p)
|
||||
inline SmartVertexHandle add_vertex(const Point _p)
|
||||
{ return new_vertex(_p); }
|
||||
|
||||
/// Alias for new_vertex_dirty().
|
||||
inline SmartVertexHandle add_vertex_dirty(const Point& _p)
|
||||
inline SmartVertexHandle add_vertex_dirty(const Point _p)
|
||||
{ return make_smart(new_vertex_dirty(_p), this); }
|
||||
|
||||
// --- normal vectors ---
|
||||
|
||||
@@ -17,6 +17,7 @@ set(UNITTEST_SRC
|
||||
unittests_mesh_dual.cc
|
||||
unittests_mesh_type.cc
|
||||
unittests_mixed_decimater.cc
|
||||
unittests_new_vertex.cc
|
||||
unittests_normal_calculations.cc
|
||||
unittests_polymesh_collapse.cc
|
||||
unittests_polymesh_vec2i.cc
|
||||
|
||||
94
src/Unittests/unittests_new_vertex.cc
Normal file
94
src/Unittests/unittests_new_vertex.cc
Normal file
@@ -0,0 +1,94 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <Unittests/unittests_common.hh>
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
|
||||
class OpenMeshNewVertexTriangleMesh : 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 OpenMeshNewVertexPolyMesh : 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
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/* Takes a vertex position directly from the mesh and readds it as a new vertex position
|
||||
*/
|
||||
TEST_F(OpenMeshNewVertexTriangleMesh, CopyVertexinsideMeshTriangle) {
|
||||
|
||||
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(Mesh::VertexHandle(0)));
|
||||
vhandle[2] = mesh_.add_vertex(mesh_.point(Mesh::VertexHandle(1)));
|
||||
vhandle[3] = mesh_.add_vertex(mesh_.point(Mesh::VertexHandle(2)));
|
||||
|
||||
|
||||
// Check setup
|
||||
EXPECT_EQ(4u, mesh_.n_vertices() ) << "Wrong number of vertices";
|
||||
EXPECT_EQ(0u, mesh_.n_faces() ) << "Wrong number of faces";
|
||||
|
||||
}
|
||||
|
||||
/* Takes a vertex position directly from the mesh and readds it as a new vertex position
|
||||
*/
|
||||
TEST_F(OpenMeshNewVertexPolyMesh, CopyVertexinsideMeshPoly) {
|
||||
|
||||
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(Mesh::VertexHandle(0)));
|
||||
vhandle[2] = mesh_.add_vertex(mesh_.point(Mesh::VertexHandle(1)));
|
||||
vhandle[3] = mesh_.add_vertex(mesh_.point(Mesh::VertexHandle(2)));
|
||||
|
||||
// Check setup
|
||||
EXPECT_EQ(4u, mesh_.n_vertices() ) << "Wrong number of vertices";
|
||||
EXPECT_EQ(0u, mesh_.n_faces() ) << "Wrong number of faces";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user