Point Cloud Library (PCL)  1.8.0
octree_pointcloud_changedetector.h
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$
37  */
38 
39 #ifndef PCL_OCTREE_CHANGEDETECTOR_H
40 #define PCL_OCTREE_CHANGEDETECTOR_H
41 
42 #include "octree_pointcloud.h"
43 
44 namespace pcl
45 {
46  namespace octree
47  {
48 
49  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
50  /** \brief @b Octree pointcloud change detector class
51  * \note This pointcloud octree class generate an octrees from a point cloud (zero-copy). It allows to detect new leaf nodes and serialize their point indices
52  * \note The octree pointcloud is initialized with its voxel resolution. Its bounding box is automatically adjusted or can be predefined.
53  * \note
54  * \note typename: PointT: type of point used in pointcloud
55  * \ingroup octree
56  * \author Julius Kammerl (julius@kammerl.de)
57  */
58  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
59  template<typename PointT,
60  typename LeafContainerT = OctreeContainerPointIndices,
61  typename BranchContainerT = OctreeContainerEmpty >
62 
64  LeafContainerT, BranchContainerT, Octree2BufBase<LeafContainerT, BranchContainerT> >
65 
66  {
67 
68  public:
69 
70  /** \brief Constructor.
71  * \param resolution_arg: octree resolution at lowest octree level
72  * */
73  OctreePointCloudChangeDetector (const double resolution_arg) :
74  OctreePointCloud<PointT, LeafContainerT, BranchContainerT,
75  Octree2BufBase<LeafContainerT, BranchContainerT> > (resolution_arg)
76  {
77  }
78 
79  /** \brief Empty class constructor. */
81  {
82  }
83 
84  /** \brief Get a indices from all leaf nodes that did not exist in previous buffer.
85  * \param indicesVector_arg: results are written to this vector of int indices
86  * \param minPointsPerLeaf_arg: minimum amount of points required within leaf node to become serialized.
87  * \return number of point indices
88  */
89  std::size_t getPointIndicesFromNewVoxels (std::vector<int> &indicesVector_arg,
90  const int minPointsPerLeaf_arg = 0)
91  {
92 
93  std::vector<OctreeContainerPointIndices*> leaf_containers;
94  this->serializeNewLeafs (leaf_containers);
95 
96  std::vector<OctreeContainerPointIndices*>::iterator it;
97  std::vector<OctreeContainerPointIndices*>::const_iterator it_end = leaf_containers.end();
98 
99  for (it=leaf_containers.begin(); it!=it_end; ++it)
100  {
101  if (static_cast<int> ((*it)->getSize ()) >= minPointsPerLeaf_arg)
102  (*it)->getPointIndices(indicesVector_arg);
103  }
104 
105  return (indicesVector_arg.size ());
106  }
107  };
108  }
109 }
110 
111 #define PCL_INSTANTIATE_OctreePointCloudChangeDetector(T) template class PCL_EXPORTS pcl::octree::OctreePointCloudChangeDetector<T>;
112 
113 #endif
114 
Octree pointcloud class
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...
std::size_t getPointIndicesFromNewVoxels(std::vector< int > &indicesVector_arg, const int minPointsPerLeaf_arg=0)
Get a indices from all leaf nodes that did not exist in previous buffer.
virtual ~OctreePointCloudChangeDetector()
Empty class constructor.
Octree double buffer class
A point structure representing Euclidean xyz coordinates, and the RGB color.
OctreePointCloudChangeDetector(const double resolution_arg)
Constructor.