/** \brief Search for the k-nearest neighbors for the given query point.
* \param[in] point the given query point
* \param[in] k the number of neighbors to search for
* \param[out] k_indices the resultant indices of the neighboring points (must be resized to \a k a priori!)
* \param[out] k_sqr_distances the resultant squared distances to the neighboring points (must be resized to \a k
* a priori!)
* \return number of neighbors found
*/
int
nearestKSearch (const PointT &point, int k,
std::vector<int> &k_indices,
std::vector<float> &k_sqr_distances) const;
param:
point:以这个传入的点为基准,基准点。
k:取几个离基本点最近的点
k_indices:这几个K点的下脚标
k_sqr_distances:这几个K点对于基准点的距离
/*
* \brief Search for the closest nearest neighbor of a given point.
* \param query the point to search a nearest neighbour for
* \param index vector of size 1 to store the index of the nearest neighbour found 给1个空间的vector去储存这个找到的最近点的脚标(因为之保留最近的那个点)
* \param distance vector of size 1 to store the distance to nearest neighbour found 给1个空间的vector去储存找到的最近点的距离
*/
inline bool searchForNeighbors(const PointSource& query, std::vector<int>& index, std::vector<float>& distance) const
{
//只搜索一个最近点和距离
int k=tree_->nearestKSearch(query,1,index,distance);
}