Loading...
Searching...
No Matches
PolygonMesh.h
#pragma once
#include <algorithm>
#include <vector>
#include <ostream>
// Include the correct Header path here
#include <pcl/PCLHeader.h>
#include <pcl/PCLPointCloud2.h>
#include <pcl/Vertices.h>
namespace pcl
{
struct PolygonMesh
{
PolygonMesh () = default;
::pcl::PCLHeader header;
::pcl::PCLPointCloud2 cloud;
std::vector< ::pcl::Vertices> polygons;
/** \brief Inplace concatenate two pcl::PolygonMesh
* \param[in,out] mesh1 the first input and output mesh
* \param[in] mesh2 the second input mesh
* \return true if successful, false otherwise (unexpected error)
*/
static bool
concatenate (pcl::PolygonMesh &mesh1, const pcl::PolygonMesh &mesh2)
{
const auto point_offset = mesh1.cloud.width * mesh1.cloud.height;
bool success = pcl::PCLPointCloud2::concatenate(mesh1.cloud, mesh2.cloud);
if (!success) {
return false;
}
// Make the resultant polygon mesh take the newest stamp
mesh1.header.stamp = std::max(mesh1.header.stamp, mesh2.header.stamp);
std::transform(mesh2.polygons.begin (),
mesh2.polygons.end (),
std::back_inserter (mesh1.polygons),
[point_offset](auto polygon)
{
std::transform(polygon.vertices.begin (),
polygon.vertices.end (),
polygon.vertices.begin (),
[point_offset](auto& point_idx)
{
return point_idx + point_offset;
});
return polygon;
});
return true;
}
/** \brief Concatenate two pcl::PolygonMesh
* \param[in] mesh1 the first input mesh
* \param[in] mesh2 the second input mesh
* \param[out] mesh_out the resultant output mesh
* \return true if successful, false otherwise (unexpected error)
*/
static bool
concatenate (const PolygonMesh &mesh1,
const PolygonMesh &mesh2,
PolygonMesh &mesh_out)
{
mesh_out = mesh1;
return concatenate(mesh_out, mesh2);
}
/** \brief Add another polygon mesh to the current mesh.
* \param[in] rhs the mesh to add to the current mesh
* \return the new mesh as a concatenation of the current mesh and the new given mesh
*/
inline PolygonMesh&
operator += (const PolygonMesh& rhs)
{
concatenate((*this), rhs);
return (*this);
}
/** \brief Add a polygon mesh to another mesh.
* \param[in] rhs the mesh to add to the current mesh
* \return the new mesh as a concatenation of the current mesh and the new given mesh
*/
inline const PolygonMesh
operator + (const PolygonMesh& rhs)
{
return (PolygonMesh (*this) += rhs);
}
public:
using Ptr = shared_ptr< ::pcl::PolygonMesh>;
using ConstPtr = shared_ptr<const ::pcl::PolygonMesh>;
}; // struct PolygonMesh
using PolygonMeshPtr = PolygonMesh::Ptr;
using PolygonMeshConstPtr = PolygonMesh::ConstPtr;
inline std::ostream& operator<<(std::ostream& s, const ::pcl::PolygonMesh &v)
{
s << "header: " << std::endl;
s << v.header;
s << "cloud: " << std::endl;
s << v.cloud;
s << "polygons[]" << std::endl;
for (std::size_t i = 0; i < v.polygons.size (); ++i)
{
s << " polygons[" << i << "]: " << std::endl;
s << v.polygons[i];
}
return (s);
}
} // namespace pcl
pcl::concatenate
bool concatenate(const pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2, pcl::PointCloud< PointT > &cloud_out)
Concatenate two pcl::PointCloud<PointT>.
Definition io.h:281
pcl
Definition convolution.h:46
pcl::PolygonMeshPtr
PolygonMesh::Ptr PolygonMeshPtr
Definition PolygonMesh.h:100
pcl::operator<<
std::ostream & operator<<(std::ostream &os, const BivariatePolynomialT< real > &p)
Definition bivariate_polynomial.hpp:238
pcl::PolygonMeshConstPtr
PolygonMesh::ConstPtr PolygonMeshConstPtr
Definition PolygonMesh.h:101
pcl::PCLHeader
Definition PCLHeader.h:11
pcl::PCLHeader::stamp
std::uint64_t stamp
A timestamp associated with the time when the data was acquired.
Definition PCLHeader.h:18
pcl::PCLPointCloud2
Definition PCLPointCloud2.h:17
pcl::PCLPointCloud2::width
uindex_t width
Definition PCLPointCloud2.h:21
pcl::PCLPointCloud2::height
uindex_t height
Definition PCLPointCloud2.h:20
pcl::PCLPointCloud2::concatenate
static bool concatenate(pcl::PCLPointCloud2 &cloud1, const pcl::PCLPointCloud2 &cloud2)
Inplace concatenate two pcl::PCLPointCloud2.
pcl::PolygonMesh
Definition PolygonMesh.h:15
pcl::PolygonMesh::concatenate
static bool concatenate(pcl::PolygonMesh &mesh1, const pcl::PolygonMesh &mesh2)
Inplace concatenate two pcl::PolygonMesh.
Definition PolygonMesh.h:30
pcl::PolygonMesh::header
::pcl::PCLHeader header
Definition PolygonMesh.h:18
pcl::PolygonMesh::Ptr
shared_ptr< ::pcl::PolygonMesh > Ptr
Definition PolygonMesh.h:96
pcl::PolygonMesh::PolygonMesh
PolygonMesh()=default
pcl::PolygonMesh::polygons
std::vector< ::pcl::Vertices > polygons
Definition PolygonMesh.h:22
pcl::PolygonMesh::concatenate
static bool concatenate(const PolygonMesh &mesh1, const PolygonMesh &mesh2, PolygonMesh &mesh_out)
Concatenate two pcl::PolygonMesh.
Definition PolygonMesh.h:66
pcl::PolygonMesh::cloud
::pcl::PCLPointCloud2 cloud
Definition PolygonMesh.h:20
pcl::PolygonMesh::ConstPtr
shared_ptr< const ::pcl::PolygonMesh > ConstPtr
Definition PolygonMesh.h:97