Loading...
Searching...
No Matches
concave_hull.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2009-2012, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#pragma once
#include <pcl/pcl_config.h>
#ifdef HAVE_QHULL
#include <pcl/surface/reconstruction.h> // for MeshConstruction
namespace pcl
{
////////////////////////////////////////////////////////////////////////////////////////////
/** \brief @b ConcaveHull (alpha shapes) using libqhull library.
* \author Aitor Aldoma
* \ingroup surface
*/
template<typename PointInT>
class ConcaveHull : public MeshConstruction<PointInT>
{
protected:
using Ptr = shared_ptr<ConcaveHull<PointInT> >;
using ConstPtr = shared_ptr<const ConcaveHull<PointInT> >;
using PCLBase<PointInT>::input_;
using PCLBase<PointInT>::indices_;
using PCLBase<PointInT>::initCompute;
using PCLBase<PointInT>::deinitCompute;
public:
using MeshConstruction<PointInT>::reconstruct;
using PointCloud = pcl::PointCloud<PointInT>;
using PointCloudPtr = typename PointCloud::Ptr;
using PointCloudConstPtr = typename PointCloud::ConstPtr;
/** \brief Empty constructor. */
ConcaveHull () = default;
/** \brief Empty destructor */
~ConcaveHull () override = default;
/** \brief Compute a concave hull for all points given
*
* \param points the resultant points lying on the concave hull
* \param polygons the resultant concave hull polygons, as a set of
* vertices. The Vertices structure contains an array of point indices.
*/
void
reconstruct (PointCloud &points,
std::vector<pcl::Vertices> &polygons);
/** \brief Compute a concave hull for all points given
* \param output the resultant concave hull vertices
*/
void
reconstruct (PointCloud &output);
/** \brief Set the alpha value, which limits the size of the resultant
* hull segments (the smaller the more detailed the hull).
*
* \param alpha positive, non-zero value, defining the maximum length
* from a vertex to the facet center (center of the voronoi cell).
*/
inline void
setAlpha (double alpha)
{
alpha_ = alpha;
}
/** \brief Returns the alpha parameter, see setAlpha(). */
inline double
getAlpha ()
{
return (alpha_);
}
/** \brief If set, the voronoi cells center will be saved in _voronoi_centers_
* \param voronoi_centers
*/
inline void
setVoronoiCenters (PointCloudPtr voronoi_centers)
{
voronoi_centers_ = voronoi_centers;
}
/** \brief If keep_information_is set to true the convex hull
* points keep other information like rgb, normals, ...
* \param value where to keep the information or not, default is false
*/
void
setKeepInformation (bool value)
{
keep_information_ = value;
}
/** \brief Returns the dimensionality (2 or 3) of the calculated hull. */
inline int
getDimension () const
{
return (dim_);
}
/** \brief Sets the dimension on the input data, 2D or 3D.
* \param[in] dimension The dimension of the input data. If not set, this will be determined automatically.
*/
void
setDimension (int dimension)
{
if ((dimension == 2) || (dimension == 3))
dim_ = dimension;
else
PCL_ERROR ("[pcl::%s::setDimension] Invalid input dimension specified!\n", getClassName ().c_str ());
}
/** \brief Retrieve the indices of the input point cloud that for the convex hull.
*
* \note Should only be called after reconstruction was performed and if the ConcaveHull is
* set to preserve information via setKeepInformation ().
*
* \param[out] hull_point_indices The indices of the points forming the point cloud
*/
void
getHullPointIndices (pcl::PointIndices &hull_point_indices) const;
protected:
/** \brief Class get name method. */
std::string
getClassName () const override
{
return ("ConcaveHull");
}
protected:
/** \brief The actual reconstruction method.
*
* \param points the resultant points lying on the concave hull
* \param polygons the resultant concave hull polygons, as a set of
* vertices. The Vertices structure contains an array of point indices.
*/
void
performReconstruction (PointCloud &points,
std::vector<pcl::Vertices> &polygons);
void
performReconstruction (PolygonMesh &output) override;
void
performReconstruction (std::vector<pcl::Vertices> &polygons) override;
/** \brief The method accepts facets only if the distance from any vertex to the facet->center
* (center of the voronoi cell) is smaller than alpha
*/
double alpha_{0.0};
/** \brief If set to true, the reconstructed point cloud describing the hull is obtained from
* the original input cloud by performing a nearest neighbor search from Qhull output.
*/
bool keep_information_{false};
/** \brief the centers of the voronoi cells */
PointCloudPtr voronoi_centers_{nullptr};
/** \brief the dimensionality of the concave hull */
int dim_{0};
/** \brief vector containing the point cloud indices of the convex hull points. */
pcl::PointIndices hull_indices_;
};
}
#ifdef PCL_NO_PRECOMPILE
#include <pcl/surface/impl/concave_hull.hpp>
#endif
#endif
pcl::ConcaveHull::setVoronoiCenters
void setVoronoiCenters(PointCloudPtr voronoi_centers)
If set, the voronoi cells center will be saved in voronoi_centers.
Definition concave_hull.h:118
pcl::ConcaveHull::setKeepInformation
void setKeepInformation(bool value)
If keep_information_is set to true the convex hull points keep other information like rgb,...
Definition concave_hull.h:128
pcl::ConcaveHull::hull_indices_
pcl::PointIndices hull_indices_
vector containing the point cloud indices of the convex hull points.
Definition concave_hull.h:204
pcl::ConcaveHull::alpha_
double alpha_
The method accepts facets only if the distance from any vertex to the facet->center (center of the vo...
Definition concave_hull.h:190
pcl::ConcaveHull::getDimension
int getDimension() const
Returns the dimensionality (2 or 3) of the calculated hull.
Definition concave_hull.h:135
pcl::ConcaveHull::ConcaveHull
ConcaveHull()=default
Empty constructor.
pcl::ConcaveHull::Ptr
shared_ptr< ConcaveHull< PointInT > > Ptr
Definition concave_hull.h:58
pcl::ConcaveHull::PointCloudConstPtr
typename PointCloud::ConstPtr PointCloudConstPtr
Definition concave_hull.h:71
pcl::ConcaveHull::~ConcaveHull
~ConcaveHull() override=default
Empty destructor.
pcl::ConcaveHull::keep_information_
bool keep_information_
If set to true, the reconstructed point cloud describing the hull is obtained from the original input...
Definition concave_hull.h:195
pcl::ConcaveHull::reconstruct
void reconstruct(PointCloud &points, std::vector< pcl::Vertices > &polygons)
Compute a concave hull for all points given.
Definition concave_hull.hpp:88
pcl::ConcaveHull::voronoi_centers_
PointCloudPtr voronoi_centers_
the centers of the voronoi cells
Definition concave_hull.h:198
pcl::ConcaveHull::setAlpha
void setAlpha(double alpha)
Set the alpha value, which limits the size of the resultant hull segments (the smaller the more detai...
Definition concave_hull.h:102
pcl::ConcaveHull::PointCloud
pcl::PointCloud< PointInT > PointCloud
Definition concave_hull.h:69
pcl::ConcaveHull::ConstPtr
shared_ptr< const ConcaveHull< PointInT > > ConstPtr
Definition concave_hull.h:59
pcl::ConcaveHull::dim_
int dim_
the dimensionality of the concave hull
Definition concave_hull.h:201
pcl::ConcaveHull::PointCloudPtr
typename PointCloud::Ptr PointCloudPtr
Definition concave_hull.h:70
pcl::ConcaveHull::getHullPointIndices
void getHullPointIndices(pcl::PointIndices &hull_point_indices) const
Retrieve the indices of the input point cloud that for the convex hull.
Definition concave_hull.hpp:618
pcl::ConcaveHull::getClassName
std::string getClassName() const override
Class get name method.
Definition concave_hull.h:165
pcl::ConcaveHull::performReconstruction
void performReconstruction(PointCloud &points, std::vector< pcl::Vertices > &polygons)
The actual reconstruction method.
Definition concave_hull.hpp:119
pcl::ConcaveHull::getAlpha
double getAlpha()
Returns the alpha parameter, see setAlpha().
Definition concave_hull.h:109
pcl::ConcaveHull::setDimension
void setDimension(int dimension)
Sets the dimension on the input data, 2D or 3D.
Definition concave_hull.h:144
pcl::MeshConstruction::MeshConstruction
MeshConstruction()=default
Constructor.
pcl::PCLBase
PCL base class.
Definition pcl_base.h:70
pcl::PCLBase< PointInT >::input_
PointCloudConstPtr input_
Definition pcl_base.h:147
pcl::PCLBase< PointInT >::indices_
IndicesPtr indices_
Definition pcl_base.h:150
pcl::PCLBase< PointInT >::initCompute
bool initCompute()
pcl::PCLBase< PointInT >::deinitCompute
bool deinitCompute()
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition point_cloud.h:174
pcl::PointCloud< PointInT >::Ptr
shared_ptr< PointCloud< PointInT > > Ptr
Definition point_cloud.h:414
pcl::PointCloud< PointInT >::ConstPtr
shared_ptr< const PointCloud< PointInT > > ConstPtr
Definition point_cloud.h:415
pcl
Definition convolution.h:46
pcl::PointIndices
Definition PointIndices.h:12
pcl::PolygonMesh
Definition PolygonMesh.h:15