reconstruction.hpp
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2011, 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$
*
*/
#ifndef PCL_SURFACE_RECONSTRUCTION_IMPL_H_
#define PCL_SURFACE_RECONSTRUCTION_IMPL_H_
#include <pcl/search/pcl_search.h>
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT> void
pcl::SurfaceReconstruction<PointInT>::reconstruct (pcl::PolygonMesh &output)
{
// Copy the header
output.header = input_->header;
if (!initCompute ())
{
output.cloud.width = output.cloud.height = 0;
output.cloud.data.clear ();
output.polygons.clear ();
return;
}
// Check if a space search locator was given
if (check_tree_)
{
if (!tree_)
{
if (input_->isOrganized ())
tree_.reset (new pcl::search::OrganizedNeighbor<PointInT> ());
else
tree_.reset (new pcl::search::KdTree<PointInT> (false));
}
// Send the surface dataset to the spatial locator
tree_->setInputCloud (input_, indices_);
}
// Set up the output dataset
pcl::toPCLPointCloud2 (*input_, output.cloud); /// NOTE: passing in boost shared pointer with * as const& should be OK here
output.polygons.clear ();
output.polygons.reserve (2*indices_->size ()); /// NOTE: usually the number of triangles is around twice the number of vertices
// Perform the actual surface reconstruction
performReconstruction (output);
deinitCompute ();
}
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT> void
pcl::SurfaceReconstruction<PointInT>::reconstruct (pcl::PointCloud<PointInT> &points,
std::vector<pcl::Vertices> &polygons)
{
// Copy the header
points.header = input_->header;
if (!initCompute ())
{
points.width = points.height = 0;
points.clear ();
polygons.clear ();
return;
}
// Check if a space search locator was given
if (check_tree_)
{
if (!tree_)
{
if (input_->isOrganized ())
tree_.reset (new pcl::search::OrganizedNeighbor<PointInT> ());
else
tree_.reset (new pcl::search::KdTree<PointInT> (false));
}
// Send the surface dataset to the spatial locator
tree_->setInputCloud (input_, indices_);
}
// Set up the output dataset
polygons.clear ();
polygons.reserve (2 * indices_->size ()); /// NOTE: usually the number of triangles is around twice the number of vertices
// Perform the actual surface reconstruction
performReconstruction (points, polygons);
deinitCompute ();
}
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT> void
pcl::MeshConstruction<PointInT>::reconstruct (pcl::PolygonMesh &output)
{
// Copy the header
output.header = input_->header;
if (!initCompute ())
{
output.cloud.width = output.cloud.height = 1;
output.cloud.data.clear ();
output.polygons.clear ();
return;
}
// Check if a space search locator was given
if (check_tree_)
{
if (!tree_)
{
if (input_->isOrganized ())
tree_.reset (new pcl::search::OrganizedNeighbor<PointInT> ());
else
tree_.reset (new pcl::search::KdTree<PointInT> (false));
}
// Send the surface dataset to the spatial locator
tree_->setInputCloud (input_, indices_);
}
// Set up the output dataset
pcl::toPCLPointCloud2 (*input_, output.cloud); /// NOTE: passing in boost shared pointer with * as const& should be OK here
// output.polygons.clear ();
// output.polygons.reserve (2*indices_->size ()); /// NOTE: usually the number of triangles is around twice the number of vertices
// Perform the actual surface reconstruction
performReconstruction (output);
deinitCompute ();
}
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT> void
pcl::MeshConstruction<PointInT>::reconstruct (std::vector<pcl::Vertices> &polygons)
{
if (!initCompute ())
{
polygons.clear ();
return;
}
// Check if a space search locator was given
if (check_tree_)
{
if (!tree_)
{
if (input_->isOrganized ())
tree_.reset (new pcl::search::OrganizedNeighbor<PointInT> ());
else
tree_.reset (new pcl::search::KdTree<PointInT> (false));
}
// Send the surface dataset to the spatial locator
tree_->setInputCloud (input_, indices_);
}
// Set up the output dataset
//polygons.clear ();
//polygons.reserve (2 * indices_->size ()); /// NOTE: usually the number of triangles is around twice the number of vertices
// Perform the actual surface reconstruction
performReconstruction (polygons);
deinitCompute ();
}
#endif // PCL_SURFACE_RECONSTRUCTION_IMPL_H_
pcl::search::KdTree
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
Definition: kdtree.h:62
pcl::SurfaceReconstruction::reconstruct
virtual void reconstruct(pcl::PolygonMesh &output)
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()> ...
Definition: reconstruction.hpp:46
pcl::PointCloud::height
uint32_t height
The point cloud height (if organized as an image-structure).
Definition: point_cloud.h:415
pcl::PointCloud::width
uint32_t width
The point cloud width (if organized as an image-structure).
Definition: point_cloud.h:413
pcl::PolygonMesh::header
::pcl::PCLHeader header
Definition: PolygonMesh.h:20
pcl::PCLPointCloud2::width
pcl::uint32_t width
Definition: PCLPointCloud2.h:38
pcl::PointCloud::clear
void clear()
Removes all points in a cloud and sets the width and height to 0.
Definition: point_cloud.h:575
pcl::PolygonMesh::polygons
std::vector< ::pcl::Vertices > polygons
Definition: PolygonMesh.h:24
pcl::PointCloud< PointInT >
pcl::PointCloud::header
pcl::PCLHeader header
The point cloud header.
Definition: point_cloud.h:407
pcl::PCLPointCloud2::height
pcl::uint32_t height
Definition: PCLPointCloud2.h:37
pcl::PolygonMesh::cloud
::pcl::PCLPointCloud2 cloud
Definition: PolygonMesh.h:22
pcl::toPCLPointCloud2
void toPCLPointCloud2(const pcl::PointCloud< PointT > &cloud, pcl::PCLPointCloud2 &msg)
Convert a pcl::PointCloud<T> object to a PCLPointCloud2 binary data blob.
Definition: conversions.h:242
pcl::PolygonMesh
Definition: PolygonMesh.h:15
pcl::search::OrganizedNeighbor
OrganizedNeighbor is a class for optimized nearest neigbhor search in organized point clouds...
Definition: organized.h:62
pcl::MeshConstruction::reconstruct
virtual void reconstruct(pcl::PolygonMesh &output)
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()> ...
Definition: reconstruction.hpp:126
pcl::PCLPointCloud2::data
std::vector< pcl::uint8_t > data
Definition: PCLPointCloud2.h:46