43 #include <pcl/conversions.h>
44 #include <pcl/PolygonMesh.h>
54 template <
class HalfEdgeMeshT>
59 using HalfEdgeMesh = HalfEdgeMeshT;
60 using VAFC =
typename HalfEdgeMesh::VertexAroundFaceCirculator;
66 face_vertex_mesh.
polygons.reserve(half_edge_mesh.sizeFaces());
67 for (std::size_t i = 0; i < half_edge_mesh.sizeFaces(); ++i) {
68 VAFC circ = half_edge_mesh.getVertexAroundFaceCirculator(
FaceIndex(i));
69 const VAFC circ_end = circ;
72 polygon.
vertices.push_back(circ.getTargetIndex().get());
73 }
while (++circ != circ_end);
74 face_vertex_mesh.
polygons.push_back(polygon);
86 template <
class HalfEdgeMeshT>
90 using HalfEdgeMesh = HalfEdgeMeshT;
91 using VertexDataCloud =
typename HalfEdgeMesh::VertexDataCloud;
92 using VertexIndices =
typename HalfEdgeMesh::VertexIndices;
94 static_assert(HalfEdgeMesh::HasVertexData::value,
95 "Output mesh must have data associated with the vertices!");
97 VertexDataCloud vertices;
100 half_edge_mesh.reserveVertices(vertices.size());
101 half_edge_mesh.reserveEdges(3 * face_vertex_mesh.
polygons.size());
102 half_edge_mesh.reserveFaces(face_vertex_mesh.
polygons.size());
104 for (
const auto& vertex : vertices) {
105 half_edge_mesh.addVertex(vertex);
108 assert(half_edge_mesh.sizeVertices() == vertices.size());
110 int count_not_added = 0;
113 for (
const auto& polygon : face_vertex_mesh.
polygons) {
115 for (
const auto& vertex : polygon.vertices) {
116 vi.emplace_back(vertex);
119 if (!half_edge_mesh.addFace(vi).isValid()) {
124 return (count_not_added);
void toFaceVertexMesh(const HalfEdgeMeshT &half_edge_mesh, pcl::PolygonMesh &face_vertex_mesh)
Convert a half-edge mesh to a face-vertex mesh.
int toHalfEdgeMesh(const pcl::PolygonMesh &face_vertex_mesh, HalfEdgeMeshT &half_edge_mesh)
Convert a face-vertex mesh to a half-edge mesh.
pcl::detail::MeshIndex< struct FaceIndexTag > FaceIndex
Index used to access elements in the half-edge mesh.
void fromPCLPointCloud2(const pcl::PCLPointCloud2 &msg, pcl::PointCloud< PointT > &cloud, const MsgFieldMap &field_map, const std::uint8_t *msg_data)
Convert a PCLPointCloud2 binary data blob into a pcl::PointCloud<T> object using a field_map.
void toPCLPointCloud2(const pcl::PointCloud< PointT > &cloud, pcl::PCLPointCloud2 &msg, bool padding)
Convert a pcl::PointCloud<T> object to a PCLPointCloud2 binary data blob.
std::vector< ::pcl::Vertices > polygons
::pcl::PCLPointCloud2 cloud
Describes a set of vertices in a polygon mesh, by basically storing an array of indices.