Point Cloud Library (PCL)  1.7.2
outofcore_iterator_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 #ifndef PCL_OUTOFCORE_ITERATOR_BASE_H_
40 #define PCL_OUTOFCORE_ITERATOR_BASE_H_
41 
42 #include <iterator>
43 
44 #include <pcl/point_types.h>
45 
46 #include <pcl/outofcore/octree_base.h>
47 #include <pcl/outofcore/octree_base_node.h>
48 #include <pcl/outofcore/octree_disk_container.h>
49 
50 namespace pcl
51 {
52  namespace outofcore
53  {
54  /** \brief Abstract octree iterator class
55  * \note This class is based on the octree_iterator written by Julius Kammerl adapted to the outofcore octree. The interface is very similar, but it does \b not inherit the \ref pcl::octree iterator base.
56  * \ingroup outofcore
57  * \author Stephen Fox (foxstephend@gmail.com)
58  */
59  template<typename PointT, typename ContainerT>
60  class OutofcoreIteratorBase : public std::iterator<std::forward_iterator_tag, /*iterator type*/
61  const OutofcoreOctreeBaseNode<ContainerT, PointT>,
62  void, /*no defined distance between iterator*/
63  const OutofcoreOctreeBaseNode<ContainerT, PointT>*,/*Pointer type*/
64  const OutofcoreOctreeBaseNode<ContainerT, PointT>&>/*Reference type*/
65  {
66  public:
69 
72 
74 
75  explicit
76  OutofcoreIteratorBase (OctreeDisk& octree_arg)
77  : octree_ (octree_arg), currentNode_ (NULL)
78  {
79  reset ();
80  }
81 
82  virtual
84  {
85  }
86 
89  {
90  }
91 
92  inline OutofcoreIteratorBase&
94  {
95  octree_ = src.octree_;
98  }
99 
100 
101  inline OutofcoreNodeType*
102  operator* () const
103  {
104  return (this->getCurrentOctreeNode ());
105  }
106 
107  virtual inline OutofcoreNodeType*
109  {
110  return (currentNode_);
111  }
112 
113  virtual inline void
114  reset ()
115  {
116  currentNode_ = static_cast<OctreeDiskNode*> (octree_.getRootNode ());
118  max_depth_ = static_cast<unsigned int> (octree_.getDepth ());
119  }
120 
121  inline void
122  setMaxDepth (unsigned int max_depth)
123  {
124  if (max_depth > static_cast<unsigned int> (octree_.getDepth ()))
125  {
126  max_depth = static_cast<unsigned int> (octree_.getDepth ());
127  }
128 
129  max_depth_ = max_depth;
130  }
131 
132  protected:
133  OctreeDisk& octree_;
134  OctreeDiskNode* currentNode_;
135  unsigned int currentOctreeDepth_;
136  unsigned int max_depth_;
137  };
138 
139 
140 #if 0
141  class PCL_EXPORTS OutofcoreBreadthFirstIterator : public OutofcoreIteratorBase
142  {
143 
144 
145 
146 
147  };
148 
149  class PCL_EXPORTS OutofcoreLeafIterator : public OutofcoreIteratorBase
150  {
151 
152 
153 
154  };
155 #endif
156  }
157 }
158 
159 #endif //PCL_OUTOFCORE_ITERATOR_BASE_H_
pcl::outofcore::OutofcoreOctreeBase< ContainerT, PointT >::BranchNode BranchNode
pcl::outofcore::OutofcoreOctreeBase< ContainerT, PointT > OctreeDisk
boost::uint64_t getDepth() const
Get number of LODs, which is the height of the tree.
Definition: octree_base.h:433
OutofcoreIteratorBase(const OutofcoreIteratorBase &src)
OutofcoreIteratorBase & operator=(const OutofcoreIteratorBase &src)
virtual OutofcoreNodeType * getCurrentOctreeNode() const
pcl::outofcore::OutofcoreOctreeBase< ContainerT, PointT >::LeafNode LeafNode
OctreeDisk::OutofcoreNodeType OutofcoreNodeType
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.
OutofcoreNodeType * getRootNode()
Definition: octree_base.h:583
This code defines the octree used for point storage at Urban Robotics.
Definition: octree_base.h:149
pcl::outofcore::OutofcoreOctreeBaseNode< ContainerT, PointT > OctreeDiskNode