Merge branch 'ply_fix' into 'master'

Ply fix

Closes #64

See merge request OpenMesh/OpenMesh!208
This commit is contained in:
Jan Möbius
2019-02-04 09:43:47 +01:00
4 changed files with 1298 additions and 8 deletions

View File

@@ -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>

View File

@@ -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;

File diff suppressed because it is too large Load Diff

View File

@@ -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
*/