From 4c2c8f34c06ca6a09b91ead728af539ec1048916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 4 Feb 2019 08:52:41 +0100 Subject: [PATCH] - PLY Reader: Fix file load for ASCII PLY without a newline at the end of the file (Thanks to Mathieu Lamarre for the patch ) closes #64 --- Doc/changelog.docu | 1 + src/OpenMesh/Core/IO/reader/PLYReader.cc | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Doc/changelog.docu b/Doc/changelog.docu index b497a8b6..4f12db85 100644 --- a/Doc/changelog.docu +++ b/Doc/changelog.docu @@ -27,6 +27,7 @@
  • PLY Reader: Allowing the PLY reader to read custom face ( Thanks to morgan Leborgne for the patch)
  • PLY Reader: Fixed endless loop on unknown property list type
  • PLY Reader: Fix hang when reading directly from istream (Thanks to Paul LorĂ© for the patch)
  • +
  • PLY Reader: Fix file load for ASCII PLY without a newline at the end of the file (Thanks to Mathieu Lamarre for the patch )
  • OM Writer/Reader: Update file format version to 2.0. Older files can still be read, but older OpenMesh versions cannot read new format.
  • OM Writer/Reader: Fixed inconsistent writing/reading of edge properties
  • OM Writer/Reader: Add option to store status
  • diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc index 1b35d53d..4617afe9 100644 --- a/src/OpenMesh/Core/IO/reader/PLYReader.cc +++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc @@ -306,6 +306,14 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options for (std::vector::iterator e_it = elements_.begin(); e_it != elements_.end(); ++e_it) { + if (_in.eof()) { + if (err_enabled) + omerr().enable(); + + omerr() << "Unexpected end of file while reading." << std::endl; + return false; + } + if (e_it->element_== VERTEX) { // read vertices: @@ -475,14 +483,6 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options } } - if (_in.eof()) { - if (err_enabled) - omerr().enable(); - - omerr() << "Unexpected end of file while reading." << std::endl; - return false; - } - if(e_it->element_== FACE) // stop reading after the faces since additional elements are not preserved anyway break; -- GitLab