Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
octree_container.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, 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: octree_nodes.h 5596 2012-04-17 15:09:31Z jkammerl $
37  */
38 
39 #ifndef OCTREE_CONTAINER_H
40 #define OCTREE_CONTAINER_H
41 
42 #include <string.h>
43 #include <vector>
44 #include <cstddef>
45 
46 #include <pcl/pcl_macros.h>
47 
48 using namespace std;
49 
50 namespace pcl
51 {
52  namespace octree
53  {
55 
59  template<typename DataT>
61  {
62  public:
65  {
66  }
67 
70  {
71  }
72 
74  virtual
76  {
77  }
78 
80  virtual OctreeContainerEmpty *
81  deepCopy () const
82  {
83  return (new OctreeContainerEmpty (*this));
84  }
85 
89  void
90  setData (const DataT&)
91  {
92  }
93 
96  void
97  getData (DataT&) const
98  {
99  }
100 
101 
105  void
106  getData (std::vector<DataT>&) const
107  {
108  }
109 
113  size_t
114  getSize () const
115  {
116  return 0;
117  }
118 
120  void
121  reset ()
122  {
123  }
124  };
125 
127 
131  template<typename DataT>
133  {
134  public:
137  data_ (),
138  isEmpty_(true)
139  {
140  reset ();
141  }
142 
145  data_ (source.data_), isEmpty_ (source.isEmpty_)
146  {
147  }
148 
150  virtual
152  {
153  }
154 
156  virtual OctreeContainerDataT*
157  deepCopy () const
158  {
159  return (new OctreeContainerDataT (*this));
160  }
161 
165  void
166  setData (const DataT& data_arg)
167  {
168  this->data_ = data_arg;
169  isEmpty_ = false;
170  }
171 
175  void
176  getData (DataT& dataVector_arg) const
177  {
178  if (!isEmpty_)
179  dataVector_arg = this->data_;
180  }
181 
185  void
186  getData (vector<DataT>& dataVector_arg) const
187  {
188  if (!isEmpty_)
189  dataVector_arg.push_back (this->data_);
190  }
191 
195  size_t
196  getSize () const
197  {
198  return isEmpty_ ? 0 : 1;
199  }
200 
202  void
203  reset ()
204  {
205  isEmpty_ = true;
206  }
207  protected:
209  DataT data_;
210 
212  bool isEmpty_;
213  };
214 
216 
220  template<typename DataT>
222  {
223  public:
226  leafDataTVector_ ()
227  {
228  }
229 
232  leafDataTVector_ (source.leafDataTVector_)
233  {
234  }
235 
237  virtual
239  {
240  }
241 
244  deepCopy () const
245  {
246  return (new OctreeContainerDataTVector (*this));
247  }
248 
252  void
253  setData (const DataT& data_arg)
254  {
255  leafDataTVector_.push_back (data_arg);
256  }
257 
261  void
262  getData (DataT& data_arg) const
263  {
264  if (leafDataTVector_.size () > 0)
265  data_arg = leafDataTVector_.back ();
266  }
267 
271  void
272  getData (std::vector<DataT>& dataVector_arg) const
273  {
274  dataVector_arg.insert (dataVector_arg.end (),
275  leafDataTVector_.begin (), leafDataTVector_.end ());
276  }
277 
281  const std::vector<DataT>& getDataTVector () const
282  {
283  return leafDataTVector_;
284  }
285 
289  size_t
290  getSize () const
291  {
292  return leafDataTVector_.size ();
293  }
294 
296  void
297  reset ()
298  {
299  leafDataTVector_.clear ();
300  }
301 
302  protected:
304  vector<DataT> leafDataTVector_;
305  };
306 
307  }
308 }
309 
310 #endif