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> >;
73 scalars->SetNumberOfComponents (3);
75 vtkIdType nr_points =
static_cast<vtkIdType
>(
cloud_->size ());
76 reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->SetNumberOfTuples (nr_points);
77 unsigned char* colors =
reinterpret_cast<vtkUnsignedCharArray*
>(&(*scalars))->GetPointer (0);
80 if (nr_points !=
static_cast<vtkIdType
>(rgb_->size ()))
81 std::fill_n(colors, nr_points * 3, (
unsigned char)0xFF);
83 for (vtkIdType cp = 0; cp < nr_points; ++cp)
86 colors[idx + 0] = (*rgb_)[cp].r;
87 colors[idx + 1] = (*rgb_)[cp].g;
88 colors[idx + 2] = (*rgb_)[cp].b;
94 std::string getFieldName ()
const override {
return (
"rgb"); }
95 inline std::string getName ()
const override {
return (
"PointCloudColorHandlerRGBHack"); }
96 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
vtkSmartPointer< vtkDataArray > getColor() 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.