Skip to content

Move further towards KdTreeNanoflann Part A - #6469

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

Move further towards KdTreeNanoflann Part A#6469
mvieth wants to merge 2 commits into
PointCloudLibrary:masterfrom
mvieth:nanoflann_default7

Conversation

@mvieth

@mvieth mvieth commented Aug 23, 2026

Copy link
Copy Markdown
Member

Preparation for #6468

  • Add include for pcl/search/kdtree.h where it is used, previously those files relied on transitive includes. This makes it easier to remove includes in other files.
  • Add the kdtree module as an explicit dependency for those test modules that use it. This makes it easier to remove dependencies on the kdtree module in other modules (e.g. filters, features, segmentation, ...).
  • In extract_clusters, two extractEuclideanClusters functions use pcl::KdTree. These are now only available if the FLANN library has been found (and thus, the kdtree module is built). Additionally, I added overloads to these two functions which use the generic pcl::search::Search instead of pcl::KdTree.

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

Prepares the codebase for the ongoing move toward KdTreeNanoflann by reducing reliance on transitive includes, making kdtree dependencies explicit in tests, and introducing pcl::search::Search-based overloads in cluster extraction to decouple callers from pcl::KdTree.

Changes:

  • Add missing direct includes (notably pcl/search/kdtree.h / pcl/search/auto.h) in tests, examples, apps, and tutorials that previously relied on transitive headers.
  • Make kdtree an explicit dependency for multiple test subsystems that use it.
  • Update extract_clusters.h to (a) gate pcl::KdTree overloads behind PCL_HAS_FLANN and (b) add pcl::search::Search overloads for normal-aware Euclidean clustering.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/sac_segmentation_plane.cpp Adds a direct point types include to avoid transitive dependency.
test/visualization/CMakeLists.txt Adds kdtree as an explicit test dependency.
test/surface/CMakeLists.txt Adds kdtree as an explicit test dependency.
test/search/CMakeLists.txt Adds kdtree as an explicit test dependency.
test/registration/test_sac_ia.cpp Adds direct pcl/search/kdtree.h include where used.
test/registration/test_registration.cpp Adds direct pcl/search/kdtree.h include where used.
test/registration/test_registration_api.cpp Adds direct pcl/search/kdtree.h include where used.
test/registration/test_ndt.cpp Adds direct pcl/search/kdtree.h include where used.
test/registration/test_correspondence_estimation.cpp Adds direct pcl/search/kdtree.h include where used.
test/registration/CMakeLists.txt Makes io and kdtree explicit dependencies for registration tests.
test/recognition/CMakeLists.txt Adds kdtree as an explicit test dependency.
test/keypoints/CMakeLists.txt Adds kdtree as an explicit test dependency.
test/filters/CMakeLists.txt Adds kdtree as an explicit test dependency.
test/features/CMakeLists.txt Adds kdtree as an explicit test dependency.
segmentation/include/pcl/segmentation/extract_clusters.h Gates pcl::KdTree overloads on PCL_HAS_FLANN and adds pcl::search::Search overloads for normal-aware clustering.
registration/src/gicp6d.cpp Makes search backend selection explicit and adjusts tree construction for nanoflann/FLANN.
registration/include/pcl/registration/gicp6d.h Generalizes member type from KdTree to Search to support multiple backends.
examples/segmentation/example_extract_clusters_normals.cpp Switches example to pcl::search::autoSelectMethod for backend-agnostic search selection.
examples/features/example_difference_of_normals.cpp Adds direct pcl/search/kdtree.h include where used.
doc/tutorials/content/sources/template_alignment/template_alignment.cpp Replaces direct FLANN kdtree include with pcl/search/kdtree.h.
doc/tutorials/content/sources/rops_feature/rops_feature.cpp Adds direct pcl/search/kdtree.h include where used.
doc/tutorials/content/sources/pcl_visualizer/pcl_visualizer_demo.cpp Adds direct pcl/search/kdtree.h include where used.
doc/tutorials/content/sources/pairwise_incremental_registration/pairwise_incremental_registration.cpp Adds direct pcl/search/kdtree.h include where used.
doc/tutorials/content/sources/cylinder_segmentation/cylinder_segmentation.cpp Adds direct pcl/search/kdtree.h include where used.
doc/tutorials/content/sources/correspondence_grouping/correspondence_grouping.cpp Adds direct pcl/search/kdtree.h include where used.
doc/tutorials/content/sources/conditional_euclidean_clustering/conditional_euclidean_clustering.cpp Adds direct pcl/search/kdtree.h include where used.
apps/src/ppf_object_recognition.cpp Adds direct pcl/search/kdtree.h include where used.
apps/src/pcd_select_object_plane.cpp Adds direct pcl/search/kdtree.h include where used.
apps/src/openni_tracking.cpp Adds direct pcl/search/kdtree.h include where used.
Suppressed comments (1)

registration/src/gicp6d.cpp:100

  • Same exception-safety issue as in the nanoflann branch: using raw new + reset can leak if an intermediate call throws. Construct the shared_ptr first and then assign to the Search base pointer.
  auto tree = new pcl::search::KdTree<pcl::PointXYZLAB>(false);
  tree->setPointRepresentation(pcl::make_shared<MyPointRepresentation>(point_rep_));
  tree->setInputCloud(target_lab_);
  target_tree_lab_.reset(tree);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread segmentation/include/pcl/segmentation/extract_clusters.h Outdated
Comment thread registration/src/gicp6d.cpp Outdated
Comment thread segmentation/include/pcl/segmentation/extract_clusters.h
@mvieth mvieth added the changelog: enhancement Meta-information for changelog generation label Aug 23, 2026
@mvieth
mvieth marked this pull request as ready for review August 23, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: enhancement Meta-information for changelog generation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants