Skip to content

Commit

Permalink
skip empty lines in ASCII before properties (#27)
Browse files Browse the repository at this point in the history
* bugfix: skip empty lines

* don't skip blanks with properties, add comments

* add version note

Co-authored-by: Dean <zhang.fuwen@qq.com>
Co-authored-by: Nicholas Sharp <nsharp@cs.cmu.edu>
  • Loading branch information
3 people committed Aug 22, 2020
1 parent 661b6f5 commit 88f7972
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions happly.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SOFTWARE.
Significant changes to the file recorded here.
- Version 5 (Aug 22, 2020) Minor: skip blank lines before properties in ASCII files
- Version 4 (Sep 11, 2019) Change internal list format to be flat. Other small perf fixes and cleanup.
- Version 3 (Aug 1, 2019) Add support for big endian and obj_info
- Version 2 (July 20, 2019) Catch exceptions by const reference.
Expand Down Expand Up @@ -500,7 +501,7 @@ class TypedListProperty : public Property {
if (count > 0) {
stream.read((char*)&flattenedData[currSize], count * sizeof(T));
}
flattenedIndexStart.emplace_back(afterSize);
flattenedIndexStart.emplace_back(afterSize);
}

/**
Expand Down Expand Up @@ -528,7 +529,7 @@ class TypedListProperty : public Property {
if (count > 0) {
stream.read((char*)&flattenedData[currSize], count * sizeof(T));
}
flattenedIndexStart.emplace_back(afterSize);
flattenedIndexStart.emplace_back(afterSize);

// Swap endian order of list elements
for (size_t iFlat = currSize; iFlat < afterSize; iFlat++) {
Expand Down Expand Up @@ -1846,6 +1847,14 @@ class PLYData {
string line;
std::getline(inStream, line);

// Some .ply files seem to include empty lines before the start of property data (though this is not specified
// in the format description). We attempt to recover and parse such files by skipping any empty lines.
if (!elem.properties.empty()) { // if the element has no properties, the line _should_ be blank, presumably
while (line.empty()) { // skip lines until we hit something nonempty
std::getline(inStream, line);
}
}

vector<string> tokens = tokenSplit(line);
size_t iTok = 0;
for (size_t iP = 0; iP < elem.properties.size(); iP++) {
Expand Down

0 comments on commit 88f7972

Please sign in to comment.