41 #ifndef PCL_GEOMETRY_MESH_CONVERSION_H
42 #define PCL_GEOMETRY_MESH_CONVERSION_H
44 #include <pcl/PolygonMesh.h>
45 #include <pcl/conversions.h>
57 template <
class HalfEdgeMeshT>
void
60 typedef HalfEdgeMeshT HalfEdgeMesh;
61 typedef typename HalfEdgeMesh::VertexAroundFaceCirculator VAFC;
62 typedef typename HalfEdgeMesh::FaceIndex
FaceIndex;
67 face_vertex_mesh.
polygons.reserve (half_edge_mesh.sizeFaces ());
68 for (
size_t i=0; i<half_edge_mesh.sizeFaces (); ++i)
70 VAFC circ = half_edge_mesh.getVertexAroundFaceCirculator (FaceIndex (i));
71 const VAFC circ_end = circ;
75 polygon.
vertices.push_back (circ.getTargetIndex ().get ());
76 }
while (++circ != circ_end);
77 face_vertex_mesh.
polygons.push_back (polygon);
88 template <
class HalfEdgeMeshT>
int
91 typedef HalfEdgeMeshT HalfEdgeMesh;
92 typedef typename HalfEdgeMesh::VertexDataCloud VertexDataCloud;
93 typedef typename HalfEdgeMesh::VertexIndex
VertexIndex;
94 typedef typename HalfEdgeMesh::VertexIndices VertexIndices;
96 BOOST_STATIC_ASSERT (HalfEdgeMesh::HasVertexData::value);
98 VertexDataCloud vertices;
101 half_edge_mesh.reserveVertices (vertices.size ());
102 half_edge_mesh.reserveEdges (3 * face_vertex_mesh.
polygons.size ());
103 half_edge_mesh.reserveFaces ( face_vertex_mesh.
polygons.size ());
105 for (
typename VertexDataCloud::const_iterator it=vertices.begin (); it!=vertices.end (); ++it)
107 half_edge_mesh.addVertex (*it);
110 assert (half_edge_mesh.sizeVertices () == vertices.size ());
112 int count_not_added = 0;
115 for (
size_t i=0; i<face_vertex_mesh.
polygons.size (); ++i)
118 for (
size_t j=0; j<face_vertex_mesh.
polygons [i].vertices.size (); ++j)
120 vi.push_back (VertexIndex (face_vertex_mesh.
polygons [i].vertices [j]));
123 if (!half_edge_mesh.addFace (vi).isValid ())
129 return (count_not_added);
134 #endif // PCL_GEOMETRY_MESH_CONVERSION_H
std::vector< ::pcl::Vertices > polygons
int toHalfEdgeMesh(const pcl::PolygonMesh &face_vertex_mesh, HalfEdgeMeshT &half_edge_mesh)
Convert a face-vertex mesh to a half-edge mesh.
std::vector< uint32_t > vertices
void toPCLPointCloud2(const pcl::PointCloud< PointT > &cloud, pcl::PCLPointCloud2 &msg)
Convert a pcl::PointCloud<T> object to a PCLPointCloud2 binary data blob.
Index used to access elements in the half-edge mesh.
Describes a set of vertices in a polygon mesh, by basically storing an array of indices.
Index used to access elements in the half-edge mesh.
void fromPCLPointCloud2(const pcl::PCLPointCloud2 &msg, pcl::PointCloud< PointT > &cloud, const MsgFieldMap &field_map)
Convert a PCLPointCloud2 binary data blob into a pcl::PointCloud<T> object using a field_map...
void toFaceVertexMesh(const HalfEdgeMeshT &half_edge_mesh, pcl::PolygonMesh &face_vertex_mesh)
Convert a half-edge mesh to a face-vertex mesh.
::pcl::PCLPointCloud2 cloud