Merge branch 'featureSplitCopyInternal' into 'master'

Feature split copy internal

Closes #44

See merge request !137
This commit is contained in:
Jan Möbius
2017-07-03 15:50:59 +02:00
5 changed files with 189 additions and 4 deletions

View File

@@ -1130,7 +1130,7 @@ void PolyConnectivity::split_copy(FaceHandle fh, VertexHandle vh) {
// Copy the property of the original face to all new faces
for(VertexFaceIter vf_it = vf_iter(vh); vf_it.is_valid(); ++vf_it)
copy_all_properties(fh, *vf_it);
copy_all_properties(fh, *vf_it, true);
}
//-----------------------------------------------------------------------------
@@ -1226,7 +1226,7 @@ void PolyConnectivity::split_edge_copy(EdgeHandle _eh, VertexHandle _vh)
EdgeHandle eh0 = edge_handle( next_halfedge_handle( halfedge_handle(_eh, 1) ) );
// Copy the property from the original to the new edge
copy_all_properties(_eh, eh0);
copy_all_properties(_eh, eh0, true);
}
} // namespace OpenMesh

View File

@@ -494,7 +494,7 @@ void TriConnectivity::split_copy(EdgeHandle _eh, VertexHandle _vh)
// Copy the properties of the original edge to all neighbor edges that
// have been created
for(VEIter ve_it = ve_iter(_vh); ve_it.is_valid(); ++ve_it)
copy_all_properties(_eh, *ve_it);
copy_all_properties(_eh, *ve_it, true);
}
}// namespace OpenMesh

View File

@@ -57,14 +57,17 @@ class OpenMeshSplitCopyPolyMesh : public OpenMeshBasePoly {
TEST_F(OpenMeshSplitCopyTriangleMesh, SplitCopyTriangleMesh) {
mesh_.clear();
mesh_.request_face_status();
mesh_.request_edge_status();
// Add some vertices
Mesh::VertexHandle vhandle[4];
Mesh::VertexHandle vhandle[5];
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(0.25, 0.25, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(0.5, 0.5, 0));
// Add one face
std::vector<Mesh::VertexHandle> face_vhandles;
@@ -74,6 +77,7 @@ TEST_F(OpenMeshSplitCopyTriangleMesh, SplitCopyTriangleMesh) {
face_vhandles.push_back(vhandle[0]);
Mesh::FaceHandle fh = mesh_.add_face(face_vhandles);
Mesh::EdgeHandle eh = *mesh_.edges_begin();
// Test setup:
// 1 === 2
@@ -86,6 +90,8 @@ TEST_F(OpenMeshSplitCopyTriangleMesh, SplitCopyTriangleMesh) {
OpenMesh::FPropHandleT<int> fprop_int;
mesh_.add_property(fprop_int);
mesh_.property(fprop_int, fh) = 999;
//set internal property
mesh_.status(fh).set_tagged(true);
// split face with new vertex
mesh_.split_copy(fh, vhandle[3]);
@@ -94,7 +100,23 @@ TEST_F(OpenMeshSplitCopyTriangleMesh, SplitCopyTriangleMesh) {
Mesh::FaceIter f_it = mesh_.faces_begin();
Mesh::FaceIter f_end = mesh_.faces_end();
for (; f_it != f_end; ++f_it)
{
EXPECT_EQ(999, mesh_.property(fprop_int, *f_it)) << "Different Property value";
EXPECT_TRUE(mesh_.status(*f_it).tagged()) << "Different internal property value";
}
//check the function overload for edgehandles
OpenMesh::EPropHandleT<int> eprop_int;
mesh_.add_property(eprop_int);
mesh_.property(eprop_int, eh) = 999;
//set internal property
mesh_.status(eh).set_feature(true);
//split edge with new vertex
mesh_.split_copy(eh, vhandle[4]);
// Check setup
Mesh::EdgeHandle eh0 = mesh_.edge_handle( mesh_.next_halfedge_handle( mesh_.halfedge_handle(eh, 1) ) );
EXPECT_EQ(999, mesh_.property(eprop_int, eh0)) << "Different Property value";
EXPECT_TRUE(mesh_.status(eh0).feature()) << "Different internal property value";
}
/* splits a face that has a property in a poly mesh with split_copy
@@ -103,6 +125,7 @@ TEST_F(OpenMeshSplitCopyTriangleMesh, SplitCopyTriangleMesh) {
TEST_F(OpenMeshSplitCopyPolyMesh, SplitCopyPolymesh) {
mesh_.clear();
mesh_.request_face_status();
// Add some vertices
Mesh::VertexHandle vhandle[5];
@@ -134,6 +157,8 @@ TEST_F(OpenMeshSplitCopyPolyMesh, SplitCopyPolymesh) {
OpenMesh::FPropHandleT<int> fprop_int;
mesh_.add_property(fprop_int);
mesh_.property(fprop_int, fh) = 999;
//set internal property
mesh_.status(fh).set_tagged(true);
// split face with new vertex
mesh_.split_copy(fh, vhandle[4]);
@@ -142,7 +167,10 @@ TEST_F(OpenMeshSplitCopyPolyMesh, SplitCopyPolymesh) {
PolyMesh::FaceIter f_it = mesh_.faces_begin();
PolyMesh::FaceIter f_end = mesh_.faces_end();
for (; f_it != f_end; ++f_it)
{
EXPECT_EQ(999, mesh_.property(fprop_int, *f_it)) << "Different Property value";
EXPECT_TRUE(mesh_.status(*f_it).tagged()) << "Different internal property value";
}
}
}

View File

@@ -0,0 +1,155 @@
#include <gtest/gtest.h>
#include <Unittests/unittests_common.hh>
#include <iostream>
namespace {
class OpenMeshSplitEdgeCopyTriangleMesh : 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 OpenMeshSplitEdgeCopyPolyMesh : 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
* ====================================================================
*/
/* splits an edge that has a property in a triangle mesh with split_edge_copy
* the property should be copied to the new edge
*/
TEST_F(OpenMeshSplitEdgeCopyTriangleMesh, SplitEdgeCopyTriangleMesh) {
mesh_.clear();
mesh_.request_edge_status();
// 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(0.25, 0.25, 0));
// Add one face
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::FaceHandle fh = mesh_.add_face(face_vhandles);
Mesh::EdgeHandle eh = *mesh_.edges_begin();
// Test setup:
// 1 === 2
// | /
// | /
// | /
// 0
// set property
OpenMesh::EPropHandleT<int> eprop_int;
mesh_.add_property(eprop_int);
mesh_.property(eprop_int, eh) = 999;
//set internal property
mesh_.status(eh).set_tagged(true);
// split face with new vertex
mesh_.split_edge_copy(eh, vhandle[3]);
// Check setup
Mesh::EdgeHandle eh0 = mesh_.edge_handle( mesh_.next_halfedge_handle( mesh_.halfedge_handle(eh, 1) ) );
EXPECT_EQ(999, mesh_.property(eprop_int, eh0)) << "Different Property value";
EXPECT_TRUE(mesh_.status(eh0).tagged()) << "Different internal property value";
}
/* splits an edge that has a property in a poly mesh with split_edge_copy
* the property should be copied to the new faces
*/
TEST_F(OpenMeshSplitEdgeCopyPolyMesh, SplitEdgeCopyPolymesh) {
mesh_.clear();
mesh_.request_edge_status();
// Add some vertices
Mesh::VertexHandle vhandle[5];
vhandle[0] = mesh_.add_vertex(PolyMesh::Point(0, 0, 0));
vhandle[1] = mesh_.add_vertex(PolyMesh::Point(0, 1, 0));
vhandle[2] = mesh_.add_vertex(PolyMesh::Point(1, 1, 0));
vhandle[3] = mesh_.add_vertex(PolyMesh::Point(1, 0, 0));
vhandle[4] = mesh_.add_vertex(PolyMesh::Point(0.5, 0.5, 0));
// Add face
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]);
PolyMesh::FaceHandle fh = mesh_.add_face(face_vhandles);
PolyMesh::EdgeHandle eh = *mesh_.edges_begin();
// Test setup:
// 1 === 2
// | |
// | |
// | |
// 0 === 3
// set property
OpenMesh::EPropHandleT<int> eprop_int;
mesh_.add_property(eprop_int);
mesh_.property(eprop_int, eh) = 999;
//set internal property
mesh_.status(eh).set_tagged(true);
// split face with new vertex
mesh_.split_edge_copy(eh, vhandle[4]);
// Check setup
Mesh::EdgeHandle eh0 = mesh_.edge_handle( mesh_.next_halfedge_handle( mesh_.halfedge_handle(eh, 1) ) );
EXPECT_EQ(999, mesh_.property(eprop_int, eh0)) << "Different Property value";
EXPECT_TRUE(mesh_.status(eh0).tagged()) << "Different internal property value";
}
}