PointCloudLibrary/pcl — pull request #465 by taketwo (2014-01-23 22:36:56+00:00)
Title: Add a function to copy data between points of different types

This pull request adds a new function that allows to copy data between points of different types:

```cpp
template void
copyPoint (const PointInT& point_in, PointOutT& point_out);
```

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:
* both have RGB fields;
* both have RGBA fields;
* one or both have no RGB/RGBA fields.

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 of `copyPointCloud()` 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.