Point Cloud Library (PCL) 1.12.1
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/filter.h>
45#include <pcl/filters/filter_indices.h>
46
47namespace pcl
48{
49 /** \brief GridMinimum assembles a local 2D grid over a given PointCloud, and downsamples the data.
50 *
51 * The GridMinimum class creates a *2D grid* over the input point cloud
52 * data. Then, in each *cell* (i.e., 2D grid element), all the points
53 * present will be *downsampled* with the minimum z value. This grid minimum
54 * can be useful in a number of topographic processing tasks such as crudely
55 * estimating ground returns, especially under foliage.
56 *
57 * \author Bradley J Chambers
58 * \ingroup filters
59 */
60 template <typename PointT>
61 class GridMinimum: public FilterIndices<PointT>
62 {
63 protected:
68
70
71 public:
72 /** \brief Empty constructor. */
73 GridMinimum (const float resolution)
74 {
75 setResolution (resolution);
76 filter_name_ = "GridMinimum";
77 }
78
79 /** \brief Destructor. */
81 {
82 }
83
84 /** \brief Set the grid resolution.
85 * \param[in] resolution the grid resolution
86 */
87 inline void
88 setResolution (const float resolution)
89 {
90 resolution_ = resolution;
91 // Use multiplications instead of divisions
93 }
94
95 /** \brief Get the grid resolution. */
96 inline float
97 getResolution () { return (resolution_); }
98
99 protected:
100 /** \brief The resolution. */
102
103 /** \brief Internal resolution stored as 1/resolution_ for efficiency reasons. */
105
106 /** \brief Downsample a Point Cloud using a 2D grid approach
107 * \param[out] output the resultant point cloud message
108 */
109 void
110 applyFilter (PointCloud &output) override;
111
112 /** \brief Filtered results are indexed by an indices array.
113 * \param[out] indices The resultant indices.
114 */
115 void
116 applyFilter (Indices &indices) override
117 {
118 applyFilterIndices (indices);
119 }
120
121 /** \brief Filtered results are indexed by an indices array.
122 * \param[out] indices The resultant indices.
123 */
124 void
125 applyFilterIndices (Indices &indices);
126
127 };
128}
129
130#ifdef PCL_NO_PRECOMPILE
131#include <pcl/filters/impl/grid_minimum.hpp>
132#endif
Filter represents the base filter class.
Definition: filter.h:81
std::string filter_name_
The filter name.
Definition: filter.h:158
FilterIndices represents the base class for filters that are about binary point removal.
GridMinimum assembles a local 2D grid over a given PointCloud, and downsamples the data.
Definition: grid_minimum.h:62
void setResolution(const float resolution)
Set the grid resolution.
Definition: grid_minimum.h:88
GridMinimum(const float resolution)
Empty constructor.
Definition: grid_minimum.h:73
float resolution_
The resolution.
Definition: grid_minimum.h:101
~GridMinimum()
Destructor.
Definition: grid_minimum.h:80
void applyFilterIndices(Indices &indices)
Filtered results are indexed by an indices array.
void applyFilter(Indices &indices) override
Filtered results are indexed by an indices array.
Definition: grid_minimum.h:116
float inverse_resolution_
Internal resolution stored as 1/resolution_ for efficiency reasons.
Definition: grid_minimum.h:104
void applyFilter(PointCloud &output) override
Downsample a Point Cloud using a 2D grid approach.
float getResolution()
Get the grid resolution.
Definition: grid_minimum.h:97
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:173
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:133