Move further towards KdTreeNanoflann Part A - #6469
Open
mvieth wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
kdtreean explicit dependency for multiple test subsystems that use it. - Update
extract_clusters.hto (a) gatepcl::KdTreeoverloads behindPCL_HAS_FLANNand (b) addpcl::search::Searchoverloads 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.
mvieth
marked this pull request as ready for review
August 23, 2026 12:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preparation for #6468
extractEuclideanClustersfunctions usepcl::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 genericpcl::search::Searchinstead ofpcl::KdTree.