Point Cloud Library (PCL)
1.12.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
PolygonMesh.h
1
#pragma once
2
3
#include <algorithm>
4
#include <vector>
5
#include <ostream>
6
7
// Include the correct Header path here
8
#include <pcl/PCLHeader.h>
9
#include <pcl/PCLPointCloud2.h>
10
#include <pcl/Vertices.h>
11
12
namespace
pcl
13
{
14
struct
PolygonMesh
15
{
16
PolygonMesh
()
17
{}
18
19
::pcl::PCLHeader
header
;
20
21
::pcl::PCLPointCloud2
cloud
;
22
23
std::vector< ::pcl::Vertices>
polygons
;
24
25
/** \brief Inplace concatenate two pcl::PolygonMesh
26
* \param[in,out] mesh1 the first input and output mesh
27
* \param[in] mesh2 the second input mesh
28
* \return true if successful, false otherwise (unexpected error)
29
*/
30
static
bool
31
concatenate
(
pcl::PolygonMesh
&mesh1,
const
pcl::PolygonMesh
&mesh2)
32
{
33
const
auto
point_offset = mesh1.
cloud
.
width
* mesh1.
cloud
.
height
;
34
35
bool
success =
pcl::PCLPointCloud2::concatenate
(mesh1.
cloud
, mesh2.
cloud
);
36
if
(success ==
false
) {
37
return
false
;
38
}
39
// Make the resultant polygon mesh take the newest stamp
40
mesh1.
header
.
stamp
= std::max(mesh1.
header
.
stamp
, mesh2.
header
.
stamp
);
41
42
std::transform(mesh2.
polygons
.begin (),
43
mesh2.
polygons
.end (),
44
std::back_inserter (mesh1.
polygons
),
45
[point_offset](
auto
polygon)
46
{
47
std::transform(polygon.vertices.begin (),
48
polygon.vertices.end (),
49
polygon.vertices.begin (),
50
[point_offset](auto& point_idx)
51
{
52
return point_idx + point_offset;
53
});
54
return
polygon;
55
});
56
57
return
true
;
58
}
59
60
/** \brief Concatenate two pcl::PCLPointCloud2
61
* \param[in] mesh1 the first input mesh
62
* \param[in] mesh2 the second input mesh
63
* \param[out] mesh_out the resultant output mesh
64
* \return true if successful, false otherwise (unexpected error)
65
*/
66
static
bool
67
concatenate
(
const
PolygonMesh
&mesh1,
68
const
PolygonMesh
&mesh2,
69
PolygonMesh
&mesh_out)
70
{
71
mesh_out = mesh1;
72
return
concatenate
(mesh_out, mesh2);
73
}
74
75
/** \brief Add another polygon mesh to the current mesh.
76
* \param[in] rhs the mesh to add to the current mesh
77
* \return the new mesh as a concatenation of the current mesh and the new given mesh
78
*/
79
inline
PolygonMesh
&
80
operator += (
const
PolygonMesh
& rhs)
81
{
82
concatenate
((*
this
), rhs);
83
return
(*
this
);
84
}
85
86
/** \brief Add a polygon mesh to another mesh.
87
* \param[in] rhs the mesh to add to the current mesh
88
* \return the new mesh as a concatenation of the current mesh and the new given mesh
89
*/
90
inline
const
PolygonMesh
91
operator + (
const
PolygonMesh
& rhs)
92
{
93
return
(
PolygonMesh
(*
this
) += rhs);
94
}
95
96
public
:
97
using
Ptr
= shared_ptr< ::pcl::PolygonMesh>;
98
using
ConstPtr
= shared_ptr<const ::pcl::PolygonMesh>;
99
};
// struct PolygonMesh
100
101
using
PolygonMeshPtr
=
PolygonMesh::Ptr
;
102
using
PolygonMeshConstPtr
=
PolygonMesh::ConstPtr
;
103
104
inline
std::ostream&
operator<<
(std::ostream& s, const ::pcl::PolygonMesh &v)
105
{
106
s <<
"header: "
<< std::endl;
107
s << v.header;
108
s <<
"cloud: "
<< std::endl;
109
s << v.cloud;
110
s <<
"polygons[]"
<< std::endl;
111
for
(std::size_t i = 0; i < v.polygons.size (); ++i)
112
{
113
s <<
" polygons["
<< i <<
"]: "
<< std::endl;
114
s << v.polygons[i];
115
}
116
return
(s);
117
}
118
119
}
// namespace pcl
pcl
Definition
convolution.h:46
pcl::PolygonMeshPtr
PolygonMesh::Ptr PolygonMeshPtr
Definition
PolygonMesh.h:101
pcl::operator<<
std::ostream & operator<<(std::ostream &os, const BivariatePolynomialT< real > &p)
Definition
bivariate_polynomial.hpp:240
pcl::PolygonMeshConstPtr
PolygonMesh::ConstPtr PolygonMeshConstPtr
Definition
PolygonMesh.h:102
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:31
pcl::PolygonMesh::header
::pcl::PCLHeader header
Definition
PolygonMesh.h:19
pcl::PolygonMesh::Ptr
shared_ptr< ::pcl::PolygonMesh > Ptr
Definition
PolygonMesh.h:97
pcl::PolygonMesh::PolygonMesh
PolygonMesh()
Definition
PolygonMesh.h:16
pcl::PolygonMesh::polygons
std::vector< ::pcl::Vertices > polygons
Definition
PolygonMesh.h:23
pcl::PolygonMesh::concatenate
static bool concatenate(const PolygonMesh &mesh1, const PolygonMesh &mesh2, PolygonMesh &mesh_out)
Concatenate two pcl::PCLPointCloud2.
Definition
PolygonMesh.h:67
pcl::PolygonMesh::cloud
::pcl::PCLPointCloud2 cloud
Definition
PolygonMesh.h:21
pcl::PolygonMesh::ConstPtr
shared_ptr< const ::pcl::PolygonMesh > ConstPtr
Definition
PolygonMesh.h:98