41 #include <pcl/octree/octree_container.h>
42 #include <pcl/octree/octree_iterator.h>
43 #include <pcl/octree/octree_key.h>
44 #include <pcl/octree/octree_nodes.h>
45 #include <pcl/pcl_macros.h>
60 template <
typename LeafContainerT =
index_t,
61 typename BranchContainerT = OctreeContainerEmpty>
320 , root_node_(new (
BranchNode)(*(source.root_node_)))
324 , max_key_(source.max_key_)
442 std::vector<LeafContainerT*>& leaf_container_vector_arg)
const;
450 serializeLeafs(std::vector<LeafContainerT*>& leaf_container_vector_arg);
468 std::vector<LeafContainerT*>& leaf_container_vector_arg);
500 LeafContainerT* result =
nullptr;
512 return (
findLeaf(key_arg) !=
nullptr);
521 if (key_arg <= max_key_)
545 return (branch_arg.
getChildPtr(child_idx_arg) !=
nullptr);
566 unsigned char child_idx_arg,
569 branch_arg[child_idx_arg] = new_child_arg;
583 for (
unsigned char i = 0; i < 8; i++) {
585 node_bits |=
static_cast<char>((!!child) << i);
598 if (branch_arg.
hasChild(child_idx_arg)) {
599 OctreeNode* branch_child = branch_arg[child_idx_arg];
619 branch_arg[child_idx_arg] =
nullptr;
630 for (
char i = 0; i < 8; i++)
643 branch_arg[child_idx_arg] =
static_cast<OctreeNode*
>(new_branch_child);
645 return new_branch_child;
656 auto* new_leaf_child =
new LeafNode();
657 branch_arg[child_idx_arg] =
static_cast<OctreeNode*
>(new_leaf_child);
659 return new_leaf_child;
695 LeafContainerT*& result_arg)
const;
722 std::vector<char>* binary_tree_out_arg,
723 typename std::vector<LeafContainerT*>* leaf_container_vector_arg)
const;
742 typename std::vector<char>::const_iterator& binary_tree_input_it_arg,
743 typename std::vector<char>::const_iterator& binary_tree_input_it_end_arg,
744 typename std::vector<LeafContainerT*>::const_iterator*
745 leaf_container_vector_it_arg,
746 typename std::vector<LeafContainerT*>::const_iterator*
747 leaf_container_vector_it_end_arg);
782 #ifdef PCL_NO_PRECOMPILE
783 #include <pcl/octree/impl/octree_base.hpp>
OctreeFixedDepthIterator< const OctreeT > ConstFixedDepthIterator
void serializeTreeRecursive(const BranchNode *branch_arg, OctreeKey &key_arg, std::vector< char > *binary_tree_out_arg, typename std::vector< LeafContainerT * > *leaf_container_vector_arg) const
Recursively explore the octree and output binary octree description together with a vector of leaf no...
ConstLeafNodeBreadthFirstIterator leaf_breadth_begin(uindex_t max_depth_arg=0u) const
ConstIterator cbegin(uindex_t max_depth_arg=0u) const
const DepthFirstIterator depth_end()
void deleteTree()
Delete the octree structure and its leaf nodes.
bool branchHasChild(const BranchNode &branch_arg, unsigned char child_idx_arg) const
Check if branch is pointing to a particular child node.
bool existLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg) const
idx_x_arg for the existence of leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
void deserializeTree(std::vector< char > &binary_tree_input_arg)
Deserialize a binary octree description vector and create a corresponding octree structure.
const FixedDepthIterator fixed_depth_end()
uindex_t octree_depth_
Octree depth.
FixedDepthIterator fixed_depth_begin(uindex_t fixed_depth_arg=0u)
uindex_t createLeafRecursive(const OctreeKey &key_arg, uindex_t depth_mask_arg, BranchNode *branch_arg, LeafNode *&return_leaf_arg, BranchNode *&parent_of_leaf_arg)
Create a leaf node at octree key.
virtual void serializeTreeCallback(LeafContainerT &, const OctreeKey &) const
Callback executed for every leaf node during serialization.
const ConstDepthFirstIterator depth_end() const
LeafContainerT * createLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg)
Create new leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
LeafNodeBreadthFirstIterator leaf_breadth_begin(uindex_t max_depth_arg=0u)
LeafContainerT * findLeaf(const OctreeKey &key_arg) const
Find leaf node.
const ConstIterator cend() const
virtual node_type_t getNodeType() const =0
Pure virtual method for retrieving the type of octree node (branch or leaf)
const LeafNodeBreadthFirstIterator leaf_breadth_end()
bool octreeCanResize() const
Test if octree is able to dynamically change its depth.
virtual ~OctreeBase()
Empty deconstructor.
OctreeNode * getChildPtr(unsigned char child_idx_arg) const
Get pointer to child.
const LeafNodeDepthFirstIterator leaf_depth_end()
void deleteBranch(BranchNode &branch_arg)
Delete branch and all its subchilds from octree.
ConstBreadthFirstIterator breadth_begin(uindex_t max_depth_arg=0u) const
OctreeBase & operator=(const OctreeBase &source)
Copy operator.
OctreeDepthFirstIterator< const OctreeT > ConstIterator
ConstIterator begin(uindex_t max_depth_arg=0u) const
uindex_t depth_mask_
Depth mask based on octree depth.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
const ConstIterator end() const
OctreeBase()
Empty constructor.
void setMaxVoxelIndex(uindex_t max_voxel_index_arg)
Set the maximum amount of voxels per dimension.
void deserializeTreeRecursive(BranchNode *branch_arg, uindex_t depth_mask_arg, OctreeKey &key_arg, typename std::vector< char >::const_iterator &binary_tree_input_it_arg, typename std::vector< char >::const_iterator &binary_tree_input_it_end_arg, typename std::vector< LeafContainerT * >::const_iterator *leaf_container_vector_it_arg, typename std::vector< LeafContainerT * >::const_iterator *leaf_container_vector_it_end_arg)
Recursive method for deserializing octree structure.
OctreeBase(const OctreeBase &source)
Copy constructor.
OctreeNode * getBranchChildPtr(const BranchNode &branch_arg, unsigned char child_idx_arg) const
Retrieve a child node pointer for child node at child_idx.
LeafNode * createLeafChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Create and add a new leaf child to a branch class.
LeafContainerT * findLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg) const
Find leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
void setTreeDepth(uindex_t max_depth_arg)
Set the maximum depth of the octree.
Iterator begin(uindex_t max_depth_arg=0u)
const ConstFixedDepthIterator fixed_depth_end() const
OctreeDepthFirstIterator< const OctreeT > ConstDepthFirstIterator
ConstFixedDepthIterator fixed_depth_begin(uindex_t fixed_depth_arg=0u) const
ConstDepthFirstIterator depth_begin(uindex_t max_depth_arg=0u) const
void serializeTree(std::vector< char > &binary_tree_out_arg) const
Serialize octree into a binary output vector describing its branch node structure.
bool hasChild(unsigned char child_idx_arg) const
Check if branch is pointing to a particular child node.
BranchNode * createBranchChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Create and add a new branch child to a branch class.
std::size_t getLeafCount() const
Return the amount of existing leafs in the octree.
OctreeKey max_key_
key range
OctreeBranchNode< BranchContainerT > BranchNode
BranchNode * root_node_
Pointer to root branch node of octree.
void serializeLeafs(std::vector< LeafContainerT * > &leaf_container_vector_arg)
Outputs a vector of all LeafContainerT elements that are stored within the octree leaf nodes...
OctreeLeafNode< LeafContainerT > LeafNode
OctreeBreadthFirstIterator< OctreeT > BreadthFirstIterator
const ContainerT * getContainerPtr() const
Get const pointer to container.
OctreeDepthFirstIterator< OctreeT > DepthFirstIterator
Octree container class that does store a vector of point indices.
Octree leaf node iterator class.
char getBranchBitPattern(const BranchNode &branch_arg) const
Generate bit pattern reflecting the existence of child node pointers.
OctreeLeafNodeBreadthFirstIterator< const OctreeT > ConstLeafNodeBreadthFirstIterator
void removeLeaf(const OctreeKey &key_arg)
Remove leaf node from octree.
virtual void deserializeTreeCallback(LeafContainerT &, const OctreeKey &)
Callback executed for every leaf node during deserialization.
bool dynamic_depth_enabled_
Enable dynamic_depth.
ConstLeafNodeDepthFirstIterator leaf_depth_begin(uindex_t max_depth_arg=0u) const
LeafContainerT * createLeaf(const OctreeKey &key_arg)
Create a leaf node.
OctreeLeafNodeBreadthFirstIterator< OctreeT > LeafNodeBreadthFirstIterator
OctreeLeafNodeDepthFirstIterator< OctreeT > LeafNodeDepthFirstIterator
Abstract octree leaf class
std::size_t getBranchCount() const
Return the amount of existing branch nodes in the octree.
bool existLeaf(const OctreeKey &key_arg) const
Check for existence of a leaf node in the octree.
uindex_t getTreeDepth() const
Get the maximum depth of the octree.
void setBranchChildPtr(BranchNode &branch_arg, unsigned char child_idx_arg, OctreeNode *new_child_arg)
Assign new child node to branch.
void removeLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg)
Remove leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
OctreeLeafNodeDepthFirstIterator< const OctreeT > ConstLeafNodeDepthFirstIterator
LeafNodeDepthFirstIterator leaf_depth_begin(uindex_t max_depth_arg=0u)
bool deleteLeafRecursive(const OctreeKey &key_arg, uindex_t depth_mask_arg, BranchNode *branch_arg)
Recursively search and delete leaf node.
Abstract octree iterator class
OctreeFixedDepthIterator< OctreeT > FixedDepthIterator
OctreeNode * getRootNode() const
Retrieve root node.
const ConstLeafNodeDepthFirstIterator leaf_depth_end() const
Abstract octree branch class
std::size_t leaf_count_
Amount of leaf nodes.
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
Octree container class that does not store any information.
const BreadthFirstIterator breadth_end()
Abstract octree node class
const ConstBreadthFirstIterator breadth_end() const
void findLeafRecursive(const OctreeKey &key_arg, uindex_t depth_mask_arg, BranchNode *branch_arg, LeafContainerT *&result_arg) const
Recursively search for a given leaf node and return a pointer.
BreadthFirstIterator breadth_begin(uindex_t max_depth_arg=0u)
OctreeBreadthFirstIterator< const OctreeT > ConstBreadthFirstIterator
DepthFirstIterator depth_begin(uindex_t max_depth_arg=0u)
OctreeDepthFirstIterator< OctreeT > Iterator
std::size_t branch_count_
Amount of branch nodes.
Octree leaf node iterator class.
void deleteBranchChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Delete child node and all its subchilds from octree.
const ConstLeafNodeBreadthFirstIterator leaf_breadth_end() const