39 #ifndef PCL_OCTREE_POINTCLOUD_H
40 #define PCL_OCTREE_POINTCLOUD_H
42 #include "octree_base.h"
45 #include <pcl/point_cloud.h>
46 #include <pcl/point_types.h>
73 template<
typename PointT,
typename LeafContainerT = OctreeContainerPointIndices,
74 typename BranchContainerT = OctreeContainerEmpty,
75 typename OctreeT = OctreeBase<LeafContainerT, BranchContainerT> >
129 typedef boost::shared_ptr<OctreePointCloud<PointT, LeafContainerT, BranchContainerT, OctreeT> >
Ptr;
130 typedef boost::shared_ptr<const OctreePointCloud<PointT, LeafContainerT, BranchContainerT, OctreeT> >
ConstPtr;
183 assert( this->leaf_count_ == 0);
203 return this->octree_depth_;
247 OctreeT::deleteTree ();
257 isVoxelOccupiedAtPoint (
const double point_x_arg,
const double point_y_arg,
const double point_z_arg)
const;
285 const Eigen::Vector3f& origin,
const Eigen::Vector3f& end,
318 defineBoundingBox (
const double min_x_arg,
const double min_y_arg,
const double min_z_arg,
319 const double max_x_arg,
const double max_y_arg,
const double max_z_arg);
329 defineBoundingBox (
const double max_x_arg,
const double max_y_arg,
const double max_z_arg);
349 getBoundingBox (
double& min_x_arg,
double& min_y_arg,
double& min_z_arg,
350 double& max_x_arg,
double& max_y_arg,
double& max_z_arg)
const;
402 assert(this->leaf_count_==0);
445 return (this->findLeaf (key));
468 return (! ( (point_idx_arg.x <
min_x_) || (point_idx_arg.y <
min_y_)
469 || (point_idx_arg.z <
min_z_) || (point_idx_arg.x >=
max_x_)
470 || (point_idx_arg.y >=
max_y_) || (point_idx_arg.z >=
max_z_)));
488 genOctreeKeyforPoint (
const double point_x_arg,
const double point_y_arg,
const double point_z_arg,
515 unsigned int tree_depth_arg,
PointT& point_arg)
const;
525 unsigned int tree_depth_arg, Eigen::Vector3f &min_pt,
526 Eigen::Vector3f &max_pt)
const;
576 #ifdef PCL_NO_PRECOMPILE
577 #include <pcl/octree/impl/octree_pointcloud.hpp>
void expandLeafNode(LeafNode *leaf_node, BranchNode *parent_branch, unsigned char child_idx, unsigned int depth_mask)
Add point at index from input pointcloud dataset to octree.
double epsilon_
Epsilon precision (error bound) for nearest neighbors searches.
void genOctreeKeyforPoint(const PointT &point_arg, OctreeKey &key_arg) const
Generate octree key for voxel at a given point.
PointCloudConstPtr getInputCloud() const
Get a pointer to the input point cloud dataset.
std::vector< PointT, Eigen::aligned_allocator< PointT > > AlignedPointTVector
void getBoundingBox(double &min_x_arg, double &min_y_arg, double &min_z_arg, double &max_x_arg, double &max_y_arg, double &max_z_arg) const
Get bounding box for octree.
const OctreeDepthFirstIterator< OctreeT > ConstIterator
void genLeafNodeCenterFromOctreeKey(const OctreeKey &key_arg, PointT &point_arg) const
Generate a point at center of leaf node voxel.
void setResolution(double resolution_arg)
Set/change the octree voxel resolution.
bool isPointWithinBoundingBox(const PointT &point_idx_arg) const
Checks if given point is within the bounding box of the octree.
IndicesConstPtr indices_
A pointer to the vector of point indices to use.
void getVoxelBounds(OctreeIteratorBase< OctreeT > &iterator, Eigen::Vector3f &min_pt, Eigen::Vector3f &max_pt)
Generate bounds of the current voxel of an octree iterator.
std::vector< PointXYZ, Eigen::aligned_allocator< PointXYZ > > AlignedPointXYZVector
unsigned int getCurrentOctreeDepth() const
Get the current depth level of octree.
int getOccupiedVoxelCenters(AlignedPointTVector &voxel_center_list_arg) const
Get a PointT vector of centers of all occupied voxels.
void genVoxelCenterFromOctreeKey(const OctreeKey &key_arg, unsigned int tree_depth_arg, PointT &point_arg) const
Generate a point at center of octree voxel at given tree level.
LeafContainerT * findLeafAtPoint(const PointT &point_arg) const
Find octree leaf node at a given point.
boost::shared_ptr< PointCloud > PointCloudPtr
const OctreeLeafNodeIterator< OctreeT > ConstLeafNodeIterator
void setEpsilon(double eps)
Set the search epsilon precision (error bound) for nearest neighbors searches.
unsigned int getTreeDepth() const
Get the maximum depth of the octree.
const PointT & getPointByIndex(const unsigned int index_arg) const
Get point at index from input pointcloud dataset.
void deleteTree()
Delete the octree structure and its leaf nodes.
bool isVoxelOccupiedAtPoint(const PointT &point_arg) const
Check if voxel at given point exist.
IndicesConstPtr const getIndices() const
Get a pointer to the vector of indices used.
void adoptBoundingBoxToPoint(const PointT &point_idx_arg)
Grow the bounding box/octree until point fits.
boost::shared_ptr< const OctreePointCloud< PointT, LeafContainerT, BranchContainerT, OctreeT > > ConstPtr
boost::shared_ptr< std::vector< int > > IndicesPtr
void addPointFromCloud(const int point_idx_arg, IndicesPtr indices_arg)
Add point at given index from input point cloud to octree.
virtual void addPointIdx(const int point_idx_arg)
Add point at index from input pointcloud dataset to octree.
OctreeLeafNodeIterator< OctreeT > LeafNodeIterator
double getVoxelSquaredDiameter() const
Calculates the squared diameter of a voxel at leaf depth.
void getKeyBitSize()
Define octree key setting and octree depth based on defined bounding box.
void defineBoundingBox()
Investigate dimensions of pointcloud data set and define corresponding bounding box for octree...
OctreeDepthFirstIterator< OctreeT > DepthFirstIterator
void setInputCloud(const PointCloudConstPtr &cloud_arg, const IndicesConstPtr &indices_arg=IndicesConstPtr())
Provide a pointer to the input data set.
double resolution_
Octree resolution.
void deleteVoxelAtPoint(const PointT &point_arg)
Delete leaf node / voxel at given point.
double getResolution() const
Get octree voxel resolution.
OctreeT::BranchNode BranchNode
int getApproxIntersectedVoxelCentersBySegment(const Eigen::Vector3f &origin, const Eigen::Vector3f &end, AlignedPointTVector &voxel_center_list, float precision=0.2)
Get a PointT vector of centers of voxels intersected by a line segment.
void addPointToCloud(const PointT &point_arg, PointCloudPtr cloud_arg)
Add point simultaneously to octree and input point cloud.
virtual ~OctreePointCloud()
Empty deconstructor.
boost::shared_ptr< std::vector< int > > IndicesPtr
bool bounding_box_defined_
Flag indicating if octree has defined bounding box.
pcl::PointCloud< PointT > PointCloud
OctreeT::LeafNode LeafNode
double getVoxelSquaredSideLen() const
Calculates the squared voxel cube side length at leaf level.
std::size_t max_objs_per_leaf_
Amount of DataT objects per leafNode before expanding branch.
OctreePointCloud(const double resolution_arg)
Octree pointcloud constructor.
boost::shared_ptr< const PointCloud > PointCloudConstPtr
int getOccupiedVoxelCentersRecursive(const BranchNode *node_arg, const OctreeKey &key_arg, AlignedPointTVector &voxel_center_list_arg) const
Recursively search the tree for all leaf nodes and return a vector of voxel centers.
Abstract octree iterator class
virtual bool genOctreeKeyForDataT(const int &data_arg, OctreeKey &key_arg) const
Virtual method for generating octree key for a given point index.
boost::shared_ptr< const std::vector< int > > IndicesConstPtr
OctreeDepthFirstIterator< OctreeT > Iterator
const OctreeDepthFirstIterator< OctreeT > ConstDepthFirstIterator
double getEpsilon() const
Get the search epsilon precision (error bound) for nearest neighbors searches.
Octree leaf node iterator class.
boost::shared_ptr< OctreePointCloud< PointT, LeafContainerT, BranchContainerT, OctreeT > > Ptr
OctreePointCloud< PointT, LeafContainerT, BranchContainerT, OctreeBase< LeafContainerT > > SingleBuffer
void addPointsFromInputCloud()
Add points from input point cloud to octree.
void genVoxelBoundsFromOctreeKey(const OctreeKey &key_arg, unsigned int tree_depth_arg, Eigen::Vector3f &min_pt, Eigen::Vector3f &max_pt) const
Generate bounds of an octree voxel using octree key and tree depth arguments.
const OctreeBreadthFirstIterator< OctreeT > ConstBreadthFirstIterator
OctreeBreadthFirstIterator< OctreeT > BreadthFirstIterator
A point structure representing Euclidean xyz coordinates, and the RGB color.
const OctreeKey & getCurrentOctreeKey() const
Get octree key for the current iterator octree node.
PointCloudConstPtr input_
Pointer to input point cloud dataset.
void enableDynamicDepth(size_t maxObjsPerLeaf)
Enable dynamic octree structure.