Point Cloud Library (PCL)  1.11.1-dev
octree_base.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2012, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * $Id$
37  */
38 
39 #pragma once
40 
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>
46 
47 #include <vector>
48 
49 namespace pcl {
50 namespace octree {
51 
52 /** \brief Octree class
53  * \note The tree depth defines the maximum amount of octree voxels / leaf nodes (should
54  * be initially defined).
55  * \note All leaf nodes are addressed by integer indices.
56  * \note The tree depth equates to the bit length of the voxel indices.
57  * \ingroup octree
58  * \author Julius Kammerl (julius@kammerl.de)
59  */
60 template <typename LeafContainerT = int,
61  typename BranchContainerT = OctreeContainerEmpty>
62 class OctreeBase {
63 public:
65 
68 
69  using BranchContainer = BranchContainerT;
70  using LeafContainer = LeafContainerT;
71 
72 protected:
73  ///////////////////////////////////////////////////////////////////////
74  // Members
75  ///////////////////////////////////////////////////////////////////////
76 
77  /** \brief Amount of leaf nodes **/
78  std::size_t leaf_count_;
79 
80  /** \brief Amount of branch nodes **/
81  std::size_t branch_count_;
82 
83  /** \brief Pointer to root branch node of octree **/
85 
86  /** \brief Depth mask based on octree depth **/
87  unsigned int depth_mask_;
88 
89  /** \brief Octree depth */
90  unsigned int octree_depth_;
91 
92  /** \brief Enable dynamic_depth **/
94 
95  /** \brief key range */
97 
98 public:
99  // iterators are friends
106 
107  // Octree default iterators
110 
111  Iterator
112  begin(unsigned int max_depth_arg = 0u)
113  {
114  return Iterator(this, max_depth_arg ? max_depth_arg : this->octree_depth_);
115  };
116 
117  const Iterator
118  end()
119  {
120  return Iterator(this, 0, nullptr);
121  };
122 
123  // Octree leaf node iterators
124  // The previous deprecated names
125  // LeafNodeIterator and ConstLeafNodeIterator are deprecated.
126  // Please use LeafNodeDepthFirstIterator and ConstLeafNodeDepthFirstIterator instead.
129 
130  // The currently valide names
134 
136  leaf_depth_begin(unsigned int max_depth_arg = 0u)
137  {
139  this, max_depth_arg ? max_depth_arg : this->octree_depth_);
140  };
141 
144  {
145  return LeafNodeDepthFirstIterator(this, 0, nullptr);
146  };
147 
148  // Octree depth-first iterators
151 
153  depth_begin(unsigned int max_depth_arg = 0u)
154  {
155  return DepthFirstIterator(this,
156  max_depth_arg ? max_depth_arg : this->octree_depth_);
157  };
158 
159  const DepthFirstIterator
161  {
162  return DepthFirstIterator(this, 0, nullptr);
163  };
164 
165  // Octree breadth-first iterators
168 
170  breadth_begin(unsigned int max_depth_arg = 0u)
171  {
172  return BreadthFirstIterator(this,
173  max_depth_arg ? max_depth_arg : this->octree_depth_);
174  };
175 
178  {
179  return BreadthFirstIterator(this, 0, nullptr);
180  };
181 
182  // Octree breadth iterators at a given depth
185 
187  fixed_depth_begin(unsigned int fixed_depth_arg = 0u)
188  {
189  return FixedDepthIterator(this, fixed_depth_arg);
190  };
191 
192  const FixedDepthIterator
194  {
195  return FixedDepthIterator(this, 0, nullptr);
196  };
197 
198  // Octree leaf node iterators
202 
204  leaf_breadth_begin(unsigned int max_depth_arg = 0u)
205  {
207  this, max_depth_arg ? max_depth_arg : this->octree_depth_);
208  };
209 
212  {
213  return LeafNodeBreadthFirstIterator(this, 0, nullptr);
214  };
215 
216  /** \brief Empty constructor. */
217  OctreeBase();
218 
219  /** \brief Empty deconstructor. */
220  virtual ~OctreeBase();
221 
222  /** \brief Copy constructor. */
223  OctreeBase(const OctreeBase& source)
224  : leaf_count_(source.leaf_count_)
225  , branch_count_(source.branch_count_)
226  , root_node_(new (BranchNode)(*(source.root_node_)))
227  , depth_mask_(source.depth_mask_)
228  , octree_depth_(source.octree_depth_)
230  , max_key_(source.max_key_)
231  {}
232 
233  /** \brief Copy operator. */
234  OctreeBase&
235  operator=(const OctreeBase& source)
236  {
237  leaf_count_ = source.leaf_count_;
238  branch_count_ = source.branch_count_;
239  delete root_node_;
240 
241  root_node_ = new (BranchNode)(*(source.root_node_));
242  depth_mask_ = source.depth_mask_;
243  max_key_ = source.max_key_;
244  octree_depth_ = source.octree_depth_;
245  return (*this);
246  }
247 
248  /** \brief Set the maximum amount of voxels per dimension.
249  * \param[in] max_voxel_index_arg maximum amount of voxels per dimension
250  */
251  void
252  setMaxVoxelIndex(unsigned int max_voxel_index_arg);
253 
254  /** \brief Set the maximum depth of the octree.
255  * \param max_depth_arg: maximum depth of octree
256  */
257  void
258  setTreeDepth(unsigned int max_depth_arg);
259 
260  /** \brief Get the maximum depth of the octree.
261  * \return depth_arg: maximum depth of octree
262  */
263  unsigned int
264  getTreeDepth() const
265  {
266  return this->octree_depth_;
267  }
268 
269  /** \brief Create new leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
270  * \note If leaf node already exist, this method returns the existing node
271  * \param idx_x_arg: index of leaf node in the X axis.
272  * \param idx_y_arg: index of leaf node in the Y axis.
273  * \param idx_z_arg: index of leaf node in the Z axis.
274  * \return pointer to new leaf node container.
275  */
276  LeafContainerT*
277  createLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg);
278 
279  /** \brief Find leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
280  * \note If leaf node already exist, this method returns the existing node
281  * \param idx_x_arg: index of leaf node in the X axis.
282  * \param idx_y_arg: index of leaf node in the Y axis.
283  * \param idx_z_arg: index of leaf node in the Z axis.
284  * \return pointer to leaf node container if found, null pointer otherwise.
285  */
286  LeafContainerT*
287  findLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg);
288 
289  /** \brief idx_x_arg for the existence of leaf node at (idx_x_arg, idx_y_arg,
290  * idx_z_arg).
291  * \param idx_x_arg: index of leaf node in the X axis.
292  * \param idx_y_arg: index of leaf node in the Y axis.
293  * \param idx_z_arg: index of leaf node in the Z axis.
294  * \return "true" if leaf node search is successful, otherwise it returns "false".
295  */
296  bool
297  existLeaf(unsigned int idx_x_arg,
298  unsigned int idx_y_arg,
299  unsigned int idx_z_arg) const;
300 
301  /** \brief Remove leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
302  * \param idx_x_arg: index of leaf node in the X axis.
303  * \param idx_y_arg: index of leaf node in the Y axis.
304  * \param idx_z_arg: index of leaf node in the Z axis.
305  */
306  void
307  removeLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg);
308 
309  /** \brief Return the amount of existing leafs in the octree.
310  * \return amount of registered leaf nodes.
311  */
312  std::size_t
313  getLeafCount() const
314  {
315  return leaf_count_;
316  }
317 
318  /** \brief Return the amount of existing branch nodes in the octree.
319  * \return amount of branch nodes.
320  */
321  std::size_t
323  {
324  return branch_count_;
325  }
326 
327  /** \brief Delete the octree structure and its leaf nodes.
328  */
329  void
330  deleteTree();
331 
332  /** \brief Serialize octree into a binary output vector describing its branch node
333  * structure.
334  * \param binary_tree_out_arg: reference to output vector for writing binary tree
335  * structure.
336  */
337  void
338  serializeTree(std::vector<char>& binary_tree_out_arg);
339 
340  /** \brief Serialize octree into a binary output vector describing its branch node
341  * structure and push all LeafContainerT elements stored in the octree to a vector.
342  * \param binary_tree_out_arg: reference to output vector for writing binary tree
343  * structure.
344  * \param leaf_container_vector_arg: pointer to all LeafContainerT objects in the
345  * octree
346  */
347  void
348  serializeTree(std::vector<char>& binary_tree_out_arg,
349  std::vector<LeafContainerT*>& leaf_container_vector_arg);
350 
351  /** \brief Outputs a vector of all LeafContainerT elements that are stored within the
352  * octree leaf nodes.
353  * \param leaf_container_vector_arg: pointers to LeafContainerT vector that receives a
354  * copy of all LeafContainerT objects in the octree.
355  */
356  void
357  serializeLeafs(std::vector<LeafContainerT*>& leaf_container_vector_arg);
358 
359  /** \brief Deserialize a binary octree description vector and create a corresponding
360  * octree structure. Leaf nodes are initialized with getDataTByKey(..).
361  * \param binary_tree_input_arg: reference to input vector for reading binary tree
362  * structure.
363  */
364  void
365  deserializeTree(std::vector<char>& binary_tree_input_arg);
366 
367  /** \brief Deserialize a binary octree description and create a corresponding octree
368  * structure. Leaf nodes are initialized with LeafContainerT elements from the
369  * dataVector.
370  * \param binary_tree_input_arg: reference to input vector for reading binary tree
371  * structure. \param leaf_container_vector_arg: pointer to container vector.
372  */
373  void
374  deserializeTree(std::vector<char>& binary_tree_input_arg,
375  std::vector<LeafContainerT*>& leaf_container_vector_arg);
376 
377 protected:
378  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
379  // Protected octree methods based on octree keys
380  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
381 
382  /** \brief Create a leaf node
383  * \param key_arg: octree key addressing a leaf node.
384  * \return pointer to leaf node
385  */
386  LeafContainerT*
387  createLeaf(const OctreeKey& key_arg)
388  {
389 
390  LeafNode* leaf_node = nullptr;
391  BranchNode* leaf_node_parent;
392 
393  createLeafRecursive(key_arg, depth_mask_, root_node_, leaf_node, leaf_node_parent);
394 
395  LeafContainerT* ret = leaf_node->getContainerPtr();
396 
397  return ret;
398  }
399 
400  /** \brief Find leaf node
401  * \param key_arg: octree key addressing a leaf node.
402  * \return pointer to leaf node. If leaf node is not found, this pointer returns 0.
403  */
404  LeafContainerT*
405  findLeaf(const OctreeKey& key_arg) const
406  {
407  LeafContainerT* result = nullptr;
408  findLeafRecursive(key_arg, depth_mask_, root_node_, result);
409  return result;
410  }
411 
412  /** \brief Check for existence of a leaf node in the octree
413  * \param key_arg: octree key addressing a leaf node.
414  * \return "true" if leaf node is found; "false" otherwise
415  */
416  bool
417  existLeaf(const OctreeKey& key_arg) const
418  {
419  return (findLeaf(key_arg) != nullptr);
420  }
421 
422  /** \brief Remove leaf node from octree
423  * \param key_arg: octree key addressing a leaf node.
424  */
425  void
426  removeLeaf(const OctreeKey& key_arg)
427  {
428  if (key_arg <= max_key_)
430  }
431 
432  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
433  // Branch node access functions
434  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
435 
436  /** \brief Retrieve root node */
437  OctreeNode*
438  getRootNode() const
439  {
440  return this->root_node_;
441  }
442 
443  /** \brief Check if branch is pointing to a particular child node
444  * \param branch_arg: reference to octree branch class
445  * \param child_idx_arg: index to child node
446  * \return "true" if pointer to child node exists; "false" otherwise
447  */
448  bool
449  branchHasChild(const BranchNode& branch_arg, unsigned char child_idx_arg) const
450  {
451  // test occupancyByte for child existence
452  return (branch_arg.getChildPtr(child_idx_arg) != nullptr);
453  }
454 
455  /** \brief Retrieve a child node pointer for child node at child_idx.
456  * \param branch_arg: reference to octree branch class
457  * \param child_idx_arg: index to child node
458  * \return pointer to octree child node class
459  */
460  OctreeNode*
461  getBranchChildPtr(const BranchNode& branch_arg, unsigned char child_idx_arg) const
462  {
463  return branch_arg.getChildPtr(child_idx_arg);
464  }
465 
466  /** \brief Assign new child node to branch
467  * \param branch_arg: reference to octree branch class
468  * \param child_idx_arg: index to child node
469  * \param new_child_arg: pointer to new child node
470  */
471  void
473  unsigned char child_idx_arg,
474  OctreeNode* new_child_arg)
475  {
476  branch_arg[child_idx_arg] = new_child_arg;
477  }
478 
479  /** \brief Generate bit pattern reflecting the existence of child node pointers
480  * \param branch_arg: reference to octree branch class
481  * \return a single byte with 8 bits of child node information
482  */
483  char
484  getBranchBitPattern(const BranchNode& branch_arg) const
485  {
486  char node_bits;
487 
488  // create bit pattern
489  node_bits = 0;
490  for (unsigned char i = 0; i < 8; i++) {
491  const OctreeNode* child = branch_arg.getChildPtr(i);
492  node_bits |= static_cast<char>((!!child) << i);
493  }
494 
495  return (node_bits);
496  }
497 
498  /** \brief Delete child node and all its subchilds from octree
499  * \param branch_arg: reference to octree branch class
500  * \param child_idx_arg: index to child node
501  */
502  void
503  deleteBranchChild(BranchNode& branch_arg, unsigned char child_idx_arg)
504  {
505  if (branch_arg.hasChild(child_idx_arg)) {
506  OctreeNode* branch_child = branch_arg[child_idx_arg];
507 
508  switch (branch_child->getNodeType()) {
509  case BRANCH_NODE: {
510  // free child branch recursively
511  deleteBranch(*static_cast<BranchNode*>(branch_child));
512  // delete branch node
513  delete branch_child;
514  } break;
515 
516  case LEAF_NODE: {
517  // delete leaf node
518  delete branch_child;
519  break;
520  }
521  default:
522  break;
523  }
524 
525  // set branch child pointer to 0
526  branch_arg[child_idx_arg] = nullptr;
527  }
528  }
529 
530  /** \brief Delete branch and all its subchilds from octree
531  * \param branch_arg: reference to octree branch class
532  */
533  void
535  {
536  // delete all branch node children
537  for (char i = 0; i < 8; i++)
538  deleteBranchChild(branch_arg, i);
539  }
540 
541  /** \brief Create and add a new branch child to a branch class
542  * \param branch_arg: reference to octree branch class
543  * \param child_idx_arg: index to child node
544  * \return pointer of new branch child to this reference
545  */
546  BranchNode*
547  createBranchChild(BranchNode& branch_arg, unsigned char child_idx_arg)
548  {
549  BranchNode* new_branch_child = new BranchNode();
550  branch_arg[child_idx_arg] = static_cast<OctreeNode*>(new_branch_child);
551 
552  return new_branch_child;
553  }
554 
555  /** \brief Create and add a new leaf child to a branch class
556  * \param branch_arg: reference to octree branch class
557  * \param child_idx_arg: index to child node
558  * \return pointer of new leaf child to this reference
559  */
560  LeafNode*
561  createLeafChild(BranchNode& branch_arg, unsigned char child_idx_arg)
562  {
563  LeafNode* new_leaf_child = new LeafNode();
564  branch_arg[child_idx_arg] = static_cast<OctreeNode*>(new_leaf_child);
565 
566  return new_leaf_child;
567  }
568 
569  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
570  // Recursive octree methods
571  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
572 
573  /** \brief Create a leaf node at octree key. If leaf node does already exist, it is
574  * returned.
575  * \param key_arg: reference to an octree key
576  * \param depth_mask_arg: depth mask used for octree key analysis and for branch depth
577  * indicator
578  * \param branch_arg: current branch node
579  * \param return_leaf_arg: return pointer to leaf node
580  * \param parent_of_leaf_arg: return pointer to parent of leaf node
581  * \return depth mask at which leaf node was created
582  **/
583  unsigned int
584  createLeafRecursive(const OctreeKey& key_arg,
585  unsigned int depth_mask_arg,
586  BranchNode* branch_arg,
587  LeafNode*& return_leaf_arg,
588  BranchNode*& parent_of_leaf_arg);
589 
590  /** \brief Recursively search for a given leaf node and return a pointer.
591  * \note If leaf node does not exist, a 0 pointer is returned.
592  * \param key_arg: reference to an octree key
593  * \param depth_mask_arg: depth mask used for octree key analysis and for branch
594  * depth indicator
595  * \param branch_arg: current branch node
596  * \param result_arg: pointer to leaf node class
597  **/
598  void
599  findLeafRecursive(const OctreeKey& key_arg,
600  unsigned int depth_mask_arg,
601  BranchNode* branch_arg,
602  LeafContainerT*& result_arg) const;
603 
604  /** \brief Recursively search and delete leaf node
605  * \param key_arg: reference to an octree key
606  * \param depth_mask_arg: depth mask used for octree key analysis and branch depth
607  * indicator
608  * \param branch_arg: current branch node
609  * \return "true" if branch does not contain any childs; "false" otherwise. This
610  * indicates if current branch can be deleted, too.
611  **/
612  bool
613  deleteLeafRecursive(const OctreeKey& key_arg,
614  unsigned int depth_mask_arg,
615  BranchNode* branch_arg);
616 
617  /** \brief Recursively explore the octree and output binary octree description
618  * together with a vector of leaf node LeafContainerTs.
619  * \param branch_arg: current branch node
620  * \param key_arg: reference to an octree key
621  * \param binary_tree_out_arg: binary output vector
622  * \param leaf_container_vector_arg: writes LeafContainerT pointers to this
623  *LeafContainerT* vector.
624  **/
625  void
627  const BranchNode* branch_arg,
628  OctreeKey& key_arg,
629  std::vector<char>* binary_tree_out_arg,
630  typename std::vector<LeafContainerT*>* leaf_container_vector_arg) const;
631 
632  /** \brief Recursive method for deserializing octree structure
633  * \param branch_arg: current branch node
634  * \param depth_mask_arg: depth mask used for octree key analysis and branch depth
635  * indicator
636  * \param key_arg: reference to an octree key
637  * \param binary_tree_input_it_arg: iterator to binary input vector
638  * \param binary_tree_input_it_end_arg: end iterator of binary input vector
639  * \param leaf_container_vector_it_arg: iterator pointing to current LeafContainerT
640  * object to be added to a leaf node
641  * \param leaf_container_vector_it_end_arg: iterator pointing to last object in
642  * LeafContainerT input vector.
643  **/
644  void
646  BranchNode* branch_arg,
647  unsigned int depth_mask_arg,
648  OctreeKey& key_arg,
649  typename std::vector<char>::const_iterator& binary_tree_input_it_arg,
650  typename std::vector<char>::const_iterator& binary_tree_input_it_end_arg,
651  typename std::vector<LeafContainerT*>::const_iterator*
652  leaf_container_vector_it_arg,
653  typename std::vector<LeafContainerT*>::const_iterator*
654  leaf_container_vector_it_end_arg);
655 
656  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
657  // Serialization callbacks
658  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
659 
660  /** \brief Callback executed for every leaf node during serialization
661  **/
662  virtual void
663  serializeTreeCallback(LeafContainerT&, const OctreeKey&) const
664  {}
665 
666  /** \brief Callback executed for every leaf node during deserialization
667  **/
668  virtual void
669  deserializeTreeCallback(LeafContainerT&, const OctreeKey&)
670  {}
671 
672  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
673  // Helpers
674  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
675 
676  /** \brief Test if octree is able to dynamically change its depth. This is required
677  *for adaptive bounding box adjustment.
678  * \return "true"
679  **/
680  bool
682  {
683  return (true);
684  }
685 };
686 } // namespace octree
687 } // namespace pcl
688 
689 #ifdef PCL_NO_PRECOMPILE
690 #include <pcl/octree/impl/octree_base.hpp>
691 #endif
pcl::octree::OctreeBase::setMaxVoxelIndex
void setMaxVoxelIndex(unsigned int max_voxel_index_arg)
Set the maximum amount of voxels per dimension.
Definition: octree_base.hpp:69
pcl::octree::OctreeBase::Iterator
OctreeDepthFirstIterator< OctreeT > Iterator
Definition: octree_base.h:108
pcl::octree::OctreeBase::createLeaf
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).
Definition: octree_base.hpp:119
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl::octree::OctreeBase::getBranchChildPtr
OctreeNode * getBranchChildPtr(const BranchNode &branch_arg, unsigned char child_idx_arg) const
Retrieve a child node pointer for child node at child_idx.
Definition: octree_base.h:461
pcl::octree::OctreeBase::depth_mask_
unsigned int depth_mask_
Depth mask based on octree depth
Definition: octree_base.h:87
pcl
Definition: convolution.h:46
pcl::octree::OctreeBase::deserializeTree
void deserializeTree(std::vector< char > &binary_tree_input_arg)
Deserialize a binary octree description vector and create a corresponding octree structure.
Definition: octree_base.hpp:228
pcl::octree::OctreeBase::deleteTree
void deleteTree()
Delete the octree structure and its leaf nodes.
Definition: octree_base.hpp:161
pcl::octree::OctreeNode::getNodeType
virtual node_type_t getNodeType() const =0
Pure virtual method for receiving the type of octree node (branch or leaf)
pcl::octree::OctreeBase::depth_end
const DepthFirstIterator depth_end()
Definition: octree_base.h:160
pcl::octree::OctreeBase::deleteLeafRecursive
bool deleteLeafRecursive(const OctreeKey &key_arg, unsigned int depth_mask_arg, BranchNode *branch_arg)
Recursively search and delete leaf node.
Definition: octree_base.hpp:383
pcl::octree::OctreeBase::fixed_depth_end
const FixedDepthIterator fixed_depth_end()
Definition: octree_base.h:193
pcl::octree::OctreeBase::branchHasChild
bool branchHasChild(const BranchNode &branch_arg, unsigned char child_idx_arg) const
Check if branch is pointing to a particular child node.
Definition: octree_base.h:449
pcl::octree::OctreeBase::operator=
OctreeBase & operator=(const OctreeBase &source)
Copy operator.
Definition: octree_base.h:235
pcl::octree::OctreeBase::setTreeDepth
void setTreeDepth(unsigned int max_depth_arg)
Set the maximum depth of the octree.
Definition: octree_base.hpp:88
pcl::octree::OctreeBase::begin
Iterator begin(unsigned int max_depth_arg=0u)
Definition: octree_base.h:112
pcl::octree::OctreeBase::OctreeBase
OctreeBase()
Empty constructor.
Definition: octree_base.hpp:48
pcl::octree::OctreeBase::leaf_breadth_end
const LeafNodeBreadthFirstIterator leaf_breadth_end()
Definition: octree_base.h:211
pcl::octree::OctreeBase::leaf_depth_end
const LeafNodeDepthFirstIterator leaf_depth_end()
Definition: octree_base.h:143
pcl::octree::OctreeBase::~OctreeBase
virtual ~OctreeBase()
Empty deconstructor.
Definition: octree_base.hpp:59
pcl::octree::OctreeBase::createLeafChild
LeafNode * createLeafChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Create and add a new leaf child to a branch class.
Definition: octree_base.h:561
pcl::octree::OctreeBase::octree_depth_
unsigned int octree_depth_
Octree depth.
Definition: octree_base.h:90
pcl::octree::OctreeKey
Octree key class
Definition: octree_key.h:52
pcl::octree::OctreeBase::deleteBranch
void deleteBranch(BranchNode &branch_arg)
Delete branch and all its subchilds from octree.
Definition: octree_base.h:534
pcl::octree::OctreeBase::findLeaf
LeafContainerT * findLeaf(const OctreeKey &key_arg) const
Find leaf node.
Definition: octree_base.h:405
pcl::octree::OctreeBase::OctreeBase
OctreeBase(const OctreeBase &source)
Copy constructor.
Definition: octree_base.h:223
pcl::octree::OctreeNode
Abstract octree node class
Definition: octree_nodes.h:58
pcl::octree::OctreeBase::existLeaf
bool existLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg) const
idx_x_arg for the existence of leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
Definition: octree_base.hpp:133
pcl::octree::LEAF_NODE
@ LEAF_NODE
Definition: octree_nodes.h:51
pcl::octree::OctreeBase::createBranchChild
BranchNode * createBranchChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Create and add a new branch child to a branch class.
Definition: octree_base.h:547
pcl::octree::OctreeLeafNode
Abstract octree leaf class
Definition: octree_nodes.h:80
pcl::octree::OctreeBase::breadth_begin
BreadthFirstIterator breadth_begin(unsigned int max_depth_arg=0u)
Definition: octree_base.h:170
pcl::octree::BRANCH_NODE
@ BRANCH_NODE
Definition: octree_nodes.h:51
pcl::octree::OctreeBase::end
const Iterator end()
Definition: octree_base.h:118
pcl::octree::OctreeBase::serializeTree
void serializeTree(std::vector< char > &binary_tree_out_arg)
Serialize octree into a binary output vector describing its branch node structure.
Definition: octree_base.hpp:175
pcl::octree::OctreeBase::serializeTreeCallback
virtual void serializeTreeCallback(LeafContainerT &, const OctreeKey &) const
Callback executed for every leaf node during serialization.
Definition: octree_base.h:663
pcl::octree::OctreeBase::createLeafRecursive
unsigned int createLeafRecursive(const OctreeKey &key_arg, unsigned int depth_mask_arg, BranchNode *branch_arg, LeafNode *&return_leaf_arg, BranchNode *&parent_of_leaf_arg)
Create a leaf node at octree key.
Definition: octree_base.hpp:285
pcl::octree::OctreeBase::root_node_
BranchNode * root_node_
Pointer to root branch node of octree
Definition: octree_base.h:84
pcl::octree::OctreeBase::removeLeaf
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).
Definition: octree_base.hpp:147
pcl::octree::OctreeBase::serializeLeafs
void serializeLeafs(std::vector< LeafContainerT * > &leaf_container_vector_arg)
Outputs a vector of all LeafContainerT elements that are stored within the octree leaf nodes.
Definition: octree_base.hpp:212
pcl::octree::OctreeBase
Octree class.
Definition: octree_base.h:62
pcl::octree::OctreeBase::findLeaf
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).
Definition: octree_base.hpp:105
pcl::octree::OctreeBase::LeafNode
OctreeLeafNode< LeafContainerT > LeafNode
Definition: octree_base.h:67
pcl::octree::OctreeBranchNode
Abstract octree branch class
Definition: octree_nodes.h:179
pcl::octree::OctreeBase::DepthFirstIterator
OctreeDepthFirstIterator< OctreeT > DepthFirstIterator
Definition: octree_base.h:149
pcl::octree::OctreeBase::octreeCanResize
bool octreeCanResize()
Test if octree is able to dynamically change its depth.
Definition: octree_base.h:681
pcl::octree::OctreeBase::getLeafCount
std::size_t getLeafCount() const
Return the amount of existing leafs in the octree.
Definition: octree_base.h:313
pcl::octree::OctreeBase::deserializeTreeCallback
virtual void deserializeTreeCallback(LeafContainerT &, const OctreeKey &)
Callback executed for every leaf node during deserialization.
Definition: octree_base.h:669
pcl::octree::OctreeIteratorBase
Abstract octree iterator class
Definition: octree_iterator.h:71
pcl::octree::OctreeBreadthFirstIterator
Octree iterator class
Definition: octree_iterator.h:463
pcl::octree::OctreeBase::dynamic_depth_enabled_
bool dynamic_depth_enabled_
Enable dynamic_depth.
Definition: octree_base.h:93
pcl::octree::OctreeBase::max_key_
OctreeKey max_key_
key range
Definition: octree_base.h:96
pcl::octree::OctreeBase::BranchNode
OctreeBranchNode< BranchContainerT > BranchNode
Definition: octree_base.h:66
pcl::octree::OctreeBase::BreadthFirstIterator
OctreeBreadthFirstIterator< OctreeT > BreadthFirstIterator
Definition: octree_base.h:166
pcl::octree::OctreeBase::getRootNode
OctreeNode * getRootNode() const
Retrieve root node.
Definition: octree_base.h:438
pcl::octree::OctreeBase::LeafNodeBreadthFirstIterator
OctreeLeafNodeBreadthFirstIterator< OctreeT > LeafNodeBreadthFirstIterator
Definition: octree_base.h:199
pcl::octree::OctreeBase::removeLeaf
void removeLeaf(const OctreeKey &key_arg)
Remove leaf node from octree.
Definition: octree_base.h:426
pcl::octree::OctreeBase::getTreeDepth
unsigned int getTreeDepth() const
Get the maximum depth of the octree.
Definition: octree_base.h:264
pcl::octree::OctreeBase::leaf_depth_begin
LeafNodeDepthFirstIterator leaf_depth_begin(unsigned int max_depth_arg=0u)
Definition: octree_base.h:136
pcl::octree::OctreeBase::LeafNodeDepthFirstIterator
OctreeLeafNodeDepthFirstIterator< OctreeT > LeafNodeDepthFirstIterator
Definition: octree_base.h:131
pcl::octree::OctreeLeafNodeDepthFirstIterator
Octree leaf node iterator class.
Definition: octree_iterator.h:652
pcl::octree::OctreeDepthFirstIterator
Octree iterator class
Definition: octree_iterator.h:358
pcl::octree::OctreeBase::createLeaf
LeafContainerT * createLeaf(const OctreeKey &key_arg)
Create a leaf node.
Definition: octree_base.h:387
pcl::octree::OctreeBase::depth_begin
DepthFirstIterator depth_begin(unsigned int max_depth_arg=0u)
Definition: octree_base.h:153
pcl::octree::OctreeFixedDepthIterator
Octree iterator class
Definition: octree_iterator.h:563
pcl::octree::OctreeBase::deserializeTreeRecursive
void deserializeTreeRecursive(BranchNode *branch_arg, unsigned int 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.
Definition: octree_base.hpp:492
pcl::octree::OctreeBranchNode::getChildPtr
OctreeNode * getChildPtr(unsigned char child_idx_arg) const
Get pointer to child.
Definition: octree_nodes.h:237
pcl::octree::OctreeLeafNodeBreadthFirstIterator
Octree leaf node iterator class.
Definition: octree_iterator.h:754
pcl::octree::OctreeBase::fixed_depth_begin
FixedDepthIterator fixed_depth_begin(unsigned int fixed_depth_arg=0u)
Definition: octree_base.h:187
pcl::octree::OctreeBase::getBranchBitPattern
char getBranchBitPattern(const BranchNode &branch_arg) const
Generate bit pattern reflecting the existence of child node pointers.
Definition: octree_base.h:484
pcl::octree::OctreeBase::findLeafRecursive
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.
Definition: octree_base.hpp:345
pcl::octree::OctreeBranchNode::hasChild
bool hasChild(unsigned char child_idx_arg) const
Check if branch is pointing to a particular child node.
Definition: octree_nodes.h:258
pcl::octree::OctreeBase::setBranchChildPtr
void setBranchChildPtr(BranchNode &branch_arg, unsigned char child_idx_arg, OctreeNode *new_child_arg)
Assign new child node to branch.
Definition: octree_base.h:472
pcl::octree::OctreeBase::leaf_breadth_begin
LeafNodeBreadthFirstIterator leaf_breadth_begin(unsigned int max_depth_arg=0u)
Definition: octree_base.h:204
pcl::octree::OctreeBase::leaf_count_
std::size_t leaf_count_
Amount of leaf nodes
Definition: octree_base.h:78
pcl::octree::OctreeBase::existLeaf
bool existLeaf(const OctreeKey &key_arg) const
Check for existence of a leaf node in the octree.
Definition: octree_base.h:417
pcl::octree::OctreeBase::FixedDepthIterator
OctreeFixedDepthIterator< OctreeT > FixedDepthIterator
Definition: octree_base.h:183
pcl::octree::OctreeBase::breadth_end
const BreadthFirstIterator breadth_end()
Definition: octree_base.h:177
pcl::octree::OctreePointCloudVoxelCentroidContainer
Octree pointcloud voxel centroid leaf node class
Definition: octree_pointcloud_voxelcentroid.h:52
pcl::octree::OctreeBase::serializeTreeRecursive
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...
Definition: octree_base.hpp:435
pcl::octree::OctreeBase::getBranchCount
std::size_t getBranchCount() const
Return the amount of existing branch nodes in the octree.
Definition: octree_base.h:322
pcl::octree::OctreeBase::branch_count_
std::size_t branch_count_
Amount of branch nodes
Definition: octree_base.h:81
pcl::octree::OctreeLeafNode::getContainerPtr
const ContainerT * getContainerPtr() const
Get const pointer to container.
Definition: octree_nodes.h:153
pcl::octree::OctreeBase::deleteBranchChild
void deleteBranchChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Delete child node and all its subchilds from octree.
Definition: octree_base.h:503
pcl::octree::OctreeContainerEmpty
Octree container class that does not store any information.
Definition: octree_container.h:116