Point Cloud Library (PCL)  1.9.1-dev
grid_minimum.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2009-2012, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  * Copyright (c) 2014, RadiantBlue Technologies, Inc.
8  *
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * * Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * * Redistributions in binary form must reproduce the above
18  * copyright notice, this list of conditions and the following
19  * disclaimer in the documentation and/or other materials provided
20  * with the distribution.
21  * * Neither the name of the copyright holder(s) nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  *
38  * $Id$
39  *
40  */
41 
42 #pragma once
43 
44 #include <pcl/filters/boost.h>
45 #include <pcl/filters/filter.h>
46 #include <pcl/filters/filter_indices.h>
47 
48 namespace pcl
49 {
50  /** \brief GridMinimum assembles a local 2D grid over a given PointCloud, and downsamples the data.
51  *
52  * The GridMinimum class creates a *2D grid* over the input point cloud
53  * data. Then, in each *cell* (i.e., 2D grid element), all the points
54  * present will be *downsampled* with the minimum z value. This grid minimum
55  * can be useful in a number of topographic processing tasks such as crudely
56  * estimating ground returns, especially under foliage.
57  *
58  * \author Bradley J Chambers
59  * \ingroup filters
60  */
61  template <typename PointT>
62  class GridMinimum: public FilterIndices<PointT>
63  {
64  protected:
69 
71 
72  public:
73  /** \brief Empty constructor. */
74  GridMinimum (const float resolution)
75  {
76  setResolution (resolution);
77  filter_name_ = "GridMinimum";
78  }
79 
80  /** \brief Destructor. */
82  {
83  }
84 
85  /** \brief Set the grid resolution.
86  * \param[in] resolution the grid resolution
87  */
88  inline void
89  setResolution (const float resolution)
90  {
91  resolution_ = resolution;
92  // Use multiplications instead of divisions
94  }
95 
96  /** \brief Get the grid resolution. */
97  inline float
98  getResolution () { return (resolution_); }
99 
100  protected:
101  /** \brief The resolution. */
102  float resolution_;
103 
104  /** \brief Internal resolution stored as 1/resolution_ for efficiency reasons. */
106 
107  /** \brief Downsample a Point Cloud using a 2D grid approach
108  * \param[out] output the resultant point cloud message
109  */
110  void
111  applyFilter (PointCloud &output) override;
112 
113  /** \brief Filtered results are indexed by an indices array.
114  * \param[out] indices The resultant indices.
115  */
116  void
117  applyFilter (std::vector<int> &indices) override
118  {
119  applyFilterIndices (indices);
120  }
121 
122  /** \brief Filtered results are indexed by an indices array.
123  * \param[out] indices The resultant indices.
124  */
125  void
126  applyFilterIndices (std::vector<int> &indices);
127 
128  };
129 }
130 
131 #ifdef PCL_NO_PRECOMPILE
132 #include <pcl/filters/impl/grid_minimum.hpp>
133 #endif
float inverse_resolution_
Internal resolution stored as 1/resolution_ for efficiency reasons.
Definition: grid_minimum.h:105
void applyFilter(PointCloud &output) override
Downsample a Point Cloud using a 2D grid approach.
void setResolution(const float resolution)
Set the grid resolution.
Definition: grid_minimum.h:89
float resolution_
The resolution.
Definition: grid_minimum.h:102
float getResolution()
Get the grid resolution.
Definition: grid_minimum.h:98
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:44
GridMinimum assembles a local 2D grid over a given PointCloud, and downsamples the data...
Definition: grid_minimum.h:62
void applyFilterIndices(std::vector< int > &indices)
Filtered results are indexed by an indices array.
FilterIndices represents the base class for filters that are about binary point removal.
Filter represents the base filter class.
Definition: filter.h:83
void applyFilter(std::vector< int > &indices) override
Filtered results are indexed by an indices array.
Definition: grid_minimum.h:117
PointCloud represents the base class in PCL for storing collections of 3D points. ...
FilterIndices< PointT >::PointCloud PointCloud
Definition: grid_minimum.h:70
std::string filter_name_
The filter name.
Definition: filter.h:165
GridMinimum(const float resolution)
Empty constructor.
Definition: grid_minimum.h:74
~GridMinimum()
Destructor.
Definition: grid_minimum.h:81