diff --git a/Doc/changelog.docu b/Doc/changelog.docu index f336bf26..57845d21 100644 --- a/Doc/changelog.docu +++ b/Doc/changelog.docu @@ -17,6 +17,7 @@ IO diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc index f86caae0..2d04f68a 100644 --- a/src/OpenMesh/Core/IO/reader/PLYReader.cc +++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc @@ -304,6 +304,11 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options return false; } + const bool err_enabled = omerr().is_enabled(); + size_t complex_faces = 0; + if (err_enabled) + omerr().disable(); + // read vertices: for (i = 0; i < vertexCount_ && !_in.eof(); ++i) { vh = _bi.add_vertex(); @@ -432,6 +437,8 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options } fh = _bi.add_face(vhandles); + if (!fh.is_valid()) + ++complex_faces; break; case CUSTOM_PROP: @@ -449,6 +456,12 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options } + if (err_enabled) + omerr().enable(); + + if (complex_faces) + omerr() << complex_faces << "The reader encountered invalid faces, that could not be added.\n"; + // File was successfully parsed. return true; } @@ -472,6 +485,11 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap _bi.reserve(vertexCount_, 3* vertexCount_ , faceCount_); + const bool err_enabled = omerr().is_enabled(); + size_t complex_faces = 0; + if (err_enabled) + omerr().disable(); + // read vertices: for (unsigned int i = 0; i < vertexCount_ && !_in.eof(); ++i) { vh = _bi.add_vertex(); @@ -610,6 +628,8 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap } fh = _bi.add_face(vhandles); + if (!fh.is_valid()) + ++complex_faces; break; case CUSTOM_PROP: @@ -626,6 +646,13 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap } } + if (err_enabled) + omerr().enable(); + + if (complex_faces) + omerr() << complex_faces << "The reader encountered invalid faces, that could not be added.\n"; + + return true; }