MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / getColor

Method getColor

visualization/src/point_cloud_handlers.cpp:47–71  ·  view source on GitHub ↗

//////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

45
46///////////////////////////////////////////////////////////////////////////////////////////
47vtkSmartPointer<vtkDataArray>
48pcl::visualization::PointCloudColorHandlerCustom<pcl::PCLPointCloud2>::getColor () const
49{
50 if (!capable_ || !cloud_)
51 return nullptr;
52
53 auto scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();
54 scalars->SetNumberOfComponents (3);
55
56 vtkIdType nr_points = cloud_->width * cloud_->height;
57 scalars->SetNumberOfTuples (nr_points);
58
59 // Get a random color
60 auto* colors = new unsigned char[nr_points * 3];
61
62 // Color every point
63 for (vtkIdType cp = 0; cp < nr_points; ++cp)
64 {
65 colors[cp * 3 + 0] = static_cast<unsigned char> (r_);
66 colors[cp * 3 + 1] = static_cast<unsigned char> (g_);
67 colors[cp * 3 + 2] = static_cast<unsigned char> (b_);
68 }
69 scalars->SetArray (colors, 3 * nr_points, 0, vtkUnsignedCharArray::VTK_DATA_ARRAY_DELETE);
70 return scalars;
71}
72
73///////////////////////////////////////////////////////////////////////////////////////////
74vtkSmartPointer<vtkDataArray>

Callers 4

OnKeyDownMethod · 0.45
fromHandlersToScreenMethod · 0.45

Calls 7

NewFunction · 0.85
getFieldSizeFunction · 0.85
atFunction · 0.85
sizeFunction · 0.85
SetArrayMethod · 0.80
getFieldIndexFunction · 0.50
insertMethod · 0.45

Tested by

no test coverage detected