37 #ifndef COLOR_HANDLER_H_
38 #define COLOR_HANDLER_H_
41 #include <pcl/point_cloud.h>
42 #include <pcl/visualization/point_cloud_handlers.h>
46 namespace visualization
48 template <
typename Po
intT>
58 typedef boost::shared_ptr<PointCloudColorHandlerRGBHack<PointT> >
Ptr;
59 typedef boost::shared_ptr<const PointCloudColorHandlerRGBHack<PointT> >
ConstPtr;
75 scalars->SetNumberOfComponents (3);
77 vtkIdType nr_points = (int)
cloud_->points.size ();
78 reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->SetNumberOfTuples (nr_points);
79 unsigned char* colors =
reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->GetPointer (0);
82 if (nr_points != (
int)rgb_->points.size ())
83 std::fill(colors, colors + nr_points * 3, (
unsigned char)0xFF);
85 for (vtkIdType cp = 0; cp < nr_points; ++cp)
88 colors[idx + 0] = rgb_->points[cp].r;
89 colors[idx + 1] = rgb_->points[cp].g;
90 colors[idx + 2] = rgb_->points[cp].b;
96 virtual std::string getFieldName ()
const {
return (
"rgb"); }
97 virtual inline std::string getName ()
const {
return (
"PointCloudColorHandlerRGBHack"); }
98 RgbCloudConstPtr rgb_;