OpenMesh issueshttps://gitlab.vci.rwth-aachen.de:9000/OpenMesh/OpenMesh/-/issues2022-05-10T15:03:17Zhttps://gitlab.vci.rwth-aachen.de:9000/OpenMesh/OpenMesh/-/issues/80PLY reader fails with face properties before `vertex_indices`2022-05-10T15:03:17ZSven-Kristofer PilzPLY reader fails with face properties before `vertex_indices`It seems the PLY parser forgets to actually skip face properties before `vertex_indices`, resulting in a misread file.
For example:
```
ply
format ascii 1.0
element vertex 3
property float x
property float y
property float z
element fac...It seems the PLY parser forgets to actually skip face properties before `vertex_indices`, resulting in a misread file.
For example:
```
ply
format ascii 1.0
element vertex 3
property float x
property float y
property float z
element face 1
property int bad_property
property list uchar int vertex_indices
end_header
```
For me, the following (removing `elements_.back().properties_.clear();`) worked:
```diff
diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc
index 5ab21b74..8ba7abc3 100644
--- a/src/OpenMesh/Core/IO/reader/PLYReader.cc
+++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc
diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc
index 5ab21b74..8ba7abc3 100644
--- a/src/OpenMesh/Core/IO/reader/PLYReader.cc
+++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc
@@ -529,7 +529,7 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
omerr().enable();
if (complex_faces)
- omerr() << complex_faces << "The reader encountered invalid faces, that could not be added.\n";
+ omerr() << "The reader encountered invalid faces (" << complex_faces << "), that could not be added.\n";
// File was successfully parsed.
return true;
@@ -783,7 +783,7 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
omerr().enable();
if (complex_faces)
- omerr() << complex_faces << "The reader encountered invalid faces, that could not be added.\n";
+ omerr() << "The reader encountered invalid faces (" << complex_faces << "), that could not be added.\n";
return true;
@@ -1298,7 +1298,6 @@ bool _PLYReader_::can_u_read(std::istream& _is) const {
if (!elements_.back().properties_.empty())
{
omerr() << "Custom face Properties defined, before 'vertex_indices' property was defined. They will be skipped" << std::endl;
- elements_.back().properties_.clear();
}
} else {
options_ += Options::Custom;
diff --git a/src/Unittests/TestFiles/property_before_face_vertex_list.ply b/src/Unittests/TestFiles/property_before_face_vertex_list.ply
new file mode 100644
index 00000000..f0dff8f9
--- /dev/null
+++ b/src/Unittests/TestFiles/property_before_face_vertex_list.ply
@@ -0,0 +1,14 @@
+ply
+format ascii 1.0
+element vertex 3
+property float x
+property float y
+property float z
+element face 1
+property int bad_property
+property list uchar int vertex_indices
+end_header
+-1.0 0.0 0.0
+1.0 0.0 0.0
+0.0 1.0 0.0
+0 3 0 1 2
diff --git a/src/Unittests/unittests_read_write_PLY.cc b/src/Unittests/unittests_read_write_PLY.cc
index 9cb614d7..ac797998 100644
--- a/src/Unittests/unittests_read_write_PLY.cc
+++ b/src/Unittests/unittests_read_write_PLY.cc
@@ -633,6 +633,21 @@ TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithCustomProps) {
}
+TEST_F(OpenMeshReadWritePLY, LoadWithFacePropertyBeforeVertexList) {
+ PolyMesh mesh;
+
+ OpenMesh::IO::Options options;
+ options += OpenMesh::IO::Options::Custom;
+
+ bool ok = OpenMesh::IO::read_mesh(mesh, "property_before_face_vertex_list.ply", options);
+
+ EXPECT_TRUE(ok) << "Unable to load property_before_face_vertex_list.ply";
+
+ EXPECT_EQ(3u , mesh.n_vertices()) << "The number of loaded vertices is not correct!";
+ EXPECT_EQ(3u , mesh.n_edges()) << "The number of loaded edges is not correct!";
+ EXPECT_EQ(1u , mesh.n_faces()) << "The number of loaded faces is not correct!";
+}
+
/*
* Just load a ply with custom properties, binary mode
*/
```https://gitlab.vci.rwth-aachen.de:9000/OpenMesh/OpenMesh/-/issues/54get_property inconsistent return value over build configs2020-04-02T07:39:21ZMatthias Möllerget_property inconsistent return value over build configsHi,
consider the following code:
```c++
Mesh mesh;
std::string = "prop";
VPropHandleT<float> prop_float;
mesh.add_property(prop_float, name);
VPropHandleT<Vec3d> prop_vec; //<-- different type
bool result = mesh.get_property_handle(pro...Hi,
consider the following code:
```c++
Mesh mesh;
std::string = "prop";
VPropHandleT<float> prop_float;
mesh.add_property(prop_float, name);
VPropHandleT<Vec3d> prop_vec; //<-- different type
bool result = mesh.get_property_handle(prop_vec, name); //<-- request handle with wrong type
```
The output in result depends on the Build Configuration.
- In Debug mode, following holds: `result==false`
- In Release mode, following holds: `result==true`
It is because in "PropertyContainer.h", the type check is disabled in Release mode (line 126-128).
The function should return the same value over the different
build configurations.
(I would prefer the type check enabled, because it seems to be complex, checking outside of the PropertyContainer if the type of your prophandle is the correct one
__edit__ or provide an additional member-function "has_type", or something like this, skipping the dynamic_cast in get_property)