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_;
boost::shared_ptr< PointCloudColorHandlerRGBHack< PointT > > Ptr
Base Handler class for PointCloud colors.
Defines all the PCL implemented PointT point type structures.
PointCloudColorHandlerRGBHack(const PointCloudConstPtr &cloud, const RgbCloudConstPtr &colors)
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
boost::shared_ptr< const PointCloudColorHandlerRGBHack< PointT > > ConstPtr
PointCloudConstPtr cloud_
A pointer to the input dataset.
A point structure representing Euclidean xyz coordinates, and the RGB color.
bool capable_
True if this handler is capable of handling the input data, false otherwise.
virtual bool getColor(vtkSmartPointer< vtkDataArray > &scalars) const
Obtain the actual color for the input dataset as vtk scalars.