From 59b0cafecd0a4a5b5fc26c6176367e76b8761462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20M=C3=B6ller?= Date: Tue, 16 Jun 2015 08:37:42 +0000 Subject: [PATCH] - fix ply ascii reader with custom face properties which aren't declared as list - extend unittest for this case git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@1284 fdac6126-5c0c-442c-9429-916003d36597 --- src/OpenMesh/Core/IO/reader/PLYReader.cc | 7 +++-- .../TestFiles/cube-minimal-custom_props.ply | 13 +++++---- src/Unittests/unittests_read_write_PLY.cc | 28 +++++++++---------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc index da109694..5e5dad44 100644 --- a/src/OpenMesh/Core/IO/reader/PLYReader.cc +++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc @@ -239,6 +239,10 @@ void _PLYReader_::readCustomProperty(std::istream& _in, BaseImporter& _bi, Handl case ValueTypeCHAR: assignCustomProperty(_in,_bi,_h,_propName,isList); break; + case ValueTypeUINT8: + case ValueTypeUCHAR: + assignCustomProperty(_in,_bi,_h,_propName,isList); + break; case ValueTypeINT16: case ValueTypeSHORT: assignCustomProperty(_in,_bi,_h,_propName,isList); @@ -1190,8 +1194,7 @@ bool _PLYReader_::can_u_read(std::istream& _is) const { options_ += Options::Custom; else omerr() << "Custom Properties not supported in binary files. Skipping" << std::endl; - PropertyInfo entry(prop, valueType, propertyName); - vertexProperties_.push_back(entry); + entry = PropertyInfo(prop, valueType, propertyName); } if (entry.property != UNSUPPORTED) diff --git a/src/Unittests/TestFiles/cube-minimal-custom_props.ply b/src/Unittests/TestFiles/cube-minimal-custom_props.ply index 38e00701..1fe0844f 100644 --- a/src/Unittests/TestFiles/cube-minimal-custom_props.ply +++ b/src/Unittests/TestFiles/cube-minimal-custom_props.ply @@ -13,6 +13,7 @@ property list uint8 int32 test_values element face 6 property list uint8 int32 vertex_indices property list uint8 float32 texcoords +property uint faceIndex end_header -1 -1 -1 0.0 0.0 1.0 1.0 0 2 1 2 1 -1 -1 0.0 1.0 0.0 0.5 1 2 3 4 @@ -22,9 +23,9 @@ end_header 1 -1 1 1.0 1.0 0.0 0.0 5 2 11 12 1 1 1 1.0 1.0 1.0 2.0 6 2 13 14 -1 1 1 1.0 1.0 2.0 5.0 7 2 15 16 -4 0 1 2 3 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 -4 5 4 7 6 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 -4 6 2 1 5 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 -4 3 7 4 0 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 -4 7 3 2 6 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 -4 5 1 0 4 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 +4 0 1 2 3 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 0 +4 5 4 7 6 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 1 +4 6 2 1 5 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 2 +4 3 7 4 0 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 3 +4 7 3 2 6 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 4 +4 5 1 0 4 8 1.0 1.0 -1.0 -1.0 0.0 0.0 -0.5 -0.5 5 diff --git a/src/Unittests/unittests_read_write_PLY.cc b/src/Unittests/unittests_read_write_PLY.cc index 4a4a1799..a0a3115d 100644 --- a/src/Unittests/unittests_read_write_PLY.cc +++ b/src/Unittests/unittests_read_write_PLY.cc @@ -460,14 +460,8 @@ TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithCustomProps) { OpenMesh::VPropHandleT qualityProp; OpenMesh::VPropHandleT indexProp; - EXPECT_TRUE(mesh.get_property_handle(qualityProp,"quality")) << "Could not access quality property"; - EXPECT_TRUE(mesh.get_property_handle(indexProp,"index")) << "Could not access index property"; - - if (!mesh.get_property_handle(qualityProp,"quality")) - return; - - if (!mesh.get_property_handle(indexProp,"index")) - return; + ASSERT_TRUE(mesh.get_property_handle(qualityProp,"quality")) << "Could not access quality property"; + ASSERT_TRUE(mesh.get_property_handle(indexProp,"index")) << "Could not access index property"; //check index property for (unsigned i = 0; i < mesh.n_vertices(); ++i) @@ -486,9 +480,7 @@ TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithCustomProps) { //check for custom list properties OpenMesh::VPropHandleT< std::vector > testValues; - EXPECT_TRUE(mesh.get_property_handle(testValues,"test_values")) << "Could not access texcoords per face"; - if (!mesh.get_property_handle(testValues,"test_values")) - return; + ASSERT_TRUE(mesh.get_property_handle(testValues,"test_values")) << "Could not access texcoords per face"; EXPECT_EQ(2u,mesh.property(testValues,OpenMesh::VertexHandle(0)).size()) << "Wrong verctor size"; @@ -502,10 +494,7 @@ TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithCustomProps) { EXPECT_EQ(16,mesh.property(testValues,OpenMesh::VertexHandle(7))[1]) << "Wrong list value at Vertex 7"; OpenMesh::FPropHandleT< std::vector > texCoordsPerFace; - EXPECT_TRUE(mesh.get_property_handle(texCoordsPerFace,"texcoords")) << "Could not access texcoords per face"; - - if (!mesh.get_property_handle(texCoordsPerFace,"texcoords")) - return; + ASSERT_TRUE(mesh.get_property_handle(texCoordsPerFace,"texcoords")) << "Could not access texcoords per face"; for (Mesh::FaceIter f_iter = mesh.faces_begin(); f_iter != mesh.faces_end(); ++f_iter) { @@ -524,7 +513,16 @@ TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithCustomProps) { } + OpenMesh::FPropHandleT< unsigned > faceIndex; + ASSERT_TRUE(mesh.get_property_handle(faceIndex,"faceIndex")) << "Could not access faceIndex per face"; + EXPECT_EQ(0u,mesh.property(faceIndex,OpenMesh::FaceHandle(0))) << "Wrong index value at FaceHandle 0"; + EXPECT_EQ(1u,mesh.property(faceIndex,OpenMesh::FaceHandle(1))) << "Wrong index value at FaceHandle 1"; + EXPECT_EQ(2u,mesh.property(faceIndex,OpenMesh::FaceHandle(2))) << "Wrong index value at FaceHandle 2"; + EXPECT_EQ(3u,mesh.property(faceIndex,OpenMesh::FaceHandle(3))) << "Wrong index value at FaceHandle 3"; + EXPECT_EQ(4u,mesh.property(faceIndex,OpenMesh::FaceHandle(4))) << "Wrong index value at FaceHandle 4"; + EXPECT_EQ(5u,mesh.property(faceIndex,OpenMesh::FaceHandle(5))) << "Wrong index value at FaceHandle 5"; } + }