Skip to content

Commit

Permalink
Merge pull request #81 from fran6co/patch-3
Browse files Browse the repository at this point in the history
search::KdTree accepts different types of KdTree
  • Loading branch information
jspricke committed Jan 21, 2014
2 parents 41eeb72 + 0372ee1 commit 5076755
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
30 changes: 15 additions & 15 deletions search/include/pcl/search/impl/kdtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,39 @@
#include <pcl/search/impl/search.hpp>

///////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT>
pcl::search::KdTree<PointT>::KdTree (bool sorted)
template <typename PointT, class Tree>
pcl::search::KdTree<PointT,Tree>::KdTree (bool sorted)
: pcl::search::Search<PointT> ("KdTree", sorted)
, tree_ (new pcl::KdTreeFLANN<PointT> (sorted))
, tree_ (new Tree (sorted))
{
}

///////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::search::KdTree<PointT>::setPointRepresentation (
template <typename PointT, class Tree> void
pcl::search::KdTree<PointT,Tree>::setPointRepresentation (
const PointRepresentationConstPtr &point_representation)
{
tree_->setPointRepresentation (point_representation);
}

///////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::search::KdTree<PointT>::setSortedResults (bool sorted_results)
template <typename PointT, class Tree> void
pcl::search::KdTree<PointT,Tree>::setSortedResults (bool sorted_results)
{
sorted_results_ = sorted_results;
tree_->setSortedResults (sorted_results);
}

///////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::search::KdTree<PointT>::setEpsilon (float eps)
template <typename PointT, class Tree> void
pcl::search::KdTree<PointT,Tree>::setEpsilon (float eps)
{
tree_->setEpsilon (eps);
}

///////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::search::KdTree<PointT>::setInputCloud (
template <typename PointT, class Tree> void
pcl::search::KdTree<PointT,Tree>::setInputCloud (
const PointCloudConstPtr& cloud,
const IndicesConstPtr& indices)
{
Expand All @@ -84,17 +84,17 @@ pcl::search::KdTree<PointT>::setInputCloud (
}

///////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> int
pcl::search::KdTree<PointT>::nearestKSearch (
template <typename PointT, class Tree> int
pcl::search::KdTree<PointT,Tree>::nearestKSearch (
const PointT &point, int k, std::vector<int> &k_indices,
std::vector<float> &k_sqr_distances) const
{
return (tree_->nearestKSearch (point, k, k_indices, k_sqr_distances));
}

///////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> int
pcl::search::KdTree<PointT>::radiusSearch (
template <typename PointT, class Tree> int
pcl::search::KdTree<PointT,Tree>::radiusSearch (
const PointT& point, double radius,
std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
unsigned int max_nn) const
Expand Down
10 changes: 5 additions & 5 deletions search/include/pcl/search/kdtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace pcl
* \author Radu B. Rusu
* \ingroup search
*/
template<typename PointT>
template<typename PointT, class Tree = pcl::KdTreeFLANN<PointT> >
class KdTree: public Search<PointT>
{
public:
Expand All @@ -79,8 +79,8 @@ namespace pcl
typedef boost::shared_ptr<KdTree<PointT> > Ptr;
typedef boost::shared_ptr<const KdTree<PointT> > ConstPtr;

typedef boost::shared_ptr<pcl::KdTreeFLANN<PointT> > KdTreeFLANNPtr;
typedef boost::shared_ptr<const pcl::KdTreeFLANN<PointT> > KdTreeFLANNConstPtr;
typedef boost::shared_ptr<Tree> KdTreePtr;
typedef boost::shared_ptr<const Tree> KdTreeConstPtr;
typedef boost::shared_ptr<const PointRepresentation<PointT> > PointRepresentationConstPtr;

/** \brief Constructor for KdTree.
Expand Down Expand Up @@ -167,8 +167,8 @@ namespace pcl
std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0) const;
protected:
/** \brief A pointer to the internal KdTreeFLANN object. */
KdTreeFLANNPtr tree_;
/** \brief A pointer to the internal KdTree object. */
KdTreePtr tree_;
};
}
}
Expand Down

0 comments on commit 5076755

Please sign in to comment.