//////////////////////////////////////////////////////////////////////////////////////
| 45 | |
| 46 | /////////////////////////////////////////////////////////////////////////////////////////// |
| 47 | vtkSmartPointer<vtkDataArray> |
| 48 | pcl::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 | /////////////////////////////////////////////////////////////////////////////////////////// |
| 74 | vtkSmartPointer<vtkDataArray> |
no test coverage detected