Point Cloud Library (PCL)  1.10.1
octree2buf_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 <vector>
42 
43 #include <pcl/octree/octree_container.h>
44 #include <pcl/octree/octree_iterator.h>
45 #include <pcl/octree/octree_key.h>
46 #include <pcl/octree/octree_nodes.h>
47 #include <pcl/pcl_macros.h>
48 
49 namespace pcl {
50 namespace octree {
51 
52 template <typename ContainerT>
54 
55 public:
56  /** \brief Empty constructor. */
58 
59  /** \brief Copy constructor. */
61  {
62  *this = source;
63  }
64 
65  /** \brief Copy operator. */
66  inline BufferedBranchNode&
67  operator=(const BufferedBranchNode& source_arg)
68  {
69  memset(child_node_array_, 0, sizeof(child_node_array_));
70 
71  for (unsigned char b = 0; b < 2; ++b)
72  for (unsigned char i = 0; i < 8; ++i)
73  if (source_arg.child_node_array_[b][i])
74  child_node_array_[b][i] = source_arg.child_node_array_[b][i]->deepCopy();
75 
76  return (*this);
77  }
78 
79  /** \brief Empty constructor. */
81 
82  /** \brief Method to perform a deep copy of the octree */
84  deepCopy() const override
85  {
86  return new BufferedBranchNode(*this);
87  }
88 
89  /** \brief Get child pointer in current branch node
90  * \param buffer_arg: buffer selector
91  * \param index_arg: index of child in node
92  * \return pointer to child node
93  */
94  inline OctreeNode*
95  getChildPtr(unsigned char buffer_arg, unsigned char index_arg) const
96  {
97  assert((buffer_arg < 2) && (index_arg < 8));
98  return child_node_array_[buffer_arg][index_arg];
99  }
100 
101  /** \brief Set child pointer in current branch node
102  * \param buffer_arg: buffer selector
103  * \param index_arg: index of child in node
104  * \param newNode_arg: pointer to new child node
105  */
106  inline void
107  setChildPtr(unsigned char buffer_arg,
108  unsigned char index_arg,
109  OctreeNode* newNode_arg)
110  {
111  assert((buffer_arg < 2) && (index_arg < 8));
112  child_node_array_[buffer_arg][index_arg] = newNode_arg;
113  }
114 
115  /** \brief Check if branch is pointing to a particular child node
116  * \param buffer_arg: buffer selector
117  * \param index_arg: index of child in node
118  * \return "true" if pointer to child node exists; "false" otherwise
119  */
120  inline bool
121  hasChild(unsigned char buffer_arg, unsigned char index_arg) const
122  {
123  assert((buffer_arg < 2) && (index_arg < 8));
124  return (child_node_array_[buffer_arg][index_arg] != nullptr);
125  }
126 
127  /** \brief Get the type of octree node. Returns LEAVE_NODE type */
129  getNodeType() const override
130  {
131  return BRANCH_NODE;
132  }
133 
134  /** \brief Reset branch node container for every branch buffer. */
135  inline void
137  {
138  memset(&child_node_array_[0][0], 0, sizeof(OctreeNode*) * 8 * 2);
139  }
140 
141  /** \brief Get const pointer to container */
142  const ContainerT* operator->() const { return &container_; }
143 
144  /** \brief Get pointer to container */
145  ContainerT* operator->() { return &container_; }
146 
147  /** \brief Get const reference to container */
148  const ContainerT& operator*() const { return container_; }
149 
150  /** \brief Get reference to container */
151  ContainerT& operator*() { return container_; }
152 
153  /** \brief Get const reference to container */
154  const ContainerT&
155  getContainer() const
156  {
157  return container_;
158  }
159 
160  /** \brief Get reference to container */
161  ContainerT&
163  {
164  return container_;
165  }
166 
167  /** \brief Get const pointer to container */
168  const ContainerT*
170  {
171  return &container_;
172  }
173 
174  /** \brief Get pointer to container */
175  ContainerT*
177  {
178  return &container_;
179  }
180 
181 protected:
182  ContainerT container_;
183 
185 };
186 
187 /** \brief @b Octree double buffer class
188  *
189  * This octree implementation keeps two separate octree structures in memory
190  * which allows for differentially comparison of the octree structures (change
191  * detection, differential encoding).
192  * \note The tree depth defines the maximum amount of octree voxels / leaf nodes (should
193  * be initially defined).
194  * \note All leaf nodes are addressed by integer indices.
195  * \note The tree depth equates to the bit length of the voxel indices.
196  * \ingroup octree
197  * \author Julius Kammerl (julius@kammerl.de)
198  */
199 template <typename LeafContainerT = int,
200  typename BranchContainerT = OctreeContainerEmpty>
202 
203 public:
205 
206  // iterators are friends
212 
215 
216  using BranchContainer = BranchContainerT;
217  using LeafContainer = LeafContainerT;
218 
219  // Octree default iterators
222  Iterator
223  begin(unsigned int max_depth_arg = 0)
224  {
225  return Iterator(this, max_depth_arg);
226  };
227  const Iterator
228  end()
229  {
230  return Iterator();
231  };
232 
233  // Octree leaf node iterators
234  // The previous deprecated names
235  // LeafNodeIterator and ConstLeafNodeIterator are deprecated.
236  // Please use LeafNodeDepthFirstIterator and ConstLeafNodeDepthFirstIterator instead.
239 
240  PCL_DEPRECATED("use leaf_depth_begin() instead")
242  leaf_begin(unsigned int max_depth_arg = 0)
243  {
244  return LeafNodeIterator(this, max_depth_arg);
245  };
246 
247  PCL_DEPRECATED("use leaf_depth_end() instead") const LeafNodeIterator leaf_end()
248  {
249  return LeafNodeIterator();
250  };
251 
252  // The currently valide names
257  leaf_depth_begin(unsigned int max_depth_arg = 0)
258  {
259  return LeafNodeDepthFirstIterator(this, max_depth_arg);
260  };
261 
264  {
266  };
267 
268  // Octree depth-first iterators
272  depth_begin(unsigned int maxDepth_arg = 0)
273  {
274  return DepthFirstIterator(this, maxDepth_arg);
275  };
276  const DepthFirstIterator
278  {
279  return DepthFirstIterator();
280  };
281 
282  // Octree breadth-first iterators
286  breadth_begin(unsigned int max_depth_arg = 0)
287  {
288  return BreadthFirstIterator(this, max_depth_arg);
289  };
292  {
293  return BreadthFirstIterator();
294  };
295 
296  // Octree leaf node iterators
300 
302  leaf_breadth_begin(unsigned int max_depth_arg = 0u)
303  {
304  return LeafNodeBreadthIterator(this,
305  max_depth_arg ? max_depth_arg : this->octree_depth_);
306  };
307 
310  {
311  return LeafNodeBreadthIterator(this, 0, nullptr);
312  };
313 
314  /** \brief Empty constructor. */
315  Octree2BufBase();
316 
317  /** \brief Empty deconstructor. */
318  virtual ~Octree2BufBase();
319 
320  /** \brief Copy constructor. */
322  : leaf_count_(source.leaf_count_)
323  , branch_count_(source.branch_count_)
324  , root_node_(new (BranchNode)(*(source.root_node_)))
325  , depth_mask_(source.depth_mask_)
326  , max_key_(source.max_key_)
329  , octree_depth_(source.octree_depth_)
331  {}
332 
333  /** \brief Copy constructor. */
334  inline Octree2BufBase&
335  operator=(const Octree2BufBase& source)
336  {
337  leaf_count_ = source.leaf_count_;
338  branch_count_ = source.branch_count_;
339  root_node_ = new (BranchNode)(*(source.root_node_));
340  depth_mask_ = source.depth_mask_;
341  max_key_ = source.max_key_;
344  octree_depth_ = source.octree_depth_;
346  return (*this);
347  }
348 
349  /** \brief Set the maximum amount of voxels per dimension.
350  * \param max_voxel_index_arg: maximum amount of voxels per dimension
351  */
352  void
353  setMaxVoxelIndex(unsigned int max_voxel_index_arg);
354 
355  /** \brief Set the maximum depth of the octree.
356  * \param depth_arg: maximum depth of octree
357  */
358  void
359  setTreeDepth(unsigned int depth_arg);
360 
361  /** \brief Get the maximum depth of the octree.
362  * \return depth_arg: maximum depth of octree
363  */
364  inline unsigned int
365  getTreeDepth() const
366  {
367  return this->octree_depth_;
368  }
369 
370  /** \brief Create new leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
371  * \note If leaf node already exist, this method returns the existing node
372  * \param idx_x_arg: index of leaf node in the X axis.
373  * \param idx_y_arg: index of leaf node in the Y axis.
374  * \param idx_z_arg: index of leaf node in the Z axis.
375  * \return pointer to new leaf node container.
376  */
377  LeafContainerT*
378  createLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg);
379 
380  /** \brief Find leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
381  * \note If leaf node already exist, this method returns the existing node
382  * \param idx_x_arg: index of leaf node in the X axis.
383  * \param idx_y_arg: index of leaf node in the Y axis.
384  * \param idx_z_arg: index of leaf node in the Z axis.
385  * \return pointer to leaf node container if found, null pointer otherwise.
386  */
387  LeafContainerT*
388  findLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg);
389 
390  /** \brief Check for the existence of leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
391  * \param idx_x_arg: index of leaf node in the X axis.
392  * \param idx_y_arg: index of leaf node in the Y axis.
393  * \param idx_z_arg: index of leaf node in the Z axis.
394  * \return "true" if leaf node search is successful, otherwise it returns "false".
395  */
396  bool
397  existLeaf(unsigned int idx_x_arg,
398  unsigned int idx_y_arg,
399  unsigned int idx_z_arg) const;
400 
401  /** \brief Remove leaf node at (idx_x_arg, idx_y_arg, idx_z_arg).
402  * \param idx_x_arg: index of leaf node in the X axis.
403  * \param idx_y_arg: index of leaf node in the Y axis.
404  * \param idx_z_arg: index of leaf node in the Z axis.
405  */
406  void
407  removeLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg);
408 
409  /** \brief Return the amount of existing leafs in the octree.
410  * \return amount of registered leaf nodes.
411  */
412  inline std::size_t
413  getLeafCount() const
414  {
415  return (leaf_count_);
416  }
417 
418  /** \brief Return the amount of existing branches in the octree.
419  * \return amount of branch nodes.
420  */
421  inline std::size_t
423  {
424  return (branch_count_);
425  }
426 
427  /** \brief Delete the octree structure and its leaf nodes.
428  */
429  void
430  deleteTree();
431 
432  /** \brief Delete octree structure of previous buffer. */
433  inline void
435  {
437  }
438 
439  /** \brief Delete the octree structure in the current buffer. */
440  inline void
442  {
445  leaf_count_ = 0;
446  }
447 
448  /** \brief Switch buffers and reset current octree structure. */
449  void
450  switchBuffers();
451 
452  /** \brief Serialize octree into a binary output vector describing its branch node
453  * structure.
454  * \param binary_tree_out_arg: reference to output vector for writing binary
455  * tree structure.
456  * \param do_XOR_encoding_arg: select if binary tree structure should be generated
457  * based on current octree (false) of based on a XOR comparison between current and
458  * previous octree
459  **/
460  void
461  serializeTree(std::vector<char>& binary_tree_out_arg,
462  bool do_XOR_encoding_arg = false);
463 
464  /** \brief Serialize octree into a binary output vector describing its branch node
465  * structure and and push all DataT elements stored in the octree to a vector.
466  * \param binary_tree_out_arg: reference to output vector for writing binary tree
467  * structure.
468  * \param leaf_container_vector_arg: pointer to all LeafContainerT objects in the
469  * octree
470  * \param do_XOR_encoding_arg: select if binary tree structure should be
471  * generated based on current octree (false) of based on a XOR comparison between
472  * current and previous octree
473  **/
474  void
475  serializeTree(std::vector<char>& binary_tree_out_arg,
476  std::vector<LeafContainerT*>& leaf_container_vector_arg,
477  bool do_XOR_encoding_arg = false);
478 
479  /** \brief Outputs a vector of all DataT elements that are stored within the octree
480  * leaf nodes.
481  * \param leaf_container_vector_arg: vector of pointers to all LeafContainerT objects
482  * in the octree
483  */
484  void
485  serializeLeafs(std::vector<LeafContainerT*>& leaf_container_vector_arg);
486 
487  /** \brief Outputs a vector of all DataT elements from leaf nodes, that do not exist
488  * in the previous octree buffer.
489  * \param leaf_container_vector_arg: vector of pointers to all LeafContainerT objects
490  * in the octree
491  */
492  void
493  serializeNewLeafs(std::vector<LeafContainerT*>& leaf_container_vector_arg);
494 
495  /** \brief Deserialize a binary octree description vector and create a corresponding
496  * octree structure. Leaf nodes are initialized with getDataTByKey(..).
497  * \param binary_tree_in_arg: reference to input vector for reading binary tree
498  * structure.
499  * \param do_XOR_decoding_arg: select if binary tree structure is based on current
500  * octree (false) of based on a XOR comparison between current and previous octree
501  */
502  void
503  deserializeTree(std::vector<char>& binary_tree_in_arg,
504  bool do_XOR_decoding_arg = false);
505 
506  /** \brief Deserialize a binary octree description and create a corresponding octree
507  * structure. Leaf nodes are initialized with DataT elements from the dataVector.
508  * \param binary_tree_in_arg: reference to inpvectoream for reading binary tree
509  * structure.
510  * \param leaf_container_vector_arg: vector of pointers to all LeafContainerT objects
511  * in the octree
512  * \param do_XOR_decoding_arg: select if binary tree structure is based on current
513  * octree (false) of based on a XOR comparison between current and previous octree
514  */
515  void
516  deserializeTree(std::vector<char>& binary_tree_in_arg,
517  std::vector<LeafContainerT*>& leaf_container_vector_arg,
518  bool do_XOR_decoding_arg = false);
519 
520 protected:
521  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
522  // Protected octree methods based on octree keys
523  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
524 
525  /** \brief Retrieve root node */
526  OctreeNode*
527  getRootNode() const
528  {
529  return (this->root_node_);
530  }
531 
532  /** \brief Find leaf node
533  * \param key_arg: octree key addressing a leaf node.
534  * \return pointer to leaf container. If leaf node is not found, this pointer returns
535  * 0.
536  */
537  inline LeafContainerT*
538  findLeaf(const OctreeKey& key_arg) const
539  {
540  LeafContainerT* result = nullptr;
541  findLeafRecursive(key_arg, depth_mask_, root_node_, result);
542  return result;
543  }
544 
545  /** \brief Create a leaf node.
546  * \note If the leaf node at the given octree node does not exist, it will be created
547  * and added to the tree.
548  * \param key_arg: octree key addressing a leaf node.
549  * \return pointer to an existing or created leaf container.
550  */
551  inline LeafContainerT*
552  createLeaf(const OctreeKey& key_arg)
553  {
554  LeafNode* leaf_node;
555  BranchNode* leaf_node_parent;
556 
558  key_arg, depth_mask_, root_node_, leaf_node, leaf_node_parent, false);
559 
560  LeafContainerT* ret = leaf_node->getContainerPtr();
561 
562  return ret;
563  }
564 
565  /** \brief Check if leaf doesn't exist in the octree
566  * \param key_arg: octree key addressing a leaf node.
567  * \return "true" if leaf node is found; "false" otherwise
568  */
569  inline bool
570  existLeaf(const OctreeKey& key_arg) const
571  {
572  return (findLeaf(key_arg) != nullptr);
573  }
574 
575  /** \brief Remove leaf node from octree
576  * \param key_arg: octree key addressing a leaf node.
577  */
578  inline void
579  removeLeaf(const OctreeKey& key_arg)
580  {
581  if (key_arg <= max_key_) {
583 
584  // we changed the octree structure -> dirty
585  tree_dirty_flag_ = true;
586  }
587  }
588 
589  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
590  // Branch node accessor inline functions
591  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
592 
593  /** \brief Check if branch is pointing to a particular child node
594  * \param branch_arg: reference to octree branch class
595  * \param child_idx_arg: index to child node
596  * \return "true" if pointer to child node exists; "false" otherwise
597  */
598  inline bool
599  branchHasChild(const BranchNode& branch_arg, unsigned char child_idx_arg) const
600  {
601  // test occupancyByte for child existence
602  return (branch_arg.getChildPtr(buffer_selector_, child_idx_arg) != nullptr);
603  }
604 
605  /** \brief Retrieve a child node pointer for child node at child_idx.
606  * \param branch_arg: reference to octree branch class
607  * \param child_idx_arg: index to child node
608  * \return pointer to octree child node class
609  */
610  inline OctreeNode*
611  getBranchChildPtr(const BranchNode& branch_arg, unsigned char child_idx_arg) const
612  {
613  return branch_arg.getChildPtr(buffer_selector_, child_idx_arg);
614  }
615 
616  /** \brief Assign new child node to branch
617  * \param branch_arg: reference to octree branch class
618  * \param child_idx_arg: index to child node
619  * \param new_child_arg: pointer to new child node
620  */
621  inline void
623  unsigned char child_idx_arg,
624  OctreeNode* new_child_arg)
625  {
626  branch_arg.setChildPtr(buffer_selector_, child_idx_arg, new_child_arg);
627  }
628 
629  /** \brief Generate bit pattern reflecting the existence of child node pointers for
630  * current buffer
631  * \param branch_arg: reference to octree branch class
632  * \return a single byte with 8 bits of child node information
633  */
634  inline char
635  getBranchBitPattern(const BranchNode& branch_arg) const
636  {
637  char node_bits;
638 
639  // create bit pattern
640  node_bits = 0;
641  for (unsigned char i = 0; i < 8; i++) {
642  const OctreeNode* child = branch_arg.getChildPtr(buffer_selector_, i);
643  node_bits |= static_cast<char>((!!child) << i);
644  }
645 
646  return (node_bits);
647  }
648 
649  /** \brief Generate bit pattern reflecting the existence of child node pointers in
650  * specific buffer
651  * \param branch_arg: reference to octree branch class
652  * \param bufferSelector_arg: buffer selector
653  * \return a single byte with 8 bits of child node information
654  */
655  inline char
656  getBranchBitPattern(const BranchNode& branch_arg,
657  unsigned char bufferSelector_arg) const
658  {
659  char node_bits;
660 
661  // create bit pattern
662  node_bits = 0;
663  for (unsigned char i = 0; i < 8; i++) {
664  const OctreeNode* child = branch_arg.getChildPtr(bufferSelector_arg, i);
665  node_bits |= static_cast<char>((!!child) << i);
666  }
667 
668  return (node_bits);
669  }
670 
671  /** \brief Generate XOR bit pattern reflecting differences between the two octree
672  * buffers
673  * \param branch_arg: reference to octree branch class
674  * \return a single byte with 8 bits of child node XOR difference information
675  */
676  inline char
677  getBranchXORBitPattern(const BranchNode& branch_arg) const
678  {
679  char node_bits[2];
680 
681  // create bit pattern for both buffers
682  node_bits[0] = node_bits[1] = 0;
683 
684  for (unsigned char i = 0; i < 8; i++) {
685  const OctreeNode* childA = branch_arg.getChildPtr(0, i);
686  const OctreeNode* childB = branch_arg.getChildPtr(1, i);
687 
688  node_bits[0] |= static_cast<char>((!!childA) << i);
689  node_bits[1] |= static_cast<char>((!!childB) << i);
690  }
691 
692  return node_bits[0] ^ node_bits[1];
693  }
694 
695  /** \brief Test if branch changed between previous and current buffer
696  * \param branch_arg: reference to octree branch class
697  * \return "true", if child node information differs between current and previous
698  * octree buffer
699  */
700  inline bool
701  hasBranchChanges(const BranchNode& branch_arg) const
702  {
703  return (getBranchXORBitPattern(branch_arg) > 0);
704  }
705 
706  /** \brief Delete child node and all its subchilds from octree in specific buffer
707  * \param branch_arg: reference to octree branch class
708  * \param buffer_selector_arg: buffer selector
709  * \param child_idx_arg: index to child node
710  */
711  inline void
713  unsigned char buffer_selector_arg,
714  unsigned char child_idx_arg)
715  {
716  if (branch_arg.hasChild(buffer_selector_arg, child_idx_arg)) {
717  OctreeNode* branchChild =
718  branch_arg.getChildPtr(buffer_selector_arg, child_idx_arg);
719 
720  switch (branchChild->getNodeType()) {
721  case BRANCH_NODE: {
722  // free child branch recursively
723  deleteBranch(*static_cast<BranchNode*>(branchChild));
724 
725  // delete unused branch
726  delete (branchChild);
727  break;
728  }
729 
730  case LEAF_NODE: {
731  // push unused leaf to branch pool
732  delete (branchChild);
733  break;
734  }
735  default:
736  break;
737  }
738 
739  // set branch child pointer to 0
740  branch_arg.setChildPtr(buffer_selector_arg, child_idx_arg, nullptr);
741  }
742  }
743 
744  /** \brief Delete child node and all its subchilds from octree in current buffer
745  * \param branch_arg: reference to octree branch class
746  * \param child_idx_arg: index to child node
747  */
748  inline void
749  deleteBranchChild(BranchNode& branch_arg, unsigned char child_idx_arg)
750  {
751  deleteBranchChild(branch_arg, buffer_selector_, child_idx_arg);
752  }
753 
754  /** \brief Delete branch and all its subchilds from octree (both buffers)
755  * \param branch_arg: reference to octree branch class
756  */
757  inline void
759  {
760  // delete all branch node children
761  for (char i = 0; i < 8; i++) {
762 
763  if (branch_arg.getChildPtr(0, i) == branch_arg.getChildPtr(1, i)) {
764  // reference was copied - there is only one child instance to be deleted
765  deleteBranchChild(branch_arg, 0, i);
766 
767  // remove pointers from both buffers
768  branch_arg.setChildPtr(0, i, nullptr);
769  branch_arg.setChildPtr(1, i, nullptr);
770  }
771  else {
772  deleteBranchChild(branch_arg, 0, i);
773  deleteBranchChild(branch_arg, 1, i);
774  }
775  }
776  }
777 
778  /** \brief Fetch and add a new branch child to a branch class in current buffer
779  * \param branch_arg: reference to octree branch class
780  * \param child_idx_arg: index to child node
781  * \return pointer of new branch child to this reference
782  */
783  inline BranchNode*
784  createBranchChild(BranchNode& branch_arg, unsigned char child_idx_arg)
785  {
786  BranchNode* new_branch_child = new BranchNode();
787 
788  branch_arg.setChildPtr(
789  buffer_selector_, child_idx_arg, static_cast<OctreeNode*>(new_branch_child));
790 
791  return new_branch_child;
792  }
793 
794  /** \brief Fetch and add a new leaf child to a branch class
795  * \param branch_arg: reference to octree branch class
796  * \param child_idx_arg: index to child node
797  * \return pointer of new leaf child to this reference
798  */
799  inline LeafNode*
800  createLeafChild(BranchNode& branch_arg, unsigned char child_idx_arg)
801  {
802  LeafNode* new_leaf_child = new LeafNode();
803 
804  branch_arg.setChildPtr(buffer_selector_, child_idx_arg, new_leaf_child);
805 
806  return new_leaf_child;
807  }
808 
809  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
810  // Recursive octree methods
811  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
812 
813  /** \brief Create a leaf node at octree key. If leaf node does already exist, it is
814  * returned.
815  * \param key_arg: reference to an octree key
816  * \param depth_mask_arg: depth mask used for octree key analysis and for branch depth
817  * indicator
818  * \param branch_arg: current branch node
819  * \param return_leaf_arg: return pointer to leaf container
820  * \param parent_of_leaf_arg: return pointer to parent of leaf node
821  * \param branch_reset_arg: Reset pointer array of current branch
822  * \return depth mask at which leaf node was created/found
823  **/
824  unsigned int
825  createLeafRecursive(const OctreeKey& key_arg,
826  unsigned int depth_mask_arg,
827  BranchNode* branch_arg,
828  LeafNode*& return_leaf_arg,
829  BranchNode*& parent_of_leaf_arg,
830  bool branch_reset_arg = false);
831 
832  /** \brief Recursively search for a given leaf node and return a pointer.
833  * \note If leaf node does not exist, a 0 pointer is returned.
834  * \param key_arg: reference to an octree key
835  * \param depth_mask_arg: depth mask used for octree key analysis and for branch
836  * depth indicator
837  * \param branch_arg: current branch node
838  * \param result_arg: pointer to leaf container class
839  **/
840  void
841  findLeafRecursive(const OctreeKey& key_arg,
842  unsigned int depth_mask_arg,
843  BranchNode* branch_arg,
844  LeafContainerT*& result_arg) const;
845 
846  /** \brief Recursively search and delete leaf node
847  * \param key_arg: reference to an octree key
848  * \param depth_mask_arg: depth mask used for octree key analysis and branch depth
849  * indicator
850  * \param branch_arg: current branch node
851  * \return "true" if branch does not contain any childs; "false" otherwise. This
852  * indicates if current branch can be deleted.
853  **/
854  bool
855  deleteLeafRecursive(const OctreeKey& key_arg,
856  unsigned int depth_mask_arg,
857  BranchNode* branch_arg);
858 
859  /** \brief Recursively explore the octree and output binary octree description
860  * together with a vector of leaf node DataT content.
861  * \param branch_arg: current branch node
862  * \param key_arg: reference to an octree key
863  * \param binary_tree_out_arg: binary output vector
864  * \param leaf_container_vector_arg: vector to return pointers to all leaf container
865  * in the tree.
866  * \param do_XOR_encoding_arg: select if binary tree structure should be generated
867  * based on current octree (false) of based on a XOR comparison between current and
868  * previous octree
869  * \param new_leafs_filter_arg: execute callback only for leaf nodes that did not
870  * exist in preceding buffer
871  **/
872  void
874  BranchNode* branch_arg,
875  OctreeKey& key_arg,
876  std::vector<char>* binary_tree_out_arg,
877  typename std::vector<LeafContainerT*>* leaf_container_vector_arg,
878  bool do_XOR_encoding_arg = false,
879  bool new_leafs_filter_arg = false);
880 
881  /** \brief Rebuild an octree based on binary XOR octree description and DataT objects
882  * for leaf node initialization.
883  * \param branch_arg: current branch node
884  * \param depth_mask_arg: depth mask used for octree key analysis and branch depth
885  * indicator
886  * \param key_arg: reference to an octree key
887  * \param binary_tree_in_it_arg iterator of binary input data
888  * \param binary_tree_in_it_end_arg
889  * \param leaf_container_vector_it_arg: iterator pointing to leaf container pointers
890  * to be added to a leaf node
891  * \param leaf_container_vector_it_end_arg: iterator pointing to leaf container
892  * pointers pointing to last object in input container.
893  * \param branch_reset_arg: Reset pointer array of current branch
894  * \param do_XOR_decoding_arg: select if binary tree structure is based on current
895  * octree (false) of based on a XOR comparison between current and previous octree
896  **/
897  void
899  BranchNode* branch_arg,
900  unsigned int depth_mask_arg,
901  OctreeKey& key_arg,
902  typename std::vector<char>::const_iterator& binary_tree_in_it_arg,
903  typename std::vector<char>::const_iterator& binary_tree_in_it_end_arg,
904  typename std::vector<LeafContainerT*>::const_iterator*
905  leaf_container_vector_it_arg,
906  typename std::vector<LeafContainerT*>::const_iterator*
907  leaf_container_vector_it_end_arg,
908  bool branch_reset_arg = false,
909  bool do_XOR_decoding_arg = false);
910 
911  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
912  // Serialization callbacks
913  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
914 
915  /** \brief Callback executed for every leaf node data during serialization
916  **/
917  virtual void
918  serializeTreeCallback(LeafContainerT&, const OctreeKey&)
919  {}
920 
921  /** \brief Callback executed for every leaf node data during deserialization
922  **/
923  virtual void
924  deserializeTreeCallback(LeafContainerT&, const OctreeKey&)
925  {}
926 
927  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
928  // Helpers
929  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
930 
931  /** \brief Recursively explore the octree and remove unused branch and leaf nodes
932  * \param branch_arg: current branch node
933  **/
934  void
935  treeCleanUpRecursive(BranchNode* branch_arg);
936 
937  /** \brief Helper function to calculate the binary logarithm
938  * \param n_arg: some value
939  * \return binary logarithm (log2) of argument n_arg
940  */
941  PCL_DEPRECATED("use std::log2 instead") inline double Log2(double n_arg)
942  {
943  return std::log2(n_arg);
944  }
945 
946  /** \brief Test if octree is able to dynamically change its depth. This is required
947  * for adaptive bounding box adjustment.
948  * \return "false" - not resizeable due to XOR serialization
949  **/
950  inline bool
952  {
953  return (false);
954  }
955 
956  /** \brief Prints binary representation of a byte - used for debugging
957  * \param data_arg - byte to be printed to stdout
958  **/
959  inline void
960  printBinary(char data_arg)
961  {
962  unsigned char mask = 1; // Bit mask
963 
964  // Extract the bits
965  for (int i = 0; i < 8; i++) {
966  // Mask each bit in the byte and print it
967  std::cout << ((data_arg & (mask << i)) ? "1" : "0");
968  }
969  std::cout << std::endl;
970  }
971 
972  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
973  // Globals
974  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
975 
976  /** \brief Amount of leaf nodes **/
977  std::size_t leaf_count_;
978 
979  /** \brief Amount of branch nodes **/
980  std::size_t branch_count_;
981 
982  /** \brief Pointer to root branch node of octree **/
984 
985  /** \brief Depth mask based on octree depth **/
986  unsigned int depth_mask_;
987 
988  /** \brief key range */
990 
991  /** \brief Currently active octree buffer **/
992  unsigned char buffer_selector_;
993 
994  // flags indicating if unused branches and leafs might exist in previous buffer
996 
997  /** \brief Octree depth */
998  unsigned int octree_depth_;
999 
1000  /** \brief Enable dynamic_depth
1001  * \note Note that this parameter is ignored in octree2buf! */
1003 };
1004 } // namespace octree
1005 } // namespace pcl
1006 
1007 #ifdef PCL_NO_PRECOMPILE
1008 #include <pcl/octree/impl/octree2buf_base.hpp>
1009 #endif
pcl::octree::Octree2BufBase::PCL_DEPRECATED
PCL_DEPRECATED("use std::log2 instead") inline double Log2(double n_arg)
Helper function to calculate the binary logarithm.
Definition: octree2buf_base.h:941
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
pcl::octree::BufferedBranchNode::getContainer
ContainerT & getContainer()
Get reference to container.
Definition: octree2buf_base.h:162
pcl::octree::Octree2BufBase::leaf_breadth_begin
LeafNodeBreadthIterator leaf_breadth_begin(unsigned int max_depth_arg=0u)
Definition: octree2buf_base.h:302
pcl::octree::BufferedBranchNode::operator=
BufferedBranchNode & operator=(const BufferedBranchNode &source_arg)
Copy operator.
Definition: octree2buf_base.h:67
pcl::octree::Octree2BufBase::deletePreviousBuffer
void deletePreviousBuffer()
Delete octree structure of previous buffer.
Definition: octree2buf_base.h:434
pcl::octree::Octree2BufBase::breadth_end
const BreadthFirstIterator breadth_end()
Definition: octree2buf_base.h:291
pcl::octree::Octree2BufBase::existLeaf
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).
Definition: octree2buf_base.hpp:134
pcl::octree::BufferedBranchNode::child_node_array_
OctreeNode * child_node_array_[2][8]
Definition: octree2buf_base.h:184
pcl::octree::Octree2BufBase::deleteCurrentBuffer
void deleteCurrentBuffer()
Delete the octree structure in the current buffer.
Definition: octree2buf_base.h:441
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::Octree2BufBase::leaf_depth_end
const LeafNodeDepthFirstIterator leaf_depth_end()
Definition: octree2buf_base.h:263
pcl::octree::Octree2BufBase::branch_count_
std::size_t branch_count_
Amount of branch nodes
Definition: octree2buf_base.h:980
pcl::octree::BufferedBranchNode::getContainerPtr
const ContainerT * getContainerPtr() const
Get const pointer to container.
Definition: octree2buf_base.h:169
pcl::octree::Octree2BufBase::DepthFirstIterator
OctreeDepthFirstIterator< OctreeT > DepthFirstIterator
Definition: octree2buf_base.h:269
pcl::octree::BufferedBranchNode::deepCopy
BufferedBranchNode * deepCopy() const override
Method to perform a deep copy of the octree.
Definition: octree2buf_base.h:84
pcl::octree::Octree2BufBase::serializeLeafs
void serializeLeafs(std::vector< LeafContainerT * > &leaf_container_vector_arg)
Outputs a vector of all DataT elements that are stored within the octree leaf nodes.
Definition: octree2buf_base.hpp:249
pcl::octree::Octree2BufBase::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: octree2buf_base.h:611
pcl::octree::Octree2BufBase::leaf_depth_begin
LeafNodeDepthFirstIterator leaf_depth_begin(unsigned int max_depth_arg=0)
Definition: octree2buf_base.h:257
pcl::octree::Octree2BufBase::getBranchXORBitPattern
char getBranchXORBitPattern(const BranchNode &branch_arg) const
Generate XOR bit pattern reflecting differences between the two octree buffers.
Definition: octree2buf_base.h:677
pcl::octree::BufferedBranchNode::getChildPtr
OctreeNode * getChildPtr(unsigned char buffer_arg, unsigned char index_arg) const
Get child pointer in current branch node.
Definition: octree2buf_base.h:95
pcl::octree::Octree2BufBase::begin
Iterator begin(unsigned int max_depth_arg=0)
Definition: octree2buf_base.h:223
pcl::octree::Octree2BufBase::LeafNodeDepthFirstIterator
OctreeLeafNodeDepthFirstIterator< OctreeT > LeafNodeDepthFirstIterator
Definition: octree2buf_base.h:253
pcl::octree::Octree2BufBase::serializeTreeCallback
virtual void serializeTreeCallback(LeafContainerT &, const OctreeKey &)
Callback executed for every leaf node data during serialization.
Definition: octree2buf_base.h:918
pcl::octree::BufferedBranchNode::operator*
ContainerT & operator*()
Get reference to container.
Definition: octree2buf_base.h:151
pcl::octree::Octree2BufBase::removeLeaf
void removeLeaf(const OctreeKey &key_arg)
Remove leaf node from octree.
Definition: octree2buf_base.h:579
pcl::octree::OctreeKey
Octree key class
Definition: octree_key.h:51
pcl::octree::Octree2BufBase::createBranchChild
BranchNode * createBranchChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Fetch and add a new branch child to a branch class in current buffer.
Definition: octree2buf_base.h:784
pcl::octree::OctreeContainerPointIndices
Octree container class that does store a vector of point indices.
Definition: octree_container.h:251
pcl::octree::Octree2BufBase::buffer_selector_
unsigned char buffer_selector_
Currently active octree buffer
Definition: octree2buf_base.h:992
pcl::octree::Octree2BufBase::getBranchCount
std::size_t getBranchCount() const
Return the amount of existing branches in the octree.
Definition: octree2buf_base.h:422
pcl::octree::BufferedBranchNode::BufferedBranchNode
BufferedBranchNode()
Empty constructor.
Definition: octree2buf_base.h:57
pcl::octree::Octree2BufBase::root_node_
BranchNode * root_node_
Pointer to root branch node of octree
Definition: octree2buf_base.h:983
pcl::octree::Octree2BufBase::depth_mask_
unsigned int depth_mask_
Depth mask based on octree depth
Definition: octree2buf_base.h:986
pcl::octree::Octree2BufBase::getBranchBitPattern
char getBranchBitPattern(const BranchNode &branch_arg, unsigned char bufferSelector_arg) const
Generate bit pattern reflecting the existence of child node pointers in specific buffer.
Definition: octree2buf_base.h:656
pcl::octree::OctreeNode
Abstract octree node class
Definition: octree_nodes.h:62
pcl::octree::Octree2BufBase::printBinary
void printBinary(char data_arg)
Prints binary representation of a byte - used for debugging.
Definition: octree2buf_base.h:960
pcl::octree::Octree2BufBase::hasBranchChanges
bool hasBranchChanges(const BranchNode &branch_arg) const
Test if branch changed between previous and current buffer.
Definition: octree2buf_base.h:701
pcl::octree::BufferedBranchNode::hasChild
bool hasChild(unsigned char buffer_arg, unsigned char index_arg) const
Check if branch is pointing to a particular child node.
Definition: octree2buf_base.h:121
pcl::octree::Octree2BufBase::findLeaf
LeafContainerT * findLeaf(const OctreeKey &key_arg) const
Find leaf node.
Definition: octree2buf_base.h:538
pcl::octree::LEAF_NODE
Definition: octree_nodes.h:55
pcl::octree::Octree2BufBase
Octree double buffer class
Definition: octree2buf_base.h:201
pcl::octree::OctreeLeafNode
Abstract octree leaf class
Definition: octree_nodes.h:84
pcl::octree::BRANCH_NODE
Definition: octree_nodes.h:55
pcl::octree::Octree2BufBase::getTreeDepth
unsigned int getTreeDepth() const
Get the maximum depth of the octree.
Definition: octree2buf_base.h:365
pcl::octree::BufferedBranchNode::~BufferedBranchNode
~BufferedBranchNode()
Empty constructor.
Definition: octree2buf_base.h:80
pcl::octree::Octree2BufBase::deleteLeafRecursive
bool deleteLeafRecursive(const OctreeKey &key_arg, unsigned int depth_mask_arg, BranchNode *branch_arg)
Recursively search and delete leaf node.
Definition: octree2buf_base.hpp:502
pcl::octree::Octree2BufBase::depth_begin
DepthFirstIterator depth_begin(unsigned int maxDepth_arg=0)
Definition: octree2buf_base.h:272
pcl::octree::Octree2BufBase::existLeaf
bool existLeaf(const OctreeKey &key_arg) const
Check if leaf doesn't exist in the octree.
Definition: octree2buf_base.h:570
pcl::octree::Octree2BufBase::createLeaf
LeafContainerT * createLeaf(const OctreeKey &key_arg)
Create a leaf node.
Definition: octree2buf_base.h:552
pcl::octree::BufferedBranchNode::getContainerPtr
ContainerT * getContainerPtr()
Get pointer to container.
Definition: octree2buf_base.h:176
pcl::octree::Octree2BufBase::Octree2BufBase
Octree2BufBase()
Empty constructor.
Definition: octree2buf_base.hpp:46
pcl::octree::Octree2BufBase::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: octree2buf_base.hpp:106
pcl::octree::Octree2BufBase::operator=
Octree2BufBase & operator=(const Octree2BufBase &source)
Copy constructor.
Definition: octree2buf_base.h:335
pcl::octree::Octree2BufBase::leaf_count_
std::size_t leaf_count_
Amount of leaf nodes
Definition: octree2buf_base.h:977
pcl::octree::Octree2BufBase::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: octree2buf_base.hpp:147
pcl::octree::Octree2BufBase::deserializeTreeRecursive
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...
Definition: octree2buf_base.hpp:643
pcl::octree::Octree2BufBase::setTreeDepth
void setTreeDepth(unsigned int depth_arg)
Set the maximum depth of the octree.
Definition: octree2buf_base.hpp:89
pcl::octree::BufferedBranchNode::getNodeType
node_type_t getNodeType() const override
Get the type of octree node.
Definition: octree2buf_base.h:129
pcl::octree::OctreeIteratorBase
Abstract octree iterator class
Definition: octree_iterator.h:72
pcl::octree::OctreeBreadthFirstIterator
Octree iterator class
Definition: octree_iterator.h:463
pcl::octree::BufferedBranchNode::reset
void reset()
Reset branch node container for every branch buffer.
Definition: octree2buf_base.h:136
pcl::octree::BufferedBranchNode
Definition: octree2buf_base.h:53
pcl::octree::BufferedBranchNode::getContainer
const ContainerT & getContainer() const
Get const reference to container.
Definition: octree2buf_base.h:155
pcl::octree::BufferedBranchNode::BufferedBranchNode
BufferedBranchNode(const BufferedBranchNode &source)
Copy constructor.
Definition: octree2buf_base.h:60
pcl::octree::Octree2BufBase::leaf_begin
LeafNodeIterator leaf_begin(unsigned int max_depth_arg=0)
Definition: octree2buf_base.h:242
pcl::octree::Octree2BufBase::octree_depth_
unsigned int octree_depth_
Octree depth.
Definition: octree2buf_base.h:998
pcl::octree::Octree2BufBase::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, bool branch_reset_arg=false)
Create a leaf node at octree key.
Definition: octree2buf_base.hpp:356
pcl::octree::Octree2BufBase::PCL_DEPRECATED
PCL_DEPRECATED("use leaf_depth_end() instead") const LeafNodeIterator leaf_end()
Definition: octree2buf_base.h:247
pcl::octree::Octree2BufBase::octreeCanResize
bool octreeCanResize()
Test if octree is able to dynamically change its depth.
Definition: octree2buf_base.h:951
pcl::octree::node_type_t
node_type_t
Definition: octree_nodes.h:55
pcl::octree::Octree2BufBase::treeCleanUpRecursive
void treeCleanUpRecursive(BranchNode *branch_arg)
Recursively explore the octree and remove unused branch and leaf nodes.
Definition: octree2buf_base.hpp:791
pcl::octree::BufferedBranchNode::operator*
const ContainerT & operator*() const
Get const reference to container.
Definition: octree2buf_base.h:148
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::Octree2BufBase::Octree2BufBase
Octree2BufBase(const Octree2BufBase &source)
Copy constructor.
Definition: octree2buf_base.h:321
pcl::octree::OctreeNode::deepCopy
virtual OctreeNode * deepCopy() const =0
Pure virtual method to perform a deep copy of the octree.
pcl::octree::Octree2BufBase::getBranchBitPattern
char getBranchBitPattern(const BranchNode &branch_arg) const
Generate bit pattern reflecting the existence of child node pointers for current buffer.
Definition: octree2buf_base.h:635
pcl::octree::Octree2BufBase::setBranchChildPtr
void setBranchChildPtr(BranchNode &branch_arg, unsigned char child_idx_arg, OctreeNode *new_child_arg)
Assign new child node to branch.
Definition: octree2buf_base.h:622
pcl::octree::Octree2BufBase::LeafNode
OctreeLeafNode< LeafContainerT > LeafNode
Definition: octree2buf_base.h:214
pcl::octree::Octree2BufBase::branchHasChild
bool branchHasChild(const BranchNode &branch_arg, unsigned char child_idx_arg) const
Check if branch is pointing to a particular child node.
Definition: octree2buf_base.h:599
pcl::octree::Octree2BufBase::createLeafChild
LeafNode * createLeafChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Fetch and add a new leaf child to a branch class.
Definition: octree2buf_base.h:800
pcl::octree::Octree2BufBase::depth_end
const DepthFirstIterator depth_end()
Definition: octree2buf_base.h:277
pcl::octree::Octree2BufBase::getRootNode
OctreeNode * getRootNode() const
Retrieve root node.
Definition: octree2buf_base.h:527
pcl::octree::BufferedBranchNode::setChildPtr
void setChildPtr(unsigned char buffer_arg, unsigned char index_arg, OctreeNode *newNode_arg)
Set child pointer in current branch node.
Definition: octree2buf_base.h:107
pcl::octree::Octree2BufBase::leaf_breadth_end
const LeafNodeBreadthIterator leaf_breadth_end()
Definition: octree2buf_base.h:309
pcl::octree::Octree2BufBase::max_key_
OctreeKey max_key_
key range
Definition: octree2buf_base.h:989
pcl::octree::OctreeLeafNodeBreadthFirstIterator
Octree leaf node iterator class.
Definition: octree_iterator.h:753
pcl::octree::Octree2BufBase::deleteBranch
void deleteBranch(BranchNode &branch_arg)
Delete branch and all its subchilds from octree (both buffers)
Definition: octree2buf_base.h:758
pcl::octree::Octree2BufBase::tree_dirty_flag_
bool tree_dirty_flag_
Definition: octree2buf_base.h:995
pcl::octree::Octree2BufBase::deserializeTree
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.
Definition: octree2buf_base.hpp:269
pcl::octree::BufferedBranchNode::operator->
ContainerT * operator->()
Get pointer to container.
Definition: octree2buf_base.h:145
pcl::octree::Octree2BufBase::BranchNode
BufferedBranchNode< BranchContainerT > BranchNode
Definition: octree2buf_base.h:213
pcl::octree::Octree2BufBase::BreadthFirstIterator
OctreeBreadthFirstIterator< OctreeT > BreadthFirstIterator
Definition: octree2buf_base.h:283
pcl::octree::Octree2BufBase::deleteTree
void deleteTree()
Delete the octree structure and its leaf nodes.
Definition: octree2buf_base.hpp:161
pcl::octree::Octree2BufBase::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: octree2buf_base.hpp:466
pcl::octree::Octree2BufBase::LeafNodeIterator
OctreeLeafNodeDepthFirstIterator< OctreeT > LeafNodeIterator
Definition: octree2buf_base.h:237
pcl::octree::Octree2BufBase::switchBuffers
void switchBuffers()
Switch buffers and reset current octree structure.
Definition: octree2buf_base.hpp:178
pcl::octree::Octree2BufBase::LeafNodeBreadthIterator
OctreeLeafNodeBreadthFirstIterator< OctreeT > LeafNodeBreadthIterator
Definition: octree2buf_base.h:297
pcl::octree::Octree2BufBase::serializeTreeRecursive
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...
Definition: octree2buf_base.hpp:554
pcl::octree::Octree2BufBase::serializeNewLeafs
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...
Definition: octree2buf_base.hpp:337
pcl::octree::Octree2BufBase::deleteBranchChild
void deleteBranchChild(BranchNode &branch_arg, unsigned char child_idx_arg)
Delete child node and all its subchilds from octree in current buffer.
Definition: octree2buf_base.h:749
pcl::octree::Octree2BufBase::breadth_begin
BreadthFirstIterator breadth_begin(unsigned int max_depth_arg=0)
Definition: octree2buf_base.h:286
pcl::octree::Octree2BufBase::serializeTree
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.
Definition: octree2buf_base.hpp:202
pcl::octree::Octree2BufBase::end
const Iterator end()
Definition: octree2buf_base.h:228
pcl::octree::Octree2BufBase::deleteBranchChild
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.
Definition: octree2buf_base.h:712
pcl::octree::Octree2BufBase::setMaxVoxelIndex
void setMaxVoxelIndex(unsigned int max_voxel_index_arg)
Set the maximum amount of voxels per dimension.
Definition: octree2buf_base.hpp:69
pcl::octree::Octree2BufBase::dynamic_depth_enabled_
bool dynamic_depth_enabled_
Enable dynamic_depth.
Definition: octree2buf_base.h:1002
pcl::octree::OctreeLeafNode::getContainerPtr
const ContainerT * getContainerPtr() const
Get const pointer to container.
Definition: octree_nodes.h:141
pcl::octree::OctreeContainerEmpty
Octree container class that does not store any information.
Definition: octree_container.h:116
pcl::octree::Octree2BufBase::getLeafCount
std::size_t getLeafCount() const
Return the amount of existing leafs in the octree.
Definition: octree2buf_base.h:413
pcl::octree::Octree2BufBase::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: octree2buf_base.hpp:120
pcl::octree::BufferedBranchNode::container_
ContainerT container_
Definition: octree2buf_base.h:182
pcl::octree::BufferedBranchNode::operator->
const ContainerT * operator->() const
Get const pointer to container.
Definition: octree2buf_base.h:142
pcl::octree::Octree2BufBase::deserializeTreeCallback
virtual void deserializeTreeCallback(LeafContainerT &, const OctreeKey &)
Callback executed for every leaf node data during deserialization.
Definition: octree2buf_base.h:924
pcl::octree::Octree2BufBase::Iterator
OctreeDepthFirstIterator< OctreeT > Iterator
Definition: octree2buf_base.h:220
pcl::octree::Octree2BufBase::~Octree2BufBase
virtual ~Octree2BufBase()
Empty deconstructor.
Definition: octree2buf_base.hpp:59