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