From c1126ecfb6535d0199827615676a92b648b98a16 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Thu, 6 Aug 2026 15:26:55 +0200 Subject: [PATCH 1/2] Replace deprecated thrust function, fix problems with thrust --- cuda/io/src/disparity_to_cloud.cu | 14 +++++++------- gpu/features/src/centroid.cu | 9 +++++++++ gpu/surface/src/cuda/convex_hull.cu | 5 +++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/cuda/io/src/disparity_to_cloud.cu b/cuda/io/src/disparity_to_cloud.cu index 877f1d63585..29fd3fb3260 100644 --- a/cuda/io/src/disparity_to_cloud.cu +++ b/cuda/io/src/disparity_to_cloud.cu @@ -222,14 +222,14 @@ DisparityToCloud::compute (const std::uint16_t* depth_image, for (int iter = 0; iter < smoothing_nr_iterations; iter++) { - transform ( + thrust::transform ( thrust::make_zip_iterator (make_tuple (depth.begin (), thrust::counting_iterator(0))), thrust::make_zip_iterator (make_tuple (depth.begin (), thrust::counting_iterator(0))) + output_size, depth.begin (), DisparityClampedSmoothing (thrust::raw_pointer_cast(&depth[0]), thrust::raw_pointer_cast(&disp_helper_map[0]), width, height, smoothing_filter_size)); } // Send the data to the device - transform ( + thrust::transform ( thrust::make_zip_iterator (make_tuple (depth.begin (), rgb.begin(), thrust::counting_iterator(0))), thrust::make_zip_iterator (make_tuple (depth.begin (), rgb.begin(), thrust::counting_iterator(0))) + output_size, output->points.begin (), @@ -238,7 +238,7 @@ DisparityToCloud::compute (const std::uint16_t* depth_image, } else { - transform ( + thrust::transform ( thrust::make_zip_iterator (make_tuple (depth.begin(), rgb.begin(), thrust::counting_iterator(0))), thrust::make_zip_iterator (make_tuple (depth.begin(), rgb.begin(), thrust::counting_iterator(0))) + output_size, output->points.begin (), @@ -356,14 +356,14 @@ DisparityToCloud::compute (const openni_wrapper::DepthImage::Ptr& depth_image, for (int iter = 0; iter < smoothing_nr_iterations; iter++) { - transform ( + thrust::transform ( thrust::make_zip_iterator (make_tuple (depth.begin (), thrust::counting_iterator(0))), thrust::make_zip_iterator (make_tuple (depth.begin (), thrust::counting_iterator(0))) + output_size, depth.begin (), DisparityClampedSmoothing (thrust::raw_pointer_cast(&depth[0]), thrust::raw_pointer_cast(&disp_helper_map[0]), output->width, output->height, smoothing_filter_size)); } // Send the data to the device - transform ( + thrust::transform ( thrust::make_zip_iterator (make_tuple (depth.begin (), rgb.begin (), thrust::counting_iterator(0))), thrust::make_zip_iterator (make_tuple (depth.begin (), rgb.begin (), thrust::counting_iterator(0))) + output_size, output->points.begin (), @@ -404,7 +404,7 @@ DisparityToCloud::compute (const openni_wrapper::DepthImage::Ptr& depth_image, else { // Send the data to the device - transform ( + thrust::transform ( thrust::make_zip_iterator (make_tuple (depth.begin (), rgb.begin (), thrust::counting_iterator(0))), thrust::make_zip_iterator (make_tuple (depth.begin (), rgb.begin (), thrust::counting_iterator(0))) + output_size, output->points.begin (), @@ -415,7 +415,7 @@ DisparityToCloud::compute (const openni_wrapper::DepthImage::Ptr& depth_image, else { // Send the data to the device - transform ( + thrust::transform ( thrust::make_zip_iterator (make_tuple (depth.begin (), thrust::counting_iterator(0))), thrust::make_zip_iterator (make_tuple (depth.begin (), thrust::counting_iterator(0))) + output->width * output->height, diff --git a/gpu/features/src/centroid.cu b/gpu/features/src/centroid.cu index 1dbd029cdf6..4761ece9e32 100644 --- a/gpu/features/src/centroid.cu +++ b/gpu/features/src/centroid.cu @@ -36,6 +36,7 @@ #include "internal.hpp" +#include #include #include #include @@ -123,7 +124,11 @@ float3 pcl::device::getMaxDistance(const DeviceArray& cloud, const float thrust::counting_iterator ce = cf + cloud.size(); thrust::tuple init(0.f, 0); +#if THRUST_VERSION >= 300100 + cuda::maximum> op; +#else thrust::maximum> op; +#endif thrust::tuple res = thrust::transform_reduce( @@ -151,7 +156,11 @@ float3 pcl::device::getMaxDistance(const DeviceArray& cloud, const Indic thrust::counting_iterator ce = cf + indices.size(); thrust::tuple init(0.f, 0); +#if THRUST_VERSION >= 300100 + cuda::maximum> op; +#else thrust::maximum> op; +#endif thrust::tuple res = thrust::transform_reduce( make_zip_iterator(make_tuple( make_permutation_iterator(src_beg, map_beg), cf )), diff --git a/gpu/surface/src/cuda/convex_hull.cu b/gpu/surface/src/cuda/convex_hull.cu index 00b49dc082f..13417c8be9c 100644 --- a/gpu/surface/src/cuda/convex_hull.cu +++ b/gpu/surface/src/cuda/convex_hull.cu @@ -44,6 +44,7 @@ //#include #include +#include #include #include #include @@ -136,7 +137,11 @@ namespace pcl int transform_reduce_index(It beg, It end, Unary unop, Init init, Binary binary) { thrust::counting_iterator cbeg(0); +#if THRUST_VERSION >= 300100 + thrust::counting_iterator cend = cbeg + cuda::std::distance(beg, end); +#else thrust::counting_iterator cend = cbeg + thrust::distance(beg, end); +#endif thrust::tuple t = thrust::transform_reduce( thrust::make_zip_iterator(thrust::make_tuple(beg, cbeg)), From 0d3867ec53839c50cb2bac063909c04a27e47488 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Fri, 7 Aug 2026 11:42:18 +0200 Subject: [PATCH 2/2] Replace VTK functions deprecated in VTK 9.7.0 --- .../3d_rec_framework/pc_source/mesh_source.h | 14 +++++++++ .../pcl/outofcore/visualization/axes.h | 4 +++ tools/obj_rec_ransac_accepted_hypotheses.cpp | 12 ++++++++ tools/obj_rec_ransac_result.cpp | 12 ++++++++ tools/virtual_scanner.cpp | 4 +++ visualization/src/common/shapes.cpp | 29 +++++++++++++++++++ visualization/src/pcl_visualizer.cpp | 12 ++++++++ visualization/src/point_cloud_handlers.cpp | 5 ++++ 8 files changed, 92 insertions(+) diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/mesh_source.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/mesh_source.h index 4b39619f465..a03f1de41c5 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/mesh_source.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/mesh_source.h @@ -12,7 +12,12 @@ #include #include +#include +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) +#include +#else #include +#endif #include @@ -153,13 +158,22 @@ class MeshSource : public Source { trans->Modified(); trans->Update(); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtkSmartPointer filter_scale = + vtkSmartPointer::New(); +#else vtkSmartPointer filter_scale = vtkSmartPointer::New(); +#endif filter_scale->SetTransform(trans); filter_scale->SetInputConnection(reader->GetOutputPort()); filter_scale->Update(); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtkSmartPointer mapper = filter_scale->GetPolyDataOutput(); +#else vtkSmartPointer mapper = filter_scale->GetOutput(); +#endif // generate views pcl::apps::RenderViewsTesselatedSphere render_views; diff --git a/outofcore/include/pcl/outofcore/visualization/axes.h b/outofcore/include/pcl/outofcore/visualization/axes.h index a2faee8628d..514a3684b9c 100644 --- a/outofcore/include/pcl/outofcore/visualization/axes.h +++ b/outofcore/include/pcl/outofcore/visualization/axes.h @@ -33,7 +33,11 @@ class Axes : public Object axes_->Update (); vtkSmartPointer axes_colors = vtkSmartPointer::New (); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + axes_colors->ReserveValues (6); +#else axes_colors->Allocate (6); +#endif axes_colors->InsertNextValue (0.0); axes_colors->InsertNextValue (0.0); axes_colors->InsertNextValue (0.5); diff --git a/tools/obj_rec_ransac_accepted_hypotheses.cpp b/tools/obj_rec_ransac_accepted_hypotheses.cpp index f884cd9c980..0fd3b1e3fa8 100644 --- a/tools/obj_rec_ransac_accepted_hypotheses.cpp +++ b/tools/obj_rec_ransac_accepted_hypotheses.cpp @@ -50,7 +50,11 @@ #include #include #include +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) +#include +#else #include +#endif #include #include #include @@ -321,7 +325,11 @@ update (CallbackParameters* params) vtkSmartPointer vtk_transform = vtkSmartPointer::New (); vtk_transform->SetMatrix (vtk_mat); // Setup the transformator +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtkSmartPointer vtk_transformator = vtkSmartPointer::New (); +#else vtkSmartPointer vtk_transformator = vtkSmartPointer::New (); +#endif vtk_transformator->SetTransform (vtk_transform); vtk_transformator->SetInputData (vtk_model); vtk_transformator->Update (); @@ -329,7 +337,11 @@ update (CallbackParameters* params) // Visualize vtkSmartPointer vtk_actor = vtkSmartPointer::New(); vtkSmartPointer vtk_mapper = vtkSmartPointer::New (); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtk_mapper->SetInputData (vtk_transformator->GetPolyDataOutput ()); +#else vtk_mapper->SetInputData (vtk_transformator->GetOutput ()); +#endif vtk_actor->SetMapper(vtk_mapper); // Set the appearance & add to the renderer vtk_actor->GetProperty ()->SetColor (0.6, 0.7, 0.9); diff --git a/tools/obj_rec_ransac_result.cpp b/tools/obj_rec_ransac_result.cpp index 78b54eb7719..e2f54d1b5f8 100644 --- a/tools/obj_rec_ransac_result.cpp +++ b/tools/obj_rec_ransac_result.cpp @@ -53,7 +53,11 @@ #include #include #include +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) +#include +#else #include +#endif #include #include #include @@ -279,7 +283,11 @@ update (CallbackParameters* params) vtk_transform->SetMatrix (vtk_mat); // Setup the transformator +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtkSmartPointer vtk_transformator = vtkSmartPointer::New (); +#else vtkSmartPointer vtk_transformator = vtkSmartPointer::New (); +#endif vtk_transformator->SetTransform (vtk_transform); vtk_transformator->SetInputData (vtk_model); vtk_transformator->Update (); @@ -287,7 +295,11 @@ update (CallbackParameters* params) // Visualize vtkSmartPointer vtk_actor = vtkSmartPointer::New(); vtkSmartPointer vtk_mapper = vtkSmartPointer::New (); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtk_mapper->SetInputData (vtk_transformator->GetPolyDataOutput ()); +#else vtk_mapper->SetInputData (vtk_transformator->GetOutput ()); +#endif vtk_actor->SetMapper(vtk_mapper); // Set the appearance & add to the renderer vtk_actor->GetProperty ()->SetColor (0.6, 0.7, 0.9); diff --git a/tools/virtual_scanner.cpp b/tools/virtual_scanner.cpp index 8d714241c2f..9fa575d86e0 100644 --- a/tools/virtual_scanner.cpp +++ b/tools/virtual_scanner.cpp @@ -56,6 +56,7 @@ #include #include +#include #include #include #include // for vtkPolyDataReader @@ -241,7 +242,10 @@ main (int argc, char** argv) vtkSmartPointer tree = vtkSmartPointer::New (); tree->SetDataSet (data); tree->CacheCellBoundsOn (); +#if (VTK_MAJOR_VERSION < 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION < 7) + // deprecated because it is a no-op, starting with VTK 9.7.0 tree->SetTolerance (0.0); +#endif tree->SetNumberOfCellsPerBucket (1); tree->AutomaticOn (); tree->BuildLocator (); diff --git a/visualization/src/common/shapes.cpp b/visualization/src/common/shapes.cpp index 8893ea96d4e..0f25269a26f 100644 --- a/visualization/src/common/shapes.cpp +++ b/visualization/src/common/shapes.cpp @@ -38,10 +38,15 @@ #include #include #include +#include #include #include #include +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) +#include +#else #include +#endif #include #include #include @@ -81,7 +86,11 @@ pcl::visualization::createSphere (const pcl::ModelCoefficients &coefficients, in s_sphere->SetThetaResolution (res); s_sphere->LatLongTessellationOff (); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtkSmartPointer tf = vtkSmartPointer::New (); +#else vtkSmartPointer tf = vtkSmartPointer::New (); +#endif tf->SetTransform (t); tf->SetInputConnection (s_sphere->GetOutputPort ()); tf->Update (); @@ -107,7 +116,11 @@ pcl::visualization::createCube (const pcl::ModelCoefficients &coefficients) cube->SetYLength (coefficients.values[8]); cube->SetZLength (coefficients.values[9]); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtkSmartPointer tf = vtkSmartPointer::New (); +#else vtkSmartPointer tf = vtkSmartPointer::New (); +#endif tf->SetTransform (t); tf->SetInputConnection (cube->GetOutputPort ()); tf->Update (); @@ -133,7 +146,11 @@ pcl::visualization::createCube (const Eigen::Vector3f &translation, const Eigen: cube->SetYLength (height); cube->SetZLength (depth); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtkSmartPointer tf = vtkSmartPointer::New (); +#else vtkSmartPointer tf = vtkSmartPointer::New (); +#endif tf->SetTransform (t); tf->SetInputConnection (cube->GetOutputPort ()); tf->Update (); @@ -243,7 +260,11 @@ pcl::visualization::create2DCircle (const pcl::ModelCoefficients &coefficients, t->Identity (); t->Translate (coefficients.values[0], coefficients.values[1], z); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtkSmartPointer tf = vtkSmartPointer::New (); +#else vtkSmartPointer tf = vtkSmartPointer::New (); +#endif tf->SetTransform (t); tf->SetInputConnection (disk->GetOutputPort ()); tf->Update (); @@ -287,7 +308,11 @@ pcl::visualization::createSphere (const Eigen::Vector4f ¢er, double radius, s_sphere->SetThetaResolution (res); s_sphere->LatLongTessellationOff (); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtkSmartPointer tf = vtkSmartPointer::New (); +#else vtkSmartPointer tf = vtkSmartPointer::New (); +#endif tf->SetTransform (t); tf->SetInputConnection (s_sphere->GetOutputPort ()); tf->Update (); @@ -323,7 +348,11 @@ pcl::visualization::createEllipsoid (const Eigen::Isometry3d &transform, vtkSmartPointer s_ellipsoid = vtkSmartPointer::New (); s_ellipsoid->SetParametricFunction (ellipsoid); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + vtkSmartPointer tf = vtkSmartPointer::New (); +#else vtkSmartPointer tf = vtkSmartPointer::New (); +#endif tf->SetTransform (t); tf->SetInputConnection (s_ellipsoid->GetOutputPort ()); tf->Update (); diff --git a/visualization/src/pcl_visualizer.cpp b/visualization/src/pcl_visualizer.cpp index 394c31eed5c..aeb24c04c65 100644 --- a/visualization/src/pcl_visualizer.cpp +++ b/visualization/src/pcl_visualizer.cpp @@ -669,7 +669,11 @@ pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, const std: axes->Update (); vtkSmartPointer axes_colors = vtkSmartPointer::New (); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + axes_colors->ReserveValues (6); +#else axes_colors->Allocate (6); +#endif axes_colors->InsertNextValue (0.0); axes_colors->InsertNextValue (0.0); axes_colors->InsertNextValue (0.5); @@ -710,7 +714,11 @@ pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, float x, f axes->Update (); vtkSmartPointer axes_colors = vtkSmartPointer::New (); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + axes_colors->ReserveValues (6); +#else axes_colors->Allocate (6); +#endif axes_colors->InsertNextValue (0.0); axes_colors->InsertNextValue (0.0); axes_colors->InsertNextValue (0.5); @@ -782,7 +790,11 @@ pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, const Eige axes->Update (); vtkSmartPointer axes_colors = vtkSmartPointer::New (); +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + axes_colors->ReserveValues (6); +#else axes_colors->Allocate (6); +#endif axes_colors->InsertNextValue (0.0); axes_colors->InsertNextValue (0.0); axes_colors->InsertNextValue (0.5); diff --git a/visualization/src/point_cloud_handlers.cpp b/visualization/src/point_cloud_handlers.cpp index 7f7946230e2..92da0c6e176 100644 --- a/visualization/src/point_cloud_handlers.cpp +++ b/visualization/src/point_cloud_handlers.cpp @@ -42,6 +42,7 @@ #include #include #include +#include /////////////////////////////////////////////////////////////////////////////////////////// vtkSmartPointer @@ -618,7 +619,11 @@ pcl::visualization::PointCloudGeometryHandler::getGeometry vtkIdType nr_points = cloud_->width * cloud_->height; +#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7) + if (!data->ReserveTuples(nr_points)) +#else if (!data->Resize(nr_points)) +#endif { PCL_ERROR("[point_cloud_handlers::getGeometry] Failed to allocate space for points in VTK array.\n"); throw std::bad_alloc();