Skip to content

Commit 112b9b9

Browse files
committed
Add support for nanoflann
1 parent ba3ea48 commit 112b9b9

File tree

9 files changed

+1576
-2
lines changed

9 files changed

+1576
-2
lines changed

Diff for: CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ else()
354354
endif()
355355
endif()
356356

357+
find_package(nanoflann 1.4.2 QUIET)
358+
if(TARGET nanoflann::nanoflann)
359+
set(PCL_HAS_NANOFLANN 1)
360+
message(STATUS "Found nanoflann")
361+
else()
362+
message(STATUS "nanoflann was not found, so some PCL classes will not be available.")
363+
endif()
364+
357365
# libusb
358366
option(WITH_LIBUSB "Build USB RGBD-Camera drivers" TRUE)
359367
if(WITH_LIBUSB)

Diff for: pcl_config.h.in

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949

5050
#cmakedefine HAVE_DAVIDSDK 1
5151

52+
#ifndef PCL_HAS_NANOFLANN
53+
#cmakedefine PCL_HAS_NANOFLANN 1
54+
#endif
55+
5256
// SSE macros
5357
#cmakedefine HAVE_POSIX_MEMALIGN
5458
#cmakedefine HAVE_MM_MALLOC

Diff for: search/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set(srcs
2222
set(incs
2323
"include/pcl/${SUBSYS_NAME}/search.h"
2424
"include/pcl/${SUBSYS_NAME}/kdtree.h"
25+
"include/pcl/${SUBSYS_NAME}/kdtree_nanoflann.h"
2526
"include/pcl/${SUBSYS_NAME}/brute_force.h"
2627
"include/pcl/${SUBSYS_NAME}/organized.h"
2728
"include/pcl/${SUBSYS_NAME}/octree.h"

Diff for: search/include/pcl/search/impl/kdtree.hpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,21 @@ pcl::search::KdTree<PointT,Tree>::KdTree (bool sorted)
4848
{
4949
}
5050

51+
template <typename PointT, class Tree>
52+
pcl::search::KdTree<PointT,Tree>::KdTree (const std::string& name, bool sorted)
53+
: pcl::search::Search<PointT> (name, sorted)
54+
{
55+
}
56+
5157
///////////////////////////////////////////////////////////////////////////////////////////
5258
template <typename PointT, class Tree> void
5359
pcl::search::KdTree<PointT,Tree>::setPointRepresentation (
5460
const PointRepresentationConstPtr &point_representation)
5561
{
56-
tree_->setPointRepresentation (point_representation);
62+
if(tree_)
63+
tree_->setPointRepresentation (point_representation);
64+
else
65+
PCL_ERROR("Calling setPointRepresentation on KdTreeNanoflann that has been cast to KdTree is not possible in this PCL version. Call setPointRepresentation directly on the KdTreeNanoflann object.\n");
5766
}
5867

5968
///////////////////////////////////////////////////////////////////////////////////////////
@@ -68,7 +77,10 @@ pcl::search::KdTree<PointT,Tree>::setSortedResults (bool sorted_results)
6877
template <typename PointT, class Tree> void
6978
pcl::search::KdTree<PointT,Tree>::setEpsilon (float eps)
7079
{
71-
tree_->setEpsilon (eps);
80+
if(tree_)
81+
tree_->setEpsilon (eps);
82+
else
83+
PCL_ERROR("Calling setEpsilon on KdTreeNanoflann that has been cast to KdTree is not possible in this PCL version. Call setEpsilon directly on the KdTreeNanoflann object.\n");
7284
}
7385

7486
///////////////////////////////////////////////////////////////////////////////////////////

Diff for: search/include/pcl/search/kdtree.h

+2
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ namespace pcl
161161
std::vector<float> &k_sqr_distances,
162162
unsigned int max_nn = 0) const override;
163163
protected:
164+
/** \brief This leaves the internal tree_ object uninitialized! */
165+
KdTree (const std::string& name, bool sorted);
164166
/** \brief A pointer to the internal KdTree object. */
165167
KdTreePtr tree_;
166168
};

0 commit comments

Comments
 (0)