40 #include <pcl/point_cloud.h>
41 #include <pcl/visualization/point_cloud_handlers.h>
45 namespace visualization
47 template <
typename Po
intT>
57 using Ptr = shared_ptr<PointCloudColorHandlerRGBHack<PointT> >;
58 using ConstPtr = shared_ptr<const PointCloudColorHandlerRGBHack<PointT> >;
74 scalars->SetNumberOfComponents (3);
76 vtkIdType nr_points =
static_cast<vtkIdType
>(
cloud_->size ());
77 reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->SetNumberOfTuples (nr_points);
78 unsigned char* colors =
reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->GetPointer (0);
81 if (nr_points !=
static_cast<vtkIdType
>(rgb_->size ()))
82 std::fill(colors, colors + nr_points * 3, (
unsigned char)0xFF);
84 for (vtkIdType cp = 0; cp < nr_points; ++cp)
87 colors[idx + 0] = (*rgb_)[cp].r;
88 colors[idx + 1] = (*rgb_)[cp].g;
89 colors[idx + 2] = (*rgb_)[cp].b;
95 std::string getFieldName ()
const override {
return (
"rgb"); }
96 inline std::string getName ()
const override {
return (
"PointCloudColorHandlerRGBHack"); }
97 RgbCloudConstPtr rgb_;
shared_ptr< const PointCloud< PointT > > ConstPtr
Base Handler class for PointCloud colors.
bool capable_
True if this handler is capable of handling the input data, false otherwise.
PointCloudConstPtr cloud_
A pointer to the input dataset.
shared_ptr< const PointCloudColorHandlerRGBHack< PointT > > ConstPtr
shared_ptr< PointCloudColorHandlerRGBHack< PointT > > Ptr
bool getColor(vtkSmartPointer< vtkDataArray > &scalars) const override
Obtain the actual color for the input dataset as a VTK data array.
PointCloudColorHandlerRGBHack(const PointCloudConstPtr &cloud, const RgbCloudConstPtr &colors)
Defines all the PCL implemented PointT point type structures.
A point structure representing Euclidean xyz coordinates, and the RGB color.