Skip to content

Replace deprecated/removed VTK functions - #6456

Open
mvieth wants to merge 2 commits into
PointCloudLibrary:masterfrom
mvieth:vtk_replace_deprecated
Open

Replace deprecated/removed VTK functions#6456
mvieth wants to merge 2 commits into
PointCloudLibrary:masterfrom
mvieth:vtk_replace_deprecated

Conversation

@mvieth

@mvieth mvieth commented Aug 3, 2026

Copy link
Copy Markdown
Member

Fixes #6453

Several VTK functions are marked as deprecated in VTK 9.6.0 and removed in VTK 9.7.0:

  • SetCells in line_cells->SetCells (n_corr, line_cells_id); is deprecated/removed. I added a new branch (for VTK >= 9.6.0) that uses the modern approach line_cells->InsertNextCell(line);. I also fixed the computation of n_corr.
  • GetData in cell_array->GetData ()->SetNumberOfValues (idx); is deprecated/removed. I moved it into details::fillCell, into the "old" branch where VTK_CELL_ARRAY_V2 is not defined. As far as I see, the new branch in details::fillCell does not need the SetNumberOfValues call because it uses InsertNextCell and InsertCellPoint
  • GetData in reinterpret_cast<vtkPolyDataMapper*>(actor->GetMapper ())->GetInput ()->GetVerts ()->GetData (); is deprecated/removed. I replaced it with ExportLegacyFormat, although I am not sure whether it makes sense to keep cloud_actor.cells in the long term (might be worth to discuss again in the future, but not high priority)

@mvieth mvieth added module: visualization changelog: fix Meta-information for changelog generation labels Aug 3, 2026
*cell++ = vertj;
}
}
cell_array->GetData ()->SetNumberOfValues (idx);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetData is deprecated and has been removed on VTK 9.7

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 deprecated vtkCellArray::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 j only for valid correspondences. line_cells_id is then resized to j, but SetCells is still called with n_corr. If any correspondences are skipped, this can make vtkCellArray read more cells than are actually present in line_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.

Comment thread visualization/include/pcl/visualization/impl/pcl_visualizer.hpp
Comment thread visualization/include/pcl/visualization/impl/pcl_visualizer.hpp
@mvieth
mvieth marked this pull request as ready for review August 4, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: fix Meta-information for changelog generation module: visualization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[compile error] Use of deprecated VTK functions that have been removed in the current version.

4 participants