39 #ifndef PCL_OCTREE_SEARCH_H_
40 #define PCL_OCTREE_SEARCH_H_
61 template<
typename Po
intT,
typename LeafT = OctreeContainerDataTVector<
int> ,
typename BranchT = OctreeContainerEmpty<
int> >
74 typedef boost::shared_ptr<OctreePointCloudSearch<PointT, LeafT, BranchT> >
Ptr;
75 typedef boost::shared_ptr<const OctreePointCloudSearch<PointT, LeafT, BranchT> >
ConstPtr;
112 voxelSearch (
const int index, std::vector<int>& pointIdx_data);
125 std::vector<float> &k_sqr_distances)
127 return (
nearestKSearch (cloud[index], k, k_indices, k_sqr_distances));
139 std::vector<float> &k_sqr_distances);
152 std::vector<float> &k_sqr_distances);
197 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
198 unsigned int max_nn = 0)
200 return (
radiusSearch (cloud.
points[index], radius, k_indices, k_sqr_distances, max_nn));
213 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const;
225 radiusSearch (
int index,
const double radius, std::vector<int> &k_indices,
226 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const;
238 int maxVoxelCount = 0)
const;
249 std::vector<int> &k_indices,
250 int maxVoxelCount = 0)
const;
260 boxSearch (
const Eigen::Vector3f &min_pt,
const Eigen::Vector3f &max_pt, std::vector<int> &k_indices)
const;
270 class prioBranchQueueEntry
274 prioBranchQueueEntry () : node (), pointDistance (0), key ()
283 prioBranchQueueEntry (OctreeNode* _node, OctreeKey& _key,
float _point_distance) :
284 node (_node), pointDistance (_point_distance), key (_key)
292 operator < (
const prioBranchQueueEntry rhs)
const
294 return (this->pointDistance > rhs.pointDistance);
298 const OctreeNode* node;
312 class prioPointQueueEntry
317 prioPointQueueEntry () :
318 pointIdx_ (0), pointDistance_ (0)
326 prioPointQueueEntry (
unsigned int& pointIdx,
float pointDistance) :
327 pointIdx_ (pointIdx), pointDistance_ (pointDistance)
335 operator< (
const prioPointQueueEntry& rhs)
const
337 return (this->pointDistance_ < rhs.pointDistance_);
344 float pointDistance_;
353 pointSquaredDist (
const PointT& pointA,
const PointT& pointB)
const;
370 getNeighborsWithinRadiusRecursive (
const PointT& point,
const double radiusSquared,
372 unsigned int treeDepth, std::vector<int>& k_indices,
373 std::vector<float>& k_sqr_distances,
unsigned int max_nn)
const;
386 getKNearestNeighborRecursive (
const PointT& point,
unsigned int K,
const BranchNode* node,
387 const OctreeKey& key,
unsigned int treeDepth,
388 const double squaredSearchRadius,
389 std::vector<prioPointQueueEntry>& pointCandidates)
const;
400 approxNearestSearchRecursive (
const PointT& point,
const BranchNode* node,
const OctreeKey& key,
401 unsigned int treeDepth,
int& result_index,
float& sqr_distance);
420 getIntersectedVoxelCentersRecursive (
double minX,
double minY,
double minZ,
double maxX,
double maxY,
421 double maxZ,
unsigned char a,
const OctreeNode* node,
423 int maxVoxelCount)
const;
435 boxSearchRecursive (
const Eigen::Vector3f &min_pt,
const Eigen::Vector3f &max_pt,
const BranchNode* node,
436 const OctreeKey& key,
unsigned int treeDepth, std::vector<int>& k_indices)
const;
455 getIntersectedVoxelIndicesRecursive (
double minX,
double minY,
double minZ,
456 double maxX,
double maxY,
double maxZ,
457 unsigned char a,
const OctreeNode* node,
const OctreeKey& key,
458 std::vector<int> &k_indices,
459 int maxVoxelCount)
const;
473 initIntersectedVoxel (Eigen::Vector3f &origin, Eigen::Vector3f &direction,
474 double &minX,
double &minY,
double &minZ,
475 double &maxX,
double &maxY,
double &maxZ,
476 unsigned char &a)
const
479 const float epsilon = 1e-10f;
480 if (direction.x () == 0.0)
481 direction.x () = epsilon;
482 if (direction.y () == 0.0)
483 direction.y () = epsilon;
484 if (direction.z () == 0.0)
485 direction.z () = epsilon;
491 if (direction.x () < 0.0)
493 origin.x () =
static_cast<float> (this->minX_) + static_cast<float> (this->maxX_) - origin.x ();
494 direction.x () = -direction.x ();
497 if (direction.y () < 0.0)
499 origin.y () =
static_cast<float> (this->minY_) + static_cast<float> (this->maxY_) - origin.y ();
500 direction.y () = -direction.y ();
503 if (direction.z () < 0.0)
505 origin.z () =
static_cast<float> (this->minZ_) + static_cast<float> (this->maxZ_) - origin.z ();
506 direction.z () = -direction.z ();
509 minX = (this->minX_ - origin.x ()) / direction.x ();
510 maxX = (this->maxX_ - origin.x ()) / direction.x ();
511 minY = (this->minY_ - origin.y ()) / direction.y ();
512 maxY = (this->maxY_ - origin.y ()) / direction.y ();
513 minZ = (this->minZ_ - origin.z ()) / direction.z ();
514 maxZ = (this->maxZ_ - origin.z ()) / direction.z ();
527 getFirstIntersectedNode (
double minX,
double minY,
double minZ,
double midX,
double midY,
double midZ)
const
586 getNextIntersectedNode (
double x,
double y,
double z,
int a,
int b,
int c)
const
610 #define PCL_INSTANTIATE_OctreePointCloudSearch(T) template class PCL_EXPORTS pcl::octree::OctreePointCloudSearch<T>;
612 #endif // PCL_OCTREE_SEARCH_H_