reconstruction.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-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_base.h>
#include <pcl/PolygonMesh.h>
#include <pcl/search/search.h> // for Search
namespace pcl
{
/** \brief Pure abstract class. All types of meshing/reconstruction
* algorithms in \b libpcl_surface must inherit from this, in order to make
* sure we have a consistent API. The methods that we care about here are:
*
* - \b setSearchMethod(&SearchPtr): passes a search locator
* - \b reconstruct(&PolygonMesh): creates a PolygonMesh object from the input data
*
* \author Radu B. Rusu, Michael Dixon, Alexandru E. Ichim
* \ingroup surface
*/
template <typename PointInT>
class PCLSurfaceBase: public PCLBase<PointInT>
{
public:
using Ptr = shared_ptr<PCLSurfaceBase<PointInT> >;
using ConstPtr = shared_ptr<const PCLSurfaceBase<PointInT> >;
using KdTree = pcl::search::Search<PointInT>;
using KdTreePtr = typename KdTree::Ptr;
/** \brief Empty constructor. */
PCLSurfaceBase () : tree_ () {}
/** \brief Empty destructor */
~PCLSurfaceBase () {}
/** \brief Provide an optional pointer to a search object.
* \param[in] tree a pointer to the spatial search object.
*/
inline void
setSearchMethod (const KdTreePtr &tree)
{
tree_ = tree;
}
/** \brief Get a pointer to the search method used. */
inline KdTreePtr
getSearchMethod () { return (tree_); }
/** \brief Base method for surface reconstruction for all points given in
* <setInputCloud (), setIndices ()>
* \param[out] output the resultant reconstructed surface model
*/
virtual void
reconstruct (pcl::PolygonMesh &output) = 0;
protected:
/** \brief A pointer to the spatial search object. */
KdTreePtr tree_;
/** \brief Abstract class get name method. */
virtual std::string
getClassName () const { return (""); }
};
/** \brief SurfaceReconstruction represents a base surface reconstruction
* class. All \b surface reconstruction methods take in a point cloud and
* generate a new surface from it, by either re-sampling the data or
* generating new data altogether. These methods are thus \b not preserving
* the topology of the original data.
*
* \note Reconstruction methods that always preserve the original input
* point cloud data as the surface vertices and simply construct the mesh on
* top should inherit from \ref MeshConstruction.
*
* \author Radu B. Rusu, Michael Dixon, Alexandru E. Ichim
* \ingroup surface
*/
template <typename PointInT>
class SurfaceReconstruction: public PCLSurfaceBase<PointInT>
{
public:
using Ptr = shared_ptr<SurfaceReconstruction<PointInT> >;
using ConstPtr = shared_ptr<const SurfaceReconstruction<PointInT> >;
using PCLSurfaceBase<PointInT>::input_;
using PCLSurfaceBase<PointInT>::indices_;
using PCLSurfaceBase<PointInT>::initCompute;
using PCLSurfaceBase<PointInT>::deinitCompute;
using PCLSurfaceBase<PointInT>::tree_;
using PCLSurfaceBase<PointInT>::getClassName;
/** \brief Constructor. */
SurfaceReconstruction () : check_tree_ (true) {}
/** \brief Destructor. */
~SurfaceReconstruction () {}
/** \brief Base method for surface reconstruction for all points given in
* <setInputCloud (), setIndices ()>
* \param[out] output the resultant reconstructed surface model
*/
void
reconstruct (pcl::PolygonMesh &output) override;
/** \brief Base method for surface reconstruction for all points given in
* <setInputCloud (), setIndices ()>
* \param[out] points the resultant points lying on the new surface
* \param[out] polygons the resultant polygons, as a set of
* vertices. The Vertices structure contains an array of point indices.
*/
virtual void
reconstruct (pcl::PointCloud<PointInT> &points,
std::vector<pcl::Vertices> &polygons);
protected:
/** \brief A flag specifying whether or not the derived reconstruction
* algorithm needs the search object \a tree.*/
bool check_tree_;
/** \brief Abstract surface reconstruction method.
* \param[out] output the output polygonal mesh
*/
virtual void
performReconstruction (pcl::PolygonMesh &output) = 0;
/** \brief Abstract surface reconstruction method.
* \param[out] points the resultant points lying on the surface
* \param[out] polygons the resultant polygons, as a set of vertices. The Vertices structure contains an array of point indices.
*/
virtual void
performReconstruction (pcl::PointCloud<PointInT> &points,
std::vector<pcl::Vertices> &polygons) = 0;
};
/** \brief MeshConstruction represents a base surface reconstruction
* class. All \b mesh constructing methods that take in a point cloud and
* generate a surface that uses the original data as vertices should inherit
* from this class.
*
* \note Reconstruction methods that generate a new surface or create new
* vertices in locations different than the input data should inherit from
* \ref SurfaceReconstruction.
*
* \author Radu B. Rusu, Michael Dixon, Alexandru E. Ichim
* \ingroup surface
*/
template <typename PointInT>
class MeshConstruction: public PCLSurfaceBase<PointInT>
{
public:
using Ptr = shared_ptr<MeshConstruction<PointInT> >;
using ConstPtr = shared_ptr<const MeshConstruction<PointInT> >;
using PCLSurfaceBase<PointInT>::input_;
using PCLSurfaceBase<PointInT>::indices_;
using PCLSurfaceBase<PointInT>::initCompute;
using PCLSurfaceBase<PointInT>::deinitCompute;
using PCLSurfaceBase<PointInT>::tree_;
using PCLSurfaceBase<PointInT>::getClassName;
/** \brief Constructor. */
MeshConstruction () : check_tree_ (true) {}
/** \brief Destructor. */
~MeshConstruction () {}
/** \brief Base method for surface reconstruction for all points given in
* <setInputCloud (), setIndices ()>
* \param[out] output the resultant reconstructed surface model
*
* \note This method copies the input point cloud data from
* PointCloud<T> to PCLPointCloud2, and is implemented here for backwards
* compatibility only!
*
*/
void
reconstruct (pcl::PolygonMesh &output) override;
/** \brief Base method for mesh construction for all points given in
* <setInputCloud (), setIndices ()>
* \param[out] polygons the resultant polygons, as a set of
* vertices. The Vertices structure contains an array of point indices.
*/
virtual void
reconstruct (std::vector<pcl::Vertices> &polygons);
protected:
/** \brief A flag specifying whether or not the derived reconstruction
* algorithm needs the search object \a tree.*/
bool check_tree_;
/** \brief Abstract surface reconstruction method.
* \param[out] output the output polygonal mesh
*/
virtual void
performReconstruction (pcl::PolygonMesh &output) = 0;
/** \brief Abstract surface reconstruction method.
* \param[out] polygons the resultant polygons, as a set of vertices. The Vertices structure contains an array of point indices.
*/
virtual void
performReconstruction (std::vector<pcl::Vertices> &polygons) = 0;
};
}
#include <pcl/surface/impl/reconstruction.hpp>
pcl::MeshConstruction
MeshConstruction represents a base surface reconstruction class.
Definition: reconstruction.h:187
pcl::MeshConstruction::MeshConstruction
MeshConstruction()
Constructor.
Definition: reconstruction.h:200
pcl::MeshConstruction::performReconstruction
virtual void performReconstruction(pcl::PolygonMesh &output)=0
Abstract surface reconstruction method.
pcl::MeshConstruction::reconstruct
void reconstruct(pcl::PolygonMesh &output) override
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>
Definition: reconstruction.hpp:132
pcl::MeshConstruction::performReconstruction
virtual void performReconstruction(std::vector< pcl::Vertices > &polygons)=0
Abstract surface reconstruction method.
pcl::MeshConstruction::~MeshConstruction
~MeshConstruction()
Destructor.
Definition: reconstruction.h:203
pcl::MeshConstruction::check_tree_
bool check_tree_
A flag specifying whether or not the derived reconstruction algorithm needs the search object tree.
Definition: reconstruction.h:228
pcl::PCLBase
PCL base class.
Definition: pcl_base.h:70
pcl::PCLSurfaceBase
Pure abstract class.
Definition: reconstruction.h:60
pcl::PCLSurfaceBase::ConstPtr
shared_ptr< const PCLSurfaceBase< PointInT > > ConstPtr
Definition: reconstruction.h:63
pcl::PCLSurfaceBase::KdTreePtr
typename KdTree::Ptr KdTreePtr
Definition: reconstruction.h:66
pcl::PCLSurfaceBase::getSearchMethod
KdTreePtr getSearchMethod()
Get a pointer to the search method used.
Definition: reconstruction.h:85
pcl::PCLSurfaceBase::tree_
KdTreePtr tree_
A pointer to the spatial search object.
Definition: reconstruction.h:96
pcl::PCLSurfaceBase::getClassName
virtual std::string getClassName() const
Abstract class get name method.
Definition: reconstruction.h:100
pcl::PCLSurfaceBase::Ptr
shared_ptr< PCLSurfaceBase< PointInT > > Ptr
Definition: reconstruction.h:62
pcl::PCLSurfaceBase::PCLSurfaceBase
PCLSurfaceBase()
Empty constructor.
Definition: reconstruction.h:69
pcl::PCLSurfaceBase::~PCLSurfaceBase
~PCLSurfaceBase()
Empty destructor.
Definition: reconstruction.h:72
pcl::PCLSurfaceBase::reconstruct
virtual void reconstruct(pcl::PolygonMesh &output)=0
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>
pcl::PCLSurfaceBase::setSearchMethod
void setSearchMethod(const KdTreePtr &tree)
Provide an optional pointer to a search object.
Definition: reconstruction.h:78
pcl::PointCloud< PointInT >
pcl::SurfaceReconstruction
SurfaceReconstruction represents a base surface reconstruction class.
Definition: reconstruction.h:118
pcl::SurfaceReconstruction::performReconstruction
virtual void performReconstruction(pcl::PolygonMesh &output)=0
Abstract surface reconstruction method.
pcl::SurfaceReconstruction::check_tree_
bool check_tree_
A flag specifying whether or not the derived reconstruction algorithm needs the search object tree.
Definition: reconstruction.h:156
pcl::SurfaceReconstruction::reconstruct
void reconstruct(pcl::PolygonMesh &output) override
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>
Definition: reconstruction.hpp:52
pcl::SurfaceReconstruction::~SurfaceReconstruction
~SurfaceReconstruction()
Destructor.
Definition: reconstruction.h:134
pcl::SurfaceReconstruction::SurfaceReconstruction
SurfaceReconstruction()
Constructor.
Definition: reconstruction.h:131
pcl::SurfaceReconstruction::performReconstruction
virtual void performReconstruction(pcl::PointCloud< PointInT > &points, std::vector< pcl::Vertices > &polygons)=0
Abstract surface reconstruction method.
pcl::search::Search< PointInT >
pcl::search::Search< PointInT >::Ptr
shared_ptr< pcl::search::Search< PointInT > > Ptr
Definition: search.h:81
pcl
Definition: convolution.h:46
pcl::PolygonMesh
Definition: PolygonMesh.h:15