Point Cloud Library (PCL)
1.10.0
|
43 #include <pcl/octree/octree_nodes.h>
44 #include <pcl/octree/octree_container.h>
45 #include <pcl/octree/octree_key.h>
46 #include <pcl/octree/octree_iterator.h>
54 template<
typename ContainerT>
77 for (
unsigned char b = 0; b < 2; ++b)
78 for (
unsigned char i = 0; i < 8; ++i)
104 getChildPtr (
unsigned char buffer_arg,
unsigned char index_arg)
const
106 assert( (buffer_arg<2) && (index_arg<8));
115 inline void setChildPtr (
unsigned char buffer_arg,
unsigned char index_arg,
118 assert( (buffer_arg<2) && (index_arg<8));
127 inline bool hasChild (
unsigned char buffer_arg,
unsigned char index_arg)
const
129 assert( (buffer_arg<2) && (index_arg<8));
219 template<
typename LeafContainerT = int,
254 [[deprecated(
"use leaf_depth_begin() instead")]]
260 [[deprecated(
"use leaf_depth_end() instead")]]
370 createLeaf (
unsigned int idx_x_arg,
unsigned int idx_y_arg,
unsigned int idx_z_arg);
380 findLeaf (
unsigned int idx_x_arg,
unsigned int idx_y_arg,
unsigned int idx_z_arg);
389 existLeaf (
unsigned int idx_x_arg,
unsigned int idx_y_arg,
unsigned int idx_z_arg)
const;
397 removeLeaf (
unsigned int idx_x_arg,
unsigned int idx_y_arg,
unsigned int idx_z_arg);
444 bool do_XOR_encoding_arg =
false);
453 std::vector<LeafContainerT*>& leaf_container_vector_arg,
454 bool do_XOR_encoding_arg =
false);
460 serializeLeafs (std::vector<LeafContainerT*>& leaf_container_vector_arg);
474 bool do_XOR_decoding_arg =
false);
483 std::vector<LeafContainerT*>& leaf_container_vector_arg,
484 bool do_XOR_decoding_arg =
false);
503 inline LeafContainerT*
506 LeafContainerT* result =
nullptr;
516 inline LeafContainerT*
535 return (
findLeaf(key_arg) !=
nullptr);
575 unsigned char child_idx_arg)
const
601 for (
unsigned char i = 0; i < 8; i++)
604 node_bits |= static_cast<char> ( (!!child) << i);
616 unsigned char bufferSelector_arg)
const
622 for (
unsigned char i = 0; i < 8; i++)
625 node_bits |= static_cast<char> ( (!!child) << i);
641 node_bits[0] = node_bits[1] = 0;
643 for (
unsigned char i = 0; i < 8; i++)
648 node_bits[0] |= static_cast<char> ( (!!childA) << i);
649 node_bits[1] |= static_cast<char> ( (!!childB) << i);
652 return node_bits[0] ^ node_bits[1];
670 unsigned char buffer_selector_arg,
671 unsigned char child_idx_arg)
673 if (branch_arg.
hasChild(buffer_selector_arg, child_idx_arg))
685 delete (branchChild);
692 delete (branchChild);
700 branch_arg.
setChildPtr(buffer_selector_arg, child_idx_arg,
nullptr);
719 for (
char i = 0; i < 8; i++)
745 unsigned char child_idx_arg)
750 static_cast<OctreeNode*> (new_branch_child));
752 return new_branch_child;
767 return new_leaf_child;
785 unsigned int depth_mask_arg,
789 bool branch_reset_arg =
false);
801 unsigned int depth_mask_arg,
803 LeafContainerT*& result_arg)
const;
814 unsigned int depth_mask_arg,
828 std::vector<char>* binary_tree_out_arg,
829 typename std::vector<LeafContainerT*>* leaf_container_vector_arg,
830 bool do_XOR_encoding_arg =
false,
831 bool new_leafs_filter_arg =
false);
846 unsigned int depth_mask_arg,
848 typename std::vector<char>::const_iterator& binary_tree_in_it_arg,
849 typename std::vector<char>::const_iterator& binary_tree_in_it_end_arg,
850 typename std::vector<LeafContainerT*>::const_iterator* leaf_container_vector_it_arg,
851 typename std::vector<LeafContainerT*>::const_iterator* leaf_container_vector_it_end_arg,
852 bool branch_reset_arg =
false,
853 bool do_XOR_decoding_arg =
false);
888 [[deprecated(
"use std::log2 instead")]]
889 inline double Log2 (
double n_arg)
891 return std::log2 (n_arg);
907 unsigned char mask = 1;
910 for (
int i = 0; i < 8; i++)
913 std::cout << ((data_arg & (mask << i)) ?
"1" :
"0");
915 std::cout << std::endl;
954 #ifdef PCL_NO_PRECOMPILE
955 #include <pcl/octree/impl/octree2buf_base.hpp>
This file defines compatibility wrappers for low level I/O functions.
ContainerT & getContainer()
Get reference to container.
LeafNodeBreadthIterator leaf_breadth_begin(unsigned int max_depth_arg=0u)
BufferedBranchNode & operator=(const BufferedBranchNode &source_arg)
Copy operator.
void deletePreviousBuffer()
Delete octree structure of previous buffer.
const BreadthFirstIterator breadth_end()
bool existLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg) const
Check for the existence of leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
OctreeNode * child_node_array_[2][8]
void deleteCurrentBuffer()
Delete the octree structure in the current buffer.
virtual node_type_t getNodeType() const =0
Pure virtual method for receiving the type of octree node (branch or leaf)
const LeafNodeDepthFirstIterator leaf_depth_end()
std::size_t branch_count_
Amount of branch nodes
const ContainerT * getContainerPtr() const
Get const pointer to container.
OctreeDepthFirstIterator< OctreeT > DepthFirstIterator
BufferedBranchNode * deepCopy() const override
Method to perform a deep copy of the octree.
void serializeLeafs(std::vector< LeafContainerT * > &leaf_container_vector_arg)
Outputs a vector of all DataT elements that are stored within the octree leaf nodes.
OctreeNode * getBranchChildPtr(const BranchNode &branch_arg, unsigned char child_idx_arg) const
Retrieve a child node pointer for child node at child_idx.
LeafNodeDepthFirstIterator leaf_depth_begin(unsigned int max_depth_arg=0)
const LeafNodeIterator leaf_end()
char getBranchXORBitPattern(const BranchNode &branch_arg) const
Generate XOR bit pattern reflecting differences between the two octree buffers.
OctreeNode * getChildPtr(unsigned char buffer_arg, unsigned char index_arg) const
Get child pointer in current branch node.
Iterator begin(unsigned int max_depth_arg=0)
OctreeLeafNodeDepthFirstIterator< OctreeT > LeafNodeDepthFirstIterator
virtual void serializeTreeCallback(LeafContainerT &, const OctreeKey &)
Callback executed for every leaf node data during serialization.
void removeLeaf(const OctreeKey &key_arg)
Remove leaf node from octree.
BranchNode * createBranchChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Fetch and add a new branch child to a branch class in current buffer.
Octree container class that does store a vector of point indices.
unsigned char buffer_selector_
Currently active octree buffer
std::size_t getBranchCount() const
Return the amount of existing branches in the octree.
BufferedBranchNode()
Empty constructor.
BranchNode * root_node_
Pointer to root branch node of octree
unsigned int depth_mask_
Depth mask based on octree depth
char getBranchBitPattern(const BranchNode &branch_arg, unsigned char bufferSelector_arg) const
Generate bit pattern reflecting the existence of child node pointers in specific buffer.
Abstract octree node class
void printBinary(char data_arg)
Prints binary representation of a byte - used for debugging.
bool hasBranchChanges(const BranchNode &branch_arg) const
Test if branch changed between previous and current buffer.
bool hasChild(unsigned char buffer_arg, unsigned char index_arg) const
Check if branch is pointing to a particular child node.
LeafContainerT * findLeaf(const OctreeKey &key_arg) const
Find leaf node.
Octree double buffer class
Abstract octree leaf class
unsigned int getTreeDepth() const
Get the maximum depth of the octree.
~BufferedBranchNode()
Empty constructor.
bool deleteLeafRecursive(const OctreeKey &key_arg, unsigned int depth_mask_arg, BranchNode *branch_arg)
Recursively search and delete leaf node.
DepthFirstIterator depth_begin(unsigned int maxDepth_arg=0)
bool existLeaf(const OctreeKey &key_arg) const
Check if leaf doesn't exist in the octree.
LeafContainerT * createLeaf(const OctreeKey &key_arg)
Create a leaf node.
double Log2(double n_arg)
Helper function to calculate the binary logarithm.
ContainerT * getContainerPtr()
Get pointer to container.
Octree2BufBase()
Empty constructor.
LeafContainerT * findLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg)
Find leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
Octree2BufBase & operator=(const Octree2BufBase &source)
Copy constructor.
std::size_t leaf_count_
Amount of leaf nodes
void removeLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg)
Remove leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
void deserializeTreeRecursive(BranchNode *branch_arg, unsigned int depth_mask_arg, OctreeKey &key_arg, typename std::vector< char >::const_iterator &binary_tree_in_it_arg, typename std::vector< char >::const_iterator &binary_tree_in_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, bool branch_reset_arg=false, bool do_XOR_decoding_arg=false)
Rebuild an octree based on binary XOR octree description and DataT objects for leaf node initializati...
void setTreeDepth(unsigned int depth_arg)
Set the maximum depth of the octree.
node_type_t getNodeType() const override
Get the type of octree node.
Abstract octree iterator class
void reset()
Reset branch node container for every branch buffer.
const ContainerT & getContainer() const
Get const reference to container.
BufferedBranchNode(const BufferedBranchNode &source)
Copy constructor.
LeafNodeIterator leaf_begin(unsigned int max_depth_arg=0)
unsigned int octree_depth_
Octree depth.
unsigned int createLeafRecursive(const OctreeKey &key_arg, unsigned int depth_mask_arg, BranchNode *branch_arg, LeafNode *&return_leaf_arg, BranchNode *&parent_of_leaf_arg, bool branch_reset_arg=false)
Create a leaf node at octree key.
bool octreeCanResize()
Test if octree is able to dynamically change its depth.
void treeCleanUpRecursive(BranchNode *branch_arg)
Recursively explore the octree and remove unused branch and leaf nodes.
const ContainerT & operator*() const
Get const reference to container.
Octree leaf node iterator class.
Octree2BufBase(const Octree2BufBase &source)
Copy constructor.
virtual OctreeNode * deepCopy() const =0
Pure virtual method to perform a deep copy of the octree.
char getBranchBitPattern(const BranchNode &branch_arg) const
Generate bit pattern reflecting the existence of child node pointers for current buffer.
void setBranchChildPtr(BranchNode &branch_arg, unsigned char child_idx_arg, OctreeNode *new_child_arg)
Assign new child node to branch.
OctreeLeafNode< LeafContainerT > LeafNode
bool branchHasChild(const BranchNode &branch_arg, unsigned char child_idx_arg) const
Check if branch is pointing to a particular child node.
LeafNode * createLeafChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Fetch and add a new leaf child to a branch class.
const DepthFirstIterator depth_end()
OctreeNode * getRootNode() const
Retrieve root node.
void setChildPtr(unsigned char buffer_arg, unsigned char index_arg, OctreeNode *newNode_arg)
Set child pointer in current branch node.
const LeafNodeBreadthIterator leaf_breadth_end()
OctreeKey max_key_
key range
Octree leaf node iterator class.
void deleteBranch(BranchNode &branch_arg)
Delete branch and all its subchilds from octree (both buffers)
void deserializeTree(std::vector< char > &binary_tree_in_arg, bool do_XOR_decoding_arg=false)
Deserialize a binary octree description vector and create a corresponding octree structure.
BufferedBranchNode< BranchContainerT > BranchNode
OctreeBreadthFirstIterator< OctreeT > BreadthFirstIterator
void deleteTree()
Delete the octree structure and its leaf nodes.
void findLeafRecursive(const OctreeKey &key_arg, unsigned int depth_mask_arg, BranchNode *branch_arg, LeafContainerT *&result_arg) const
Recursively search for a given leaf node and return a pointer.
OctreeLeafNodeDepthFirstIterator< OctreeT > LeafNodeIterator
void switchBuffers()
Switch buffers and reset current octree structure.
OctreeLeafNodeBreadthFirstIterator< OctreeT > LeafNodeBreadthIterator
void serializeTreeRecursive(BranchNode *branch_arg, OctreeKey &key_arg, std::vector< char > *binary_tree_out_arg, typename std::vector< LeafContainerT * > *leaf_container_vector_arg, bool do_XOR_encoding_arg=false, bool new_leafs_filter_arg=false)
Recursively explore the octree and output binary octree description together with a vector of leaf no...
void serializeNewLeafs(std::vector< LeafContainerT * > &leaf_container_vector_arg)
Outputs a vector of all DataT elements from leaf nodes, that do not exist in the previous octree buff...
void deleteBranchChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Delete child node and all its subchilds from octree in current buffer.
BreadthFirstIterator breadth_begin(unsigned int max_depth_arg=0)
void serializeTree(std::vector< char > &binary_tree_out_arg, bool do_XOR_encoding_arg=false)
Serialize octree into a binary output vector describing its branch node structure.
void deleteBranchChild(BranchNode &branch_arg, unsigned char buffer_selector_arg, unsigned char child_idx_arg)
Delete child node and all its subchilds from octree in specific buffer.
void setMaxVoxelIndex(unsigned int max_voxel_index_arg)
Set the maximum amount of voxels per dimension.
bool dynamic_depth_enabled_
Enable dynamic_depth.
const ContainerT * getContainerPtr() const
Get const pointer to container.
Octree container class that does not store any information.
std::size_t getLeafCount() const
Return the amount of existing leafs in the octree.
LeafContainerT * createLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg)
Create new leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
const ContainerT * operator->() const
Get const pointer to container.
virtual void deserializeTreeCallback(LeafContainerT &, const OctreeKey &)
Callback executed for every leaf node data during deserialization.
OctreeDepthFirstIterator< OctreeT > Iterator
virtual ~Octree2BufBase()
Empty deconstructor.