Point Cloud Library (PCL) 1.12.0
Loading...
Searching...
No Matches
concave_hull.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 *
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
40#pragma once
41
42#include <pcl/pcl_config.h>
43#ifdef HAVE_QHULL
44
45#include <pcl/surface/reconstruction.h> // for MeshConstruction
46
47namespace pcl
48{
49 ////////////////////////////////////////////////////////////////////////////////////////////
50 /** \brief @b ConcaveHull (alpha shapes) using libqhull library.
51 * \author Aitor Aldoma
52 * \ingroup surface
53 */
54 template<typename PointInT>
55 class ConcaveHull : public MeshConstruction<PointInT>
56 {
57 protected:
58 using Ptr = shared_ptr<ConcaveHull<PointInT> >;
59 using ConstPtr = shared_ptr<const ConcaveHull<PointInT> >;
60
61 using PCLBase<PointInT>::input_;
62 using PCLBase<PointInT>::indices_;
63 using PCLBase<PointInT>::initCompute;
64 using PCLBase<PointInT>::deinitCompute;
65
66 public:
67 using MeshConstruction<PointInT>::reconstruct;
68
72
73 /** \brief Empty constructor. */
75 {
76 };
77
78 /** \brief Empty destructor */
80
81 /** \brief Compute a concave hull for all points given
82 *
83 * \param points the resultant points lying on the concave hull
84 * \param polygons the resultant concave hull polygons, as a set of
85 * vertices. The Vertices structure contains an array of point indices.
86 */
87 void
88 reconstruct (PointCloud &points,
89 std::vector<pcl::Vertices> &polygons);
90
91 /** \brief Compute a concave hull for all points given
92 * \param output the resultant concave hull vertices
93 */
94 void
95 reconstruct (PointCloud &output);
96
97 /** \brief Set the alpha value, which limits the size of the resultant
98 * hull segments (the smaller the more detailed the hull).
99 *
100 * \param alpha positive, non-zero value, defining the maximum length
101 * from a vertex to the facet center (center of the voronoi cell).
102 */
103 inline void
104 setAlpha (double alpha)
105 {
106 alpha_ = alpha;
107 }
108
109 /** \brief Returns the alpha parameter, see setAlpha(). */
110 inline double
112 {
113 return (alpha_);
114 }
115
116 /** \brief If set, the voronoi cells center will be saved in _voronoi_centers_
117 * \param voronoi_centers
118 */
119 inline void
121 {
122 voronoi_centers_ = voronoi_centers;
123 }
124
125 /** \brief If keep_information_is set to true the convex hull
126 * points keep other information like rgb, normals, ...
127 * \param value where to keep the information or not, default is false
128 */
129 void
131 {
132 keep_information_ = value;
133 }
134
135 /** \brief Returns the dimensionality (2 or 3) of the calculated hull. */
136 inline int
138 {
139 return (dim_);
140 }
141
142 /** \brief Sets the dimension on the input data, 2D or 3D.
143 * \param[in] dimension The dimension of the input data. If not set, this will be determined automatically.
144 */
145 void
146 setDimension (int dimension)
147 {
148 if ((dimension == 2) || (dimension == 3))
149 dim_ = dimension;
150 else
151 PCL_ERROR ("[pcl::%s::setDimension] Invalid input dimension specified!\n", getClassName ().c_str ());
152 }
153
154 /** \brief Retrieve the indices of the input point cloud that for the convex hull.
155 *
156 * \note Should only be called after reconstruction was performed and if the ConcaveHull is
157 * set to preserve information via setKeepInformation ().
158 *
159 * \param[out] hull_point_indices The indices of the points forming the point cloud
160 */
161 void
162 getHullPointIndices (pcl::PointIndices &hull_point_indices) const;
163
164 protected:
165 /** \brief Class get name method. */
166 std::string
167 getClassName () const override
168 {
169 return ("ConcaveHull");
170 }
171
172 protected:
173 /** \brief The actual reconstruction method.
174 *
175 * \param points the resultant points lying on the concave hull
176 * \param polygons the resultant concave hull polygons, as a set of
177 * vertices. The Vertices structure contains an array of point indices.
178 */
179 void
181 std::vector<pcl::Vertices> &polygons);
182
183 void
184 performReconstruction (PolygonMesh &output) override;
185
186 void
187 performReconstruction (std::vector<pcl::Vertices> &polygons) override;
188
189 /** \brief The method accepts facets only if the distance from any vertex to the facet->center
190 * (center of the voronoi cell) is smaller than alpha
191 */
192 double alpha_;
193
194 /** \brief If set to true, the reconstructed point cloud describing the hull is obtained from
195 * the original input cloud by performing a nearest neighbor search from Qhull output.
196 */
198
199 /** \brief the centers of the voronoi cells */
201
202 /** \brief the dimensionality of the concave hull */
203 int dim_;
204
205 /** \brief vector containing the point cloud indices of the convex hull points. */
207 };
208}
209
210#ifdef PCL_NO_PRECOMPILE
211#include <pcl/surface/impl/concave_hull.hpp>
212#endif
213
214#endif
ConcaveHull (alpha shapes) using libqhull library.
void setVoronoiCenters(PointCloudPtr voronoi_centers)
If set, the voronoi cells center will be saved in voronoi_centers
ConcaveHull()
Empty constructor.
void setKeepInformation(bool value)
If keep_information_is set to true the convex hull points keep other information like rgb,...
pcl::PointIndices hull_indices_
vector containing the point cloud indices of the convex hull points.
double alpha_
The method accepts facets only if the distance from any vertex to the facet->center (center of the vo...
int getDimension() const
Returns the dimensionality (2 or 3) of the calculated hull.
~ConcaveHull()
Empty destructor.
shared_ptr< ConcaveHull< PointInT > > Ptr
typename PointCloud::ConstPtr PointCloudConstPtr
bool keep_information_
If set to true, the reconstructed point cloud describing the hull is obtained from the original input...
void reconstruct(PointCloud &points, std::vector< pcl::Vertices > &polygons)
Compute a concave hull for all points given.
PointCloudPtr voronoi_centers_
the centers of the voronoi cells
void setAlpha(double alpha)
Set the alpha value, which limits the size of the resultant hull segments (the smaller the more detai...
shared_ptr< const ConcaveHull< PointInT > > ConstPtr
int dim_
the dimensionality of the concave hull
typename PointCloud::Ptr PointCloudPtr
void getHullPointIndices(pcl::PointIndices &hull_point_indices) const
Retrieve the indices of the input point cloud that for the convex hull.
std::string getClassName() const override
Class get name method.
void performReconstruction(PointCloud &points, std::vector< pcl::Vertices > &polygons)
The actual reconstruction method.
double getAlpha()
Returns the alpha parameter, see setAlpha().
void setDimension(int dimension)
Sets the dimension on the input data, 2D or 3D.
MeshConstruction represents a base surface reconstruction class.
PCL base class.
Definition pcl_base.h:70
PointCloudConstPtr input_
Definition pcl_base.h:147
shared_ptr< const PointCloud< PointT > > ConstPtr
shared_ptr< PointCloud< PointT > > Ptr