Commit 26b3682c authored by Jan Möbius's avatar Jan Möbius

Merge branch 'ply_fix' into 'master'

Ply fix

Closes #64

See merge request !208
parents f2d07dc9 4c2c8f34
Pipeline #8448 passed with stages
in 51 minutes and 47 seconds
......@@ -27,6 +27,7 @@
<li>PLY Reader: Allowing the PLY reader to read custom face ( Thanks to morgan Leborgne for the patch)</li>
<li>PLY Reader: Fixed endless loop on unknown property list type</li>
<li>PLY Reader: Fix hang when reading directly from istream (Thanks to Paul Loré for the patch)</li>
<li>PLY Reader: Fix file load for ASCII PLY without a newline at the end of the file (Thanks to Mathieu Lamarre for the patch )
<li>OM Writer/Reader: Update file format version to 2.0. Older files can still be read, but older OpenMesh versions cannot read new format.</li>
<li>OM Writer/Reader: Fixed inconsistent writing/reading of edge properties</li>
<li>OM Writer/Reader: Add option to store status</li>
......
......@@ -306,6 +306,14 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
for (std::vector<ElementInfo>::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;
......
This diff is collapsed.
......@@ -81,6 +81,24 @@ TEST_F(OpenMeshReadWritePLY, LoadSimplePLY) {
}
/*
* Load a ply ascii file without a newline at the end of the file
*
*/
TEST_F(OpenMeshReadWritePLY, LoadSimplePLYNoEndl) {
mesh_.clear();
bool ok = OpenMesh::IO::read_mesh(mesh_, "sphere840.ply");
EXPECT_TRUE(ok) << "Unable to load sphere840.ply";
EXPECT_EQ(422u , mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
EXPECT_EQ(1260u , mesh_.n_edges()) << "The number of loaded edges is not correct!";
EXPECT_EQ(840u , mesh_.n_faces()) << "The number of loaded faces is not correct!";
}
/*
* Just load a ply file and set vertex color option before loading
*/
......
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