Add a function to copy data between points of different types #465
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds a new function that allows to copy data between points of different types:
The function has several specializations, which the compiler instantiates depending on the particular combination of input and output point types.
There are three cases:
Points have the same type.
In this case a single
memcpy
is used.Points have different types and one of the following is true:
There is no RGB/RGBA mismatch involved, so we simply find the list of common fields and copy their contents one by one with
NdConcatenateFunctor
.Points have different types and one of these types has RGB field, and the other has RGBA field.
In this case we also find the list of common fields and copy their contents. In order to account for the fact that RGB and RGBA do not match we have an additional
memcpy
to copy the contents of one into another.All decisions are made at compilation time, so at run time only the copy instructions are called.
This pull request also adds a unit test for
copyPoint()
and updates the family ofcopyPointCloud()
functions to use it. This dramatically simplifies them.Finally, I searched through the PCL code to identify places where the authors intended to copy data between different point types, and replaced it with
copyPoint()
calls. I should note that in all cases the existing code did not account for RGB/RGBA mismatch, so this update potentially fixes some not-yet-discovered bugs for certain pairs of point types.