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