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>
60 template <
typename LeafContainerT =
index_t,
61 typename BranchContainerT = OctreeContainerEmpty>
114 return Iterator(
this, max_depth_arg ? max_depth_arg : this->octree_depth_);
139 this, max_depth_arg ? max_depth_arg : this->octree_depth_);
156 max_depth_arg ? max_depth_arg : this->octree_depth_);
173 max_depth_arg ? max_depth_arg : this->octree_depth_);
207 this, max_depth_arg ? max_depth_arg : this->octree_depth_);
347 std::vector<LeafContainerT*>& leaf_container_vector_arg);
355 serializeLeafs(std::vector<LeafContainerT*>& leaf_container_vector_arg);
373 std::vector<LeafContainerT*>& leaf_container_vector_arg);
405 LeafContainerT* result =
nullptr;
417 return (
findLeaf(key_arg) !=
nullptr);
450 return (branch_arg.
getChildPtr(child_idx_arg) !=
nullptr);
471 unsigned char child_idx_arg,
474 branch_arg[child_idx_arg] = new_child_arg;
488 for (
unsigned char i = 0; i < 8; i++) {
490 node_bits |=
static_cast<char>((!!child) << i);
503 if (branch_arg.
hasChild(child_idx_arg)) {
504 OctreeNode* branch_child = branch_arg[child_idx_arg];
524 branch_arg[child_idx_arg] =
nullptr;
535 for (
char i = 0; i < 8; i++)
548 branch_arg[child_idx_arg] =
static_cast<OctreeNode*
>(new_branch_child);
550 return new_branch_child;
562 branch_arg[child_idx_arg] =
static_cast<OctreeNode*
>(new_leaf_child);
564 return new_leaf_child;
600 LeafContainerT*& result_arg)
const;
627 std::vector<char>* binary_tree_out_arg,
628 typename std::vector<LeafContainerT*>* leaf_container_vector_arg)
const;
647 typename std::vector<char>::const_iterator& binary_tree_input_it_arg,
648 typename std::vector<char>::const_iterator& binary_tree_input_it_end_arg,
649 typename std::vector<LeafContainerT*>::const_iterator*
650 leaf_container_vector_it_arg,
651 typename std::vector<LeafContainerT*>::const_iterator*
652 leaf_container_vector_it_end_arg);
687 #ifdef PCL_NO_PRECOMPILE
688 #include <pcl/octree/impl/octree_base.hpp>
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.
virtual void serializeTreeCallback(LeafContainerT &, const OctreeKey &) const
Callback executed for every leaf node during serialization.
LeafContainerT * findLeaf(const OctreeKey &key_arg) const
Find leaf node.
void setTreeDepth(uindex_t max_depth_arg)
Set the maximum depth of the octree.
const LeafNodeBreadthFirstIterator leaf_breadth_end()
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.
LeafContainerT LeafContainer
OctreeFixedDepthIterator< OctreeT > FixedDepthIterator
OctreeDepthFirstIterator< OctreeT > Iterator
FixedDepthIterator fixed_depth_begin(uindex_t fixed_depth_arg=0u)
void serializeLeafs(std::vector< LeafContainerT * > &leaf_container_vector_arg)
Outputs a vector of all LeafContainerT elements that are stored within the octree leaf nodes.
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).
std::size_t leaf_count_
Amount of leaf nodes
BranchNode * createBranchChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Create and add a new branch child to a branch class.
BranchNode * root_node_
Pointer to root branch node of octree
virtual ~OctreeBase()
Empty deconstructor.
uindex_t depth_mask_
Depth mask based on octree depth
bool branchHasChild(const BranchNode &branch_arg, unsigned char child_idx_arg) const
Check if branch is pointing to a particular child node.
BranchContainerT BranchContainer
const BreadthFirstIterator breadth_end()
void deleteBranch(BranchNode &branch_arg)
Delete branch and all its subchilds from octree.
bool octreeCanResize()
Test if octree is able to dynamically change its depth.
LeafContainerT * findLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg)
Find leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
void removeLeaf(const OctreeKey &key_arg)
Remove leaf node from octree.
DepthFirstIterator depth_begin(uindex_t max_depth_arg=0u)
std::size_t branch_count_
Amount of branch nodes
bool deleteLeafRecursive(const OctreeKey &key_arg, uindex_t depth_mask_arg, BranchNode *branch_arg)
Recursively search and delete leaf node.
bool dynamic_depth_enabled_
Enable dynamic_depth.
Iterator begin(uindex_t max_depth_arg=0u)
void setBranchChildPtr(BranchNode &branch_arg, unsigned char child_idx_arg, OctreeNode *new_child_arg)
Assign new child node to branch.
std::size_t getBranchCount() const
Return the amount of existing branch nodes in the octree.
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.
LeafNodeDepthFirstIterator leaf_depth_begin(uindex_t max_depth_arg=0u)
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 getTreeDepth() const
Get the maximum depth of the octree.
OctreeBranchNode< BranchContainerT > BranchNode
OctreeNode * getBranchChildPtr(const BranchNode &branch_arg, unsigned char child_idx_arg) const
Retrieve a child node pointer for child node at child_idx.
void deleteTree()
Delete the octree structure and its leaf nodes.
LeafContainerT * createLeaf(const OctreeKey &key_arg)
Create a leaf node.
OctreeDepthFirstIterator< OctreeT > DepthFirstIterator
void serializeTree(std::vector< char > &binary_tree_out_arg)
Serialize octree into a binary output vector describing its branch node structure.
OctreeBase & operator=(const OctreeBase &source)
Copy operator.
uindex_t octree_depth_
Octree depth.
OctreeLeafNodeBreadthFirstIterator< OctreeT > LeafNodeBreadthFirstIterator
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).
const LeafNodeDepthFirstIterator leaf_depth_end()
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...
char getBranchBitPattern(const BranchNode &branch_arg) const
Generate bit pattern reflecting the existence of child node pointers.
std::size_t getLeafCount() const
Return the amount of existing leafs in the octree.
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).
LeafNodeBreadthFirstIterator leaf_breadth_begin(uindex_t max_depth_arg=0u)
void setMaxVoxelIndex(uindex_t max_voxel_index_arg)
Set the maximum amount of voxels per dimension.
OctreeNode * getRootNode() const
Retrieve root node.
OctreeLeafNodeDepthFirstIterator< OctreeT > LeafNodeDepthFirstIterator
OctreeBase(const OctreeBase &source)
Copy constructor.
BreadthFirstIterator breadth_begin(uindex_t max_depth_arg=0u)
OctreeBreadthFirstIterator< OctreeT > BreadthFirstIterator
OctreeKey max_key_
key range
bool existLeaf(const OctreeKey &key_arg) const
Check for existence of a leaf node in the octree.
OctreeBase()
Empty constructor.
const DepthFirstIterator depth_end()
void deleteBranchChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Delete child node and all its subchilds from octree.
OctreeLeafNode< LeafContainerT > LeafNode
virtual void deserializeTreeCallback(LeafContainerT &, const OctreeKey &)
Callback executed for every leaf node during deserialization.
LeafNode * createLeafChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Create and add a new leaf child to a branch class.
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.
Abstract octree iterator class
Octree leaf node iterator class.
Octree leaf node iterator class.
Abstract octree leaf class
const ContainerT * getContainerPtr() const
Get const pointer to container.
Abstract octree node class
virtual node_type_t getNodeType() const =0
Pure virtual method for receiving the type of octree node (branch or leaf)
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
Defines all the PCL and non-PCL macros used.