-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds in-memory PCD serialization/deserialization; de-duplicates PCDReader::readHeader(). (take #2) #1986
Adds in-memory PCD serialization/deserialization; de-duplicates PCDReader::readHeader(). (take #2) #1986
Conversation
…tream &os as a parameter, instead of using a local std::ostringstream oss and returning a std::string. Updated docstring of std::ostream & version, in order to describe return value. Added overload of PCDWriter::generateHeaderBinaryCompressed() for compatibility with legacy code. Internally, the std::ostream & version is still used to avoid needless string copies. Added an overload of PCDWriter::writeBinaryCompressed () that writes to a std::ostream. Changed existing PCDWriter::writeBinaryCompressed () implementation to simply utilize the std::ostream version, then write the result to a file.
…nd the entire body (259 lines) copied. Upon diffing the two, no meaningful differences were found. The overload was made to call the original, in order to avoid them drifting out of sync.
Updated docstring of PCDReader::readHeader() to indicate which members of the cloud parameter are modified.
…o support reading PCD-serialized point clouds from memory. This also simplifies PCDReader::read(), leaving it just to deal with opening & closing files.
…>() calls. Added TEST (PCL, LZFInMem), to exercise new functionality for reading & writing std::iostreams.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an excellent PR. Thanks!
io/src/pcd_io.cpp
Outdated
// Compress the valid data | ||
unsigned int compressed_size = pcl::lzfCompress (only_valid_data, | ||
unsigned int compressed_size = pcl::lzfCompress (&only_valid_data.front (), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Informative note, std::vector exposes a .data() method which does exactly this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
...another C++11 improvement I seem to have missed. I've long used std::string::data(), when null-termination wasn't needed. Nice to see it in std::vector.
Feel free to change it, if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, it's a C++11 feature, so we can not integrate it anyway.
* * < 0 (-1) on error | ||
* * == 0 on success | ||
*/ | ||
int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the code this feels like it should return a Boolean instead of an integer. Was it to keep it consistent with all other methods returning integers as status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes (see #1869 (comment))
This supersedes #1869, in order to coalesce the changes into a smaller number of commits, each of which conforms to white space & naming conventions and avoids test failures.