Skip to content
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

Merged
merged 6 commits into from
Sep 22, 2017

Conversation

mattgruenke
Copy link
Contributor

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.

…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.
Copy link
Member

@taketwo taketwo left a 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!

@taketwo taketwo added this to the pcl-1.9.0 milestone Sep 4, 2017
// Compress the valid data
unsigned int compressed_size = pcl::lzfCompress (only_valid_data,
unsigned int compressed_size = pcl::lzfCompress (&only_valid_data.front (),
Copy link
Member

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.

Copy link
Contributor Author

@mattgruenke mattgruenke Sep 6, 2017

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.

Copy link
Member

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
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes (see #1869 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants