From 84eccff6a64a3749c0d01ff1f8a9b84d050c74cc Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 7 Aug 2018 14:03:51 +0200 Subject: [PATCH] add another test for custom edge property storing and loading --- src/Unittests/unittests_read_write_OM.cc | 105 ++++++++++++++++++++++- 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/src/Unittests/unittests_read_write_OM.cc b/src/Unittests/unittests_read_write_OM.cc index 4d33486e..b20e845d 100644 --- a/src/Unittests/unittests_read_write_OM.cc +++ b/src/Unittests/unittests_read_write_OM.cc @@ -464,11 +464,11 @@ TEST_F(OpenMeshReadWriteOM, WriteTriangleEdgeIntProperty) { Mesh::EdgeHandle e2 = Mesh::EdgeHandle(1); Mesh::EdgeHandle e3 = Mesh::EdgeHandle(2); - int va1ue1 = 10, + int value1 = 10, value2 = 21, value3 = 32; - mesh.property(prop,e1) = va1ue1; + mesh.property(prop,e1) = value1; mesh.property(prop,e2) = value2; mesh.property(prop,e3) = value3; @@ -494,7 +494,7 @@ TEST_F(OpenMeshReadWriteOM, WriteTriangleEdgeIntProperty) { EXPECT_EQ(Mesh::Point(0.0,1.0,0.0) , cmpMesh.point(v2)) << "Wrong coordinates at vertex 1"; EXPECT_EQ(Mesh::Point(0.0,0.0,1.0) , cmpMesh.point(v3)) << "Wrong coordinates at vertex 2"; - EXPECT_EQ(va1ue1 , cmpMesh.property(prop,e1)) << "Wrong property at edge 0"; + EXPECT_EQ(value1 , cmpMesh.property(prop,e1)) << "Wrong property at edge 0"; EXPECT_EQ(value2 , cmpMesh.property(prop,e2)) << "Wrong property at edge 1"; EXPECT_EQ(value3 , cmpMesh.property(prop,e3)) << "Wrong property at edge 2"; @@ -503,6 +503,105 @@ TEST_F(OpenMeshReadWriteOM, WriteTriangleEdgeIntProperty) { } +/* + * Save and load simple mesh with custom property + */ +TEST_F(OpenMeshReadWriteOM, WriteSplitTriangleEdgeIntProperty) { + + Mesh mesh; + + const std::string propName = "EIProp"; + const std::string filename = std::string("triangle-minimal-")+propName+".om"; + + // generate data + Mesh::VertexHandle v1 = mesh.add_vertex(Mesh::Point(1.0,0.0,0.0)); + Mesh::VertexHandle v2 = mesh.add_vertex(Mesh::Point(0.0,1.0,0.0)); + Mesh::VertexHandle v3 = mesh.add_vertex(Mesh::Point(0.0,0.0,1.0)); + auto fh0 = mesh.add_face(v1,v2,v3); + auto c = mesh.calc_face_centroid(fh0); + Mesh::VertexHandle v4 = mesh.add_vertex(c); + mesh.split(fh0, v4); + + + OpenMesh::EPropHandleT prop; + mesh.add_property(prop,propName); + mesh.property(prop).set_persistent(true); + + Mesh::EdgeHandle e1 = Mesh::EdgeHandle(0); + Mesh::EdgeHandle e2 = Mesh::EdgeHandle(1); + Mesh::EdgeHandle e3 = Mesh::EdgeHandle(2); + Mesh::EdgeHandle e4 = Mesh::EdgeHandle(3); + Mesh::EdgeHandle e5 = Mesh::EdgeHandle(4); + Mesh::EdgeHandle e6 = Mesh::EdgeHandle(5); + + int value1 = 10, + value2 = 21, + value3 = 32, + value4 = 43, + value5 = 54, + value6 = 65; + + mesh.property(prop,e1) = value1; + mesh.property(prop,e2) = value2; + mesh.property(prop,e3) = value3; + mesh.property(prop,e4) = value4; + mesh.property(prop,e5) = value5; + mesh.property(prop,e6) = value6; + + // save + OpenMesh::IO::Options options; + bool ok = OpenMesh::IO::write_mesh(mesh,filename); + EXPECT_TRUE(ok) << "Unable to write "<