Commit 59b0cafe authored by Matthias Möller's avatar Matthias Möller

- 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
parent 324acba2
......@@ -239,6 +239,10 @@ void _PLYReader_::readCustomProperty(std::istream& _in, BaseImporter& _bi, Handl
case ValueTypeCHAR:
assignCustomProperty<char>(_in,_bi,_h,_propName,isList);
break;
case ValueTypeUINT8:
case ValueTypeUCHAR:
assignCustomProperty<unsigned char>(_in,_bi,_h,_propName,isList);
break;
case ValueTypeINT16:
case ValueTypeSHORT:
assignCustomProperty<short>(_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)
......
......@@ -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
......@@ -460,14 +460,8 @@ TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithCustomProps) {
OpenMesh::VPropHandleT<float> qualityProp;
OpenMesh::VPropHandleT<unsigned int> 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<int> > 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<float> > 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";
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment