Commit 437257de authored by Isaak Lim's avatar Isaak Lim
Browse files

added some checks so that empty lines and comments are skipped.

closes #780

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14591 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 2e198ce3
......@@ -399,7 +399,14 @@ bool FileOFFPlugin::readFileOptions(QString _filename, OFFImporter& _importer) {
// Get whole line since there could be comments in it
getCleanLine(ifs, str);
sstr.str(str);
// check if #vertices, #faces and #edges follow
// on the next line
if ( str.compare("OFF") == 0 ) {
getCleanLine(ifs, str);
sstr.str(str);
}
// + #Vertices, #Faces, #Edges
sstr >> nV;
sstr >> nF;
......@@ -601,6 +608,16 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy
// Reserve memory
_importer.reserve(nV, nF * _importer.maxFaceValence() /*Upper bound*/, nF);
// skip empty lines and comments
std::string tmp;
while (true) {
char c = _in.peek();
if ( (c == '\n') || (c == '#') )
std::getline(_in, tmp);
else
break;
}
// read vertices: coord [hcoord] [normal] [color] [texcoord]
for (uint i=0; i<nV && !_in.eof(); ++i) {
......@@ -681,7 +698,16 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy
}
}
}
// skip empty lines and comments
while (true) {
char c = _in.peek();
if ( (c == '\n') || (c == '#') )
std::getline(_in, tmp);
else
break;
}
// faces
// #N <v1> <v2> .. <v(n-1)> [color spec]
for (uint i=0; i<nF; ++i)
......
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