Point Cloud Library (PCL)  1.13.0-dev
outofcore_breadth_first_iterator.hpp
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: outofcore_depth_first_iterator.hpp 7938 2012-11-14 06:27:39Z jrosen $
37  */
38 
39 #ifndef PCL_OUTOFCORE_BREADTH_FIRST_ITERATOR_IMPL_H_
40 #define PCL_OUTOFCORE_BREADTH_FIRST_ITERATOR_IMPL_H_
41 
42 namespace pcl
43 {
44  namespace outofcore
45  {
46 
47  template<typename PointT, typename ContainerT>
49  : OutofcoreIteratorBase<PointT, ContainerT> (octree_arg)
50  {
51  reset();
52  }
53 
54  ////////////////////////////////////////////////////////////////////////////////
55 
56  template<typename PointT, typename ContainerT>
58 
59  ////////////////////////////////////////////////////////////////////////////////
60 
61  template<typename PointT, typename ContainerT>
64  {
65  if (!FIFO_.empty ())
66  {
67  // Get the first entry from the FIFO queue
68  OctreeDiskNode *node = FIFO_.front ();
69  FIFO_.pop_front ();
70 
71  // If not skipping children, not at the max specified depth and we're a branch then iterate over children
72  if (!skip_child_voxels_ && node->getDepth () < this->max_depth_ && node->getNodeType () == pcl::octree::BRANCH_NODE)
73  {
74  // Get the branch node
75  auto* branch = static_cast<BranchNode*> (node);
76  OctreeDiskNode* child = nullptr;
77 
78  // Iterate over the branches children
79  for (unsigned char child_idx = 0; child_idx < 8 ; child_idx++)
80  {
81  // If child/index exists add it to FIFO queue
82  child = this->octree_.getBranchChildPtr (*branch, child_idx);
83  if (child)
84  {
85  FIFO_.push_back (child);
86  }
87  }
88  }
89  }
90 
91  // Reset skipped children
92  skip_child_voxels_ = false;
93 
94  // If there's a queue, set the current node to the first entry
95  if (!FIFO_.empty ())
96  {
97  this->currentNode_ = FIFO_.front ();
98  }
99  else
100  {
101  this->currentNode_ = nullptr;
102  }
103 
104  return (*this);
105  }
106 
107  ////////////////////////////////////////////////////////////////////////////////
108 
109  }//namespace pcl
110 }//namespace outofcore
111 
112 #endif //PCL_OUTOFCORE_BREADTH_FIRST_ITERATOR_IMPL_H_
113 
This code defines the octree used for point storage at Urban Robotics.
Definition: octree_base.h:150
OutofcoreOctreeBaseNode Class internally representing nodes of an outofcore octree,...
virtual std::size_t getDepth() const
node_type_t getNodeType() const override
Pure virtual method for retrieving the type of octree node (branch or leaf)
A point structure representing Euclidean xyz coordinates, and the RGB color.