41#include <pcl/octree/octree_pointcloud.h>
42#include <pcl/point_cloud.h>
54template <
typename PointT,
70 shared_ptr<OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>>;
120 std::vector<float>& k_sqr_distances)
122 return (
nearestKSearch(cloud[index], k, k_indices, k_sqr_distances));
138 std::vector<float>& k_sqr_distances);
155 std::vector<float>& k_sqr_distances);
205 std::vector<float>& k_sqr_distances,
208 return (
radiusSearch(cloud[index], radius, k_indices, k_sqr_distances, max_nn));
224 std::vector<float>& k_sqr_distances,
242 std::vector<float>& k_sqr_distances,
256 Eigen::Vector3f direction,
258 uindex_t max_voxel_count = 0)
const;
271 Eigen::Vector3f direction,
273 uindex_t max_voxel_count = 0)
const;
284 const Eigen::Vector3f& max_pt,
388 const double radiusSquared,
393 std::vector<float>& k_sqr_distances,
414 const double squared_search_radius,
415 std::vector<prioPointQueueEntry>& point_candidates)
const;
432 float& sqr_distance);
476 const Eigen::Vector3f& max_pt,
525 Eigen::Vector3f& direction,
532 unsigned char& a)
const
535 constexpr float epsilon = 1e-10f;
536 if (direction.x() == 0.0)
537 direction.x() = epsilon;
538 if (direction.y() == 0.0)
539 direction.y() = epsilon;
540 if (direction.z() == 0.0)
541 direction.z() = epsilon;
547 if (direction.x() < 0.0) {
548 origin.x() =
static_cast<float>(this->
min_x_) +
static_cast<float>(this->
max_x_) -
550 direction.x() = -direction.x();
553 if (direction.y() < 0.0) {
554 origin.y() =
static_cast<float>(this->
min_y_) +
static_cast<float>(this->
max_y_) -
556 direction.y() = -direction.y();
559 if (direction.z() < 0.0) {
560 origin.z() =
static_cast<float>(this->
min_z_) +
static_cast<float>(this->
max_z_) -
562 direction.z() = -direction.z();
565 min_x = (this->
min_x_ - origin.x()) / direction.x();
566 max_x = (this->
max_x_ - origin.x()) / direction.x();
567 min_y = (this->
min_y_ - origin.y()) / direction.y();
568 max_y = (this->
max_y_ - origin.y()) / direction.y();
569 min_z = (this->
min_z_ - origin.z()) / direction.z();
570 max_z = (this->
max_z_ - origin.z()) / direction.z();
656#ifdef PCL_NO_PRECOMPILE
657#include <pcl/octree/impl/octree_search.hpp>
PointCloud represents the base class in PCL for storing collections of 3D points.
shared_ptr< PointCloud< PointInT > > Ptr
shared_ptr< const PointCloud< PointInT > > ConstPtr
Octree container class that does not store any information.
Octree container class that does store a vector of point indices.
Abstract octree node class
OctreePointCloud(const double resolution_arg)
typename OctreeT::LeafNode LeafNode
typename OctreeT::BranchNode BranchNode
bool operator<(const prioBranchQueueEntry rhs) const
Operator< for comparing priority queue entries with each other.
const OctreeNode * node
Pointer to octree node.
prioBranchQueueEntry(OctreeNode *_node, OctreeKey &_key, float _point_distance)
Constructor for initializing priority queue entry.
prioBranchQueueEntry()
Empty constructor.
float point_distance
Distance to query point.
prioPointQueueEntry(uindex_t point_idx, float point_distance)
Constructor for initializing priority queue entry.
prioPointQueueEntry()
Empty constructor.
uindex_t point_idx_
Index representing a point in the dataset given by setInputCloud.
bool operator<(const prioPointQueueEntry &rhs) const
Operator< for comparing priority queue entries with each other.
float point_distance_
Distance to query point.
pcl::PointCloud< PointInT > PointCloud
shared_ptr< OctreePointCloudSearch< PointInT, OctreeContainerPointIndices, OctreeContainerEmpty > > Ptr
typename OctreeT::LeafNode LeafNode
double getKNearestNeighborRecursive(const PointT &point, uindex_t K, const BranchNode *node, const OctreeKey &key, uindex_t tree_depth, const double squared_search_radius, std::vector< prioPointQueueEntry > &point_candidates) const
Recursive search method that explores the octree and finds the K nearest neighbors.
uindex_t getIntersectedVoxelIndices(Eigen::Vector3f origin, Eigen::Vector3f direction, Indices &k_indices, uindex_t max_voxel_count=0) const
Get indices of all voxels that are intersected by a ray (origin, direction).
uindex_t nearestKSearch(const PointT &p_q, uindex_t k, Indices &k_indices, std::vector< float > &k_sqr_distances)
Search for k-nearest neighbors at given query point.
int getNextIntersectedNode(double x, double y, double z, int a, int b, int c) const
Get the next visited node given the current node upper bounding box corner.
uindex_t nearestKSearch(uindex_t index, uindex_t k, Indices &k_indices, std::vector< float > &k_sqr_distances)
Search for k-nearest neighbors at query point.
uindex_t getIntersectedVoxelIndicesRecursive(double min_x, double min_y, double min_z, double max_x, double max_y, double max_z, unsigned char a, const OctreeNode *node, const OctreeKey &key, Indices &k_indices, uindex_t max_voxel_count) const
Recursively search the tree for all intersected leaf nodes and return a vector of indices.
uindex_t getIntersectedVoxelCenters(Eigen::Vector3f origin, Eigen::Vector3f direction, AlignedPointTVector &voxel_center_list, uindex_t max_voxel_count=0) const
Get a PointT vector of centers of all voxels that intersected by a ray (origin, direction).
typename PointCloud::ConstPtr PointCloudConstPtr
uindex_t radiusSearch(uindex_t index, const double radius, Indices &k_indices, std::vector< float > &k_sqr_distances, uindex_t max_nn=0) const
Search for all neighbors of query point that are within a given radius.
bool voxelSearch(const PointT &point, Indices &point_idx_data)
Search for neighbors within a voxel at given point.
std::vector< PointInT, Eigen::aligned_allocator< PointInT > > AlignedPointTVector
OctreePointCloud< PointInT, OctreeContainerPointIndices, OctreeContainerEmpty > OctreeT
void approxNearestSearch(const PointT &p_q, index_t &result_index, float &sqr_distance)
Search for approx.
shared_ptr< Indices > IndicesPtr
uindex_t boxSearch(const Eigen::Vector3f &min_pt, const Eigen::Vector3f &max_pt, Indices &k_indices) const
Search for points within rectangular search area Points exactly on the edges of the search rectangle ...
uindex_t getIntersectedVoxelCentersRecursive(double min_x, double min_y, double min_z, double max_x, double max_y, double max_z, unsigned char a, const OctreeNode *node, const OctreeKey &key, AlignedPointTVector &voxel_center_list, uindex_t max_voxel_count) const
Recursively search the tree for all intersected leaf nodes and return a vector of voxel centers.
void approxNearestSearchRecursive(const PointT &point, const BranchNode *node, const OctreeKey &key, uindex_t tree_depth, index_t &result_index, float &sqr_distance)
Recursive search method that explores the octree and finds the approximate nearest neighbor.
uindex_t nearestKSearch(const PointCloud &cloud, uindex_t index, uindex_t k, Indices &k_indices, std::vector< float > &k_sqr_distances)
Search for k-nearest neighbors at the query point.
void boxSearchRecursive(const Eigen::Vector3f &min_pt, const Eigen::Vector3f &max_pt, const BranchNode *node, const OctreeKey &key, uindex_t tree_depth, Indices &k_indices) const
Recursive search method that explores the octree and finds points within a rectangular search area.
void initIntersectedVoxel(Eigen::Vector3f &origin, Eigen::Vector3f &direction, double &min_x, double &min_y, double &min_z, double &max_x, double &max_y, double &max_z, unsigned char &a) const
Initialize raytracing algorithm.
float pointSquaredDist(const PointT &point_a, const PointT &point_b) const
Helper function to calculate the squared distance between two points.
void getNeighborsWithinRadiusRecursive(const PointT &point, const double radiusSquared, const BranchNode *node, const OctreeKey &key, uindex_t tree_depth, Indices &k_indices, std::vector< float > &k_sqr_distances, uindex_t max_nn) const
Recursive search method that explores the octree and finds neighbors within a given radius.
uindex_t radiusSearch(const PointT &p_q, const double radius, Indices &k_indices, std::vector< float > &k_sqr_distances, uindex_t max_nn=0) const
Search for all neighbors of query point that are within a given radius.
void approxNearestSearch(uindex_t query_index, index_t &result_index, float &sqr_distance)
Search for approx.
shared_ptr< const Indices > IndicesConstPtr
shared_ptr< const OctreePointCloudSearch< PointInT, OctreeContainerPointIndices, OctreeContainerEmpty > > ConstPtr
typename OctreeT::BranchNode BranchNode
void approxNearestSearch(const PointCloud &cloud, uindex_t query_index, index_t &result_index, float &sqr_distance)
Search for approx.
int getFirstIntersectedNode(double min_x, double min_y, double min_z, double mid_x, double mid_y, double mid_z) const
Find first child node ray will enter.
uindex_t radiusSearch(const PointCloud &cloud, uindex_t index, double radius, Indices &k_indices, std::vector< float > &k_sqr_distances, index_t max_nn=0)
Search for all neighbors of query point that are within a given radius.
OctreePointCloudSearch(const double resolution)
Constructor.
typename PointCloud::Ptr PointCloudPtr
bool voxelSearch(uindex_t index, Indices &point_idx_data)
Search for neighbors within a voxel at given point referenced by a point index.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
IndicesAllocator<> Indices
Type used for indices in PCL.
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.