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

Method convertPointCloudToVTKPolyData

visualization/src/pcl_visualizer.cpp:1258–1315  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1256}
1257/////////////////////////////////////////////////////////////////////////////////////////////
1258void
1259pcl::visualization::PCLVisualizer::convertPointCloudToVTKPolyData (
1260 const GeometryHandlerConstPtr &geometry_handler,
1261 vtkSmartPointer<vtkPolyData> &polydata,
1262 vtkSmartPointer<vtkIdTypeArray> &initcells)
1263{
1264 vtkSmartPointer<vtkCellArray> vertices;
1265
1266 if (!polydata)
1267 {
1268 allocVtkPolyData (polydata);
1269 vertices = vtkSmartPointer<vtkCellArray>::New ();
1270 polydata->SetVerts (vertices);
1271 }
1272
1273 // Use the handler to obtain the geometry
1274 vtkSmartPointer<vtkPoints> points;
1275 geometry_handler->getGeometry (points);
1276 polydata->SetPoints (points);
1277
1278 vtkIdType nr_points = points->GetNumberOfPoints ();
1279
1280 // Create the supporting structures
1281 vertices = polydata->GetVerts ();
1282 if (!vertices)
1283 vertices = vtkSmartPointer<vtkCellArray>::New ();
1284
1285#ifdef VTK_CELL_ARRAY_V2
1286 // TODO: Remove when VTK 6,7,8 is unsupported
1287 pcl::utils::ignore(initcells);
1288
1289 auto numOfCells = vertices->GetNumberOfCells();
1290
1291 // If we have less cells than points, add new cells.
1292 if (numOfCells < nr_points)
1293 {
1294 for (int i = numOfCells; i < nr_points; i++)
1295 {
1296 vertices->InsertNextCell(1);
1297 vertices->InsertCellPoint(i);
1298 }
1299 }
1300 // if we too many cells than points, set size (doesn't free excessive memory)
1301 else if (numOfCells > nr_points)
1302 {
1303 vertices->ResizeExact(nr_points, nr_points);
1304 }
1305
1306 polydata->SetPoints(points);
1307 polydata->SetVerts(vertices);
1308
1309#else
1310 vtkSmartPointer<vtkIdTypeArray> cells = vertices->GetData ();
1311 updateCells (cells, initcells, nr_points);
1312 // Set the cells and the vertices
1313 vertices->SetCells (nr_points, cells);
1314#endif
1315}

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
ignoreFunction · 0.85
getGeometryMethod · 0.45
SetPointsMethod · 0.45

Tested by

no test coverage detected