Replace deprecated/removed VTK functions - #6456
Conversation
| *cell++ = vertj; | ||
| } | ||
| } | ||
| cell_array->GetData ()->SetNumberOfValues (idx); |
There was a problem hiding this comment.
GetData is deprecated and has been removed on VTK 9.7
There was a problem hiding this comment.
Thanks for the comment. This is in the #else branch of #ifdef VTK_CELL_ARRAY_V2, which is only taken if an old VTK version is used: https://gitlab.kitware.com/vtk/vtk/-/blob/master/Common/DataModel/vtkCellArray.h#L164
There was a problem hiding this comment.
Pull request overview
This PR updates PCL’s VTK visualization integration to remain compatible with VTK 9.6+ deprecations and VTK 9.7 removals, primarily by replacing deprecated vtkCellArray APIs and adjusting correspondence rendering logic.
Changes:
- Updated polygon/mesh cell population to avoid deprecated
vtkCellArray::GetData()usage in the modern VTK path. - Updated
addCorrespondences()to avoid deprecatedvtkCellArray::SetCells()for VTK >= 9.6 and fixed correspondence counting. - Added a regression test covering
PCLVisualizer::addCorrespondences().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| visualization/src/pcl_visualizer.cpp | Moves legacy SetNumberOfValues handling into details::fillCells() and replaces a deprecated GetData() usage with ExportLegacyFormat() for VTK >= 9.6. |
| visualization/include/pcl/visualization/impl/pcl_visualizer.hpp | Adds a VTK >= 9.6 branch for correspondence line creation using modern vtkCellArray insertion APIs; adjusts correspondence counting/indexing. |
| test/visualization/test_visualization.cpp | Adds a test that exercises PCLVisualizer::addCorrespondences() to help catch regressions/VTK API breakages. |
Suppressed comments (1)
visualization/include/pcl/visualization/impl/pcl_visualizer.hpp:1340
- In the legacy VTK branch, the loop increments
jonly for valid correspondences.line_cells_idis then resized toj, butSetCellsis still called withn_corr. If any correspondences are skipped, this can makevtkCellArrayread more cells than are actually present inline_cells_id.
line_colors->SetNumberOfTuples (j);
line_cells_id->SetNumberOfTuples (j);
line_cells->SetCells (n_corr, line_cells_id);
line_points->SetNumberOfPoints (j*2);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #6453
Several VTK functions are marked as deprecated in VTK 9.6.0 and removed in VTK 9.7.0:
SetCellsinline_cells->SetCells (n_corr, line_cells_id);is deprecated/removed. I added a new branch (for VTK >= 9.6.0) that uses the modern approachline_cells->InsertNextCell(line);. I also fixed the computation ofn_corr.GetDataincell_array->GetData ()->SetNumberOfValues (idx);is deprecated/removed. I moved it intodetails::fillCell, into the "old" branch whereVTK_CELL_ARRAY_V2is not defined. As far as I see, the new branch indetails::fillCelldoes not need theSetNumberOfValuescall because it usesInsertNextCellandInsertCellPointGetDatainreinterpret_cast<vtkPolyDataMapper*>(actor->GetMapper ())->GetInput ()->GetVerts ()->GetData ();is deprecated/removed. I replaced it withExportLegacyFormat, although I am not sure whether it makes sense to keepcloud_actor.cellsin the long term (might be worth to discuss again in the future, but not high priority)