Merge branch 'ply_reader_omerr_fix' into 'master'

don't emit an error message for every face that could not be added (due to complex elements)



See merge request !55
This commit is contained in:
Jan Möbius
2016-04-15 16:20:12 +02:00
2 changed files with 28 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
<b>IO</b> <b>IO</b>
<ul> <ul>
<li>Obj reader: added texCoord3d functions to objloader</li> <li>Obj reader: added texCoord3d functions to objloader</li>
<li>PLY Reader: Don't emit warning for every complex face but warn only once in the end.</li>
<li>Importer: Integrate non-manifold faces while importing and not at the end. Fixes missing properties on non-manifolds. (Thanks to Max Limper for the patch, Merge Request 51)<li> <li>Importer: Integrate non-manifold faces while importing and not at the end. Fixes missing properties on non-manifolds. (Thanks to Max Limper for the patch, Merge Request 51)<li>
</ul> </ul>

View File

@@ -304,6 +304,11 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
return false; return false;
} }
const bool err_enabled = omerr().is_enabled();
size_t complex_faces = 0;
if (err_enabled)
omerr().disable();
// read vertices: // read vertices:
for (i = 0; i < vertexCount_ && !_in.eof(); ++i) { for (i = 0; i < vertexCount_ && !_in.eof(); ++i) {
vh = _bi.add_vertex(); vh = _bi.add_vertex();
@@ -432,6 +437,8 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
} }
fh = _bi.add_face(vhandles); fh = _bi.add_face(vhandles);
if (!fh.is_valid())
++complex_faces;
break; break;
case CUSTOM_PROP: 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. // File was successfully parsed.
return true; return true;
} }
@@ -472,6 +485,11 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
_bi.reserve(vertexCount_, 3* vertexCount_ , faceCount_); _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: // read vertices:
for (unsigned int i = 0; i < vertexCount_ && !_in.eof(); ++i) { for (unsigned int i = 0; i < vertexCount_ && !_in.eof(); ++i) {
vh = _bi.add_vertex(); vh = _bi.add_vertex();
@@ -610,6 +628,8 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap
} }
fh = _bi.add_face(vhandles); fh = _bi.add_face(vhandles);
if (!fh.is_valid())
++complex_faces;
break; break;
case CUSTOM_PROP: 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; return true;
} }