Point Cloud Library (PCL)  1.7.2
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  ////////////////////////////////////////////////////////////////////////////////
62 
63  template<typename PointT, typename ContainerT>
66  {
67  if (FIFO_.size ())
68  {
69  // Get the first entry from the FIFO queue
70  OctreeDiskNode *node = FIFO_.front ();
71  FIFO_.pop_front ();
72 
73  // If not skipping children, not at the max specified depth and we're a branch then iterate over children
74  if (!skip_child_voxels_ && node->getDepth () < this->max_depth_ && node->getNodeType () == pcl::octree::BRANCH_NODE)
75  {
76  // Get the branch node
77  BranchNode* branch = static_cast<BranchNode*> (node);
78  OctreeDiskNode* child = 0;
79 
80  // Iterate over the branches children
81  for (unsigned char child_idx = 0; child_idx < 8 ; child_idx++)
82  {
83  // If child/index exists add it to FIFO queue
84  child = this->octree_.getBranchChildPtr (*branch, child_idx);
85  if (child)
86  {
87  FIFO_.push_back (child);
88  }
89  }
90  }
91  }
92 
93  // Reset skipped children
94  skip_child_voxels_ = false;
95 
96  // If there's a queue, set the current node to the first entry
97  if (FIFO_.size ())
98  {
99  this->currentNode_ = FIFO_.front ();
100  }
101  else
102  {
103  this->currentNode_ = NULL;
104  }
105 
106  return (*this);
107  }
108 
109  ////////////////////////////////////////////////////////////////////////////////
110 
111  }//namesapce pcl
112 }//namespace outofcore
113 
114 #endif //PCL_OUTOFCORE_BREADTH_FIRST_ITERATOR_IMPL_H_
115 
virtual node_type_t getNodeType() const
Pure virtual method for receiving the type of octree node (branch or leaf)
OutofcoreOctreeBaseNode Class internally representing nodes of an outofcore octree, with accessors to its data via the pcl::outofcore::OutofcoreOctreeDiskContainer class or pcl::outofcore::OutofcoreOctreeRamContainer class, whichever it is templated against.
Abstract octree iterator class.
A point structure representing Euclidean xyz coordinates, and the RGB color.
This code defines the octree used for point storage at Urban Robotics.
Definition: octree_base.h:149