43 #include <pcl/PolygonMesh.h>
44 #include <pcl/conversions.h>
56 template <
class HalfEdgeMeshT>
void
59 using HalfEdgeMesh = HalfEdgeMeshT;
60 using VAFC =
typename HalfEdgeMesh::VertexAroundFaceCirculator;
61 using FaceIndex =
typename HalfEdgeMesh::FaceIndex;
66 face_vertex_mesh.
polygons.reserve (half_edge_mesh.sizeFaces ());
67 for (std::size_t i=0; i<half_edge_mesh.sizeFaces (); ++i)
69 VAFC circ = half_edge_mesh.getVertexAroundFaceCirculator (
FaceIndex (i));
70 const VAFC circ_end = circ;
74 polygon.
vertices.push_back (circ.getTargetIndex ().get ());
75 }
while (++circ != circ_end);
76 face_vertex_mesh.
polygons.push_back (polygon);
87 template <
class HalfEdgeMeshT>
int
90 using HalfEdgeMesh = HalfEdgeMeshT;
91 using VertexDataCloud =
typename HalfEdgeMesh::VertexDataCloud;
92 using VertexIndices =
typename HalfEdgeMesh::VertexIndices;
94 static_assert (HalfEdgeMesh::HasVertexData::value,
"Output mesh must have data associated with the vertices!");
96 VertexDataCloud vertices;
99 half_edge_mesh.reserveVertices (vertices.size ());
100 half_edge_mesh.reserveEdges (3 * face_vertex_mesh.
polygons.size ());
101 half_edge_mesh.reserveFaces ( face_vertex_mesh.
polygons.size ());
103 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)
116 for (
const auto &vertex : polygon.vertices)
118 vi.emplace_back (vertex);
121 if (!half_edge_mesh.addFace (vi).isValid ())
127 return (count_not_added);