40 #ifndef PCL_OCTREE_VOXELCENTROID_HPP
41 #define PCL_OCTREE_VOXELCENTROID_HPP
50 #include <pcl/octree/impl/octree_pointcloud.hpp>
53 template <
typename Po
intT,
typename LeafContainerT,
typename BranchContainerT>
59 LeafContainerT* leaf = NULL;
62 genOctreeKeyforPoint(point_arg, key);
64 leaf = this->findLeaf(key);
66 leaf->getCentroid(voxel_centroid_arg);
68 return (leaf != NULL);
72 template <
typename Po
intT,
typename LeafContainerT,
typename BranchContainerT>
77 AlignedPointTVector& voxel_centroid_list_arg)
const
82 voxel_centroid_list_arg.clear();
83 voxel_centroid_list_arg.reserve(this->leaf_count_);
85 getVoxelCentroidsRecursive(this->root_node_, new_key, voxel_centroid_list_arg);
88 return (voxel_centroid_list_arg.size());
92 template <
typename Po
intT,
typename LeafContainerT,
typename BranchContainerT>
99 AlignedPointTVector& voxel_centroid_list_arg)
const
102 for (
unsigned char child_idx = 0; child_idx < 8; child_idx++) {
104 if (branch_arg->
hasChild(child_idx)) {
113 getVoxelCentroidsRecursive(
static_cast<const BranchNode*
>(child_node),
115 voxel_centroid_list_arg);
121 auto* container =
static_cast<LeafNode*
>(child_node);
125 voxel_centroid_list_arg.push_back(new_centroid);
138 #define PCL_INSTANTIATE_OctreePointCloudVoxelCentroid(T) \
139 template class PCL_EXPORTS pcl::octree::OctreePointCloudVoxelCentroid<T>;
Abstract octree branch class
bool hasChild(unsigned char child_idx_arg) const
Check if branch is pointing to a particular child node.
OctreeNode * getChildPtr(unsigned char child_idx_arg) const
Get pointer to child.
void popBranch()
pop child node from octree key
void pushBranch(unsigned char childIndex)
push a child node to the octree key
Abstract octree leaf class
const ContainerT & getContainer() const
Get const reference to container.
Abstract octree node class
virtual node_type_t getNodeType() const =0
Pure virtual method for retrieving the type of octree node (branch or leaf)
bool getVoxelCentroidAtPoint(const PointT &point_arg, PointT &voxel_centroid_arg) const
Get centroid for a single voxel addressed by a PointT point.
void getVoxelCentroidsRecursive(const BranchNode *branch_arg, OctreeKey &key_arg, typename OctreePointCloud< PointT, LeafContainerT, BranchContainerT >::AlignedPointTVector &voxel_centroid_list_arg) const
Recursively explore the octree and output a PointT vector of centroids for all occupied voxels.
uindex_t getVoxelCentroids(typename OctreePointCloud< PointT, LeafContainerT, BranchContainerT >::AlignedPointTVector &voxel_centroid_list_arg) const
Get PointT vector of centroids for all occupied voxels.
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
A point structure representing Euclidean xyz coordinates, and the RGB color.