From ad950d46b76a96156533e2b38a58a79760fc3f29 Mon Sep 17 00:00:00 2001 From: Martin Schultz Date: Tue, 27 Jun 2017 11:56:15 +0200 Subject: [PATCH 1/7] made the face and edge split operations that copy properties also copy builtin properties --- src/OpenMesh/Core/Mesh/PolyConnectivity.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc index efea0e3f..3e26e6d2 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc @@ -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 From 83e7cb2cde8405f108abddce32780bbb1453a6b6 Mon Sep 17 00:00:00 2001 From: Martin Schultz Date: Tue, 27 Jun 2017 13:20:16 +0200 Subject: [PATCH 2/7] added check for internal properties to split_copy unittest --- src/Unittests/unittests_split_copy.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Unittests/unittests_split_copy.cc b/src/Unittests/unittests_split_copy.cc index 2422a977..aee6e188 100644 --- a/src/Unittests/unittests_split_copy.cc +++ b/src/Unittests/unittests_split_copy.cc @@ -57,6 +57,7 @@ class OpenMeshSplitCopyPolyMesh : public OpenMeshBasePoly { TEST_F(OpenMeshSplitCopyTriangleMesh, SplitCopyTriangleMesh) { mesh_.clear(); + mesh_.request_face_status(); // Add some vertices Mesh::VertexHandle vhandle[4]; @@ -86,6 +87,8 @@ TEST_F(OpenMeshSplitCopyTriangleMesh, SplitCopyTriangleMesh) { OpenMesh::FPropHandleT 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 +97,10 @@ 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"; + } } /* splits a face that has a property in a poly mesh with split_copy @@ -103,6 +109,7 @@ TEST_F(OpenMeshSplitCopyTriangleMesh, SplitCopyTriangleMesh) { TEST_F(OpenMeshSplitCopyPolyMesh, SplitCopyPolymesh) { mesh_.clear(); + mesh_.request_face_status(); // Add some vertices Mesh::VertexHandle vhandle[5]; @@ -134,6 +141,8 @@ TEST_F(OpenMeshSplitCopyPolyMesh, SplitCopyPolymesh) { OpenMesh::FPropHandleT 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 +151,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"; + } } } From da765870a08aa04e9b97d9e47c0ca6ee7a4faca2 Mon Sep 17 00:00:00 2001 From: Martin Schultz Date: Tue, 27 Jun 2017 13:22:59 +0200 Subject: [PATCH 3/7] added unittests for split_edge_copy --- src/Unittests/unittests_split_edge_copy.cc | 152 +++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 src/Unittests/unittests_split_edge_copy.cc diff --git a/src/Unittests/unittests_split_edge_copy.cc b/src/Unittests/unittests_split_edge_copy.cc new file mode 100644 index 00000000..18ff172a --- /dev/null +++ b/src/Unittests/unittests_split_edge_copy.cc @@ -0,0 +1,152 @@ + +#include +#include +#include + +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 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 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 + EXPECT_EQ(999, mesh_.property(eprop_int, *(mesh_.edges_begin()++))) << "Different Property value"; + EXPECT_TRUE(mesh_.status(*(mesh_.edges_begin()++)).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 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 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 + EXPECT_EQ(999, mesh_.property(eprop_int, *(mesh_.edges_begin()++))) << "Different Property value"; + EXPECT_TRUE(mesh_.status(*(mesh_.edges_begin()++)).tagged()) << "Different internal property value"; +} +} From 03b8e184b8b9388c92af83ae94031c98b74c4009 Mon Sep 17 00:00:00 2001 From: Martin Schultz Date: Thu, 29 Jun 2017 10:19:44 +0200 Subject: [PATCH 4/7] fixed unittests for split_edge_copy they were always passing --- src/Unittests/unittests_split_edge_copy.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Unittests/unittests_split_edge_copy.cc b/src/Unittests/unittests_split_edge_copy.cc index 18ff172a..4dd2088d 100644 --- a/src/Unittests/unittests_split_edge_copy.cc +++ b/src/Unittests/unittests_split_edge_copy.cc @@ -95,8 +95,9 @@ TEST_F(OpenMeshSplitEdgeCopyTriangleMesh, SplitEdgeCopyTriangleMesh) { mesh_.split_edge_copy(eh, vhandle[3]); // Check setup - EXPECT_EQ(999, mesh_.property(eprop_int, *(mesh_.edges_begin()++))) << "Different Property value"; - EXPECT_TRUE(mesh_.status(*(mesh_.edges_begin()++)).tagged()) << "Different internal property value"; + 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 @@ -145,8 +146,10 @@ TEST_F(OpenMeshSplitEdgeCopyPolyMesh, SplitEdgeCopyPolymesh) { // split face with new vertex mesh_.split_edge_copy(eh, vhandle[4]); + // Check setup - EXPECT_EQ(999, mesh_.property(eprop_int, *(mesh_.edges_begin()++))) << "Different Property value"; - EXPECT_TRUE(mesh_.status(*(mesh_.edges_begin()++)).tagged()) << "Different internal property value"; + 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"; } } From 019ea5d6ae6c762545f6c8e3691f637939c055a6 Mon Sep 17 00:00:00 2001 From: Martin Schultz Date: Thu, 29 Jun 2017 10:21:01 +0200 Subject: [PATCH 5/7] added check for overloaded split_copy with edgehandle as first parameter to unittest --- src/Unittests/unittests_split_copy.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Unittests/unittests_split_copy.cc b/src/Unittests/unittests_split_copy.cc index aee6e188..d45437c0 100644 --- a/src/Unittests/unittests_split_copy.cc +++ b/src/Unittests/unittests_split_copy.cc @@ -58,14 +58,16 @@ 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 face_vhandles; @@ -75,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 @@ -101,6 +104,19 @@ TEST_F(OpenMeshSplitCopyTriangleMesh, SplitCopyTriangleMesh) { 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 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 From 8302ef59dd5b91ae61c09f1a0493698b1647d899 Mon Sep 17 00:00:00 2001 From: Martin Schultz Date: Thu, 29 Jun 2017 10:21:46 +0200 Subject: [PATCH 6/7] changed the split_copy overloaded function with edgehandle as first parameter tzo always copy internal properties --- src/OpenMesh/Core/Mesh/TriConnectivity.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/Mesh/TriConnectivity.cc b/src/OpenMesh/Core/Mesh/TriConnectivity.cc index 5567c73b..e3d69623 100644 --- a/src/OpenMesh/Core/Mesh/TriConnectivity.cc +++ b/src/OpenMesh/Core/Mesh/TriConnectivity.cc @@ -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 From fcee42095fdd2f780f5b81600eb286838ccc0858 Mon Sep 17 00:00:00 2001 From: Martin Schultz Date: Thu, 29 Jun 2017 10:28:42 +0200 Subject: [PATCH 7/7] added changes of split_copy and split_edge_copy to changelog --- Doc/changelog.docu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/changelog.docu b/Doc/changelog.docu index a798ae16..2a55a8fa 100644 --- a/Doc/changelog.docu +++ b/Doc/changelog.docu @@ -18,6 +18,7 @@
  • Implemented a cast from polyMesh to Mesh and vice versa using static_cast(polymeshInstance) or static_cast(trimeshInstance)
  • make all negative handles invalid, not just -1
  • Several warnings fixed (Including the checked iterators)
  • +
  • split_copy and split_edge_copy operations now also copy internal properties.
  • @@ -46,6 +47,7 @@ Unittests
    • Added unittest to write and read faceTexcoords with a test obj file
    • +
    • Added unittest for split_edge_copy operations on Tri and PolyMeshes
    Python