/// <summary>
/// PCL mesh 转 OpenMesh mesh
/// </summary>
/// <param name="trianglesMesh"></param>
/// <param name="mesh"></param>
void Pcl2OpenMesh(pcl::PolygonMesh trianglesMesh, MyMesh& mesh)
{
std::vector<PolyMesh::VertexHandle> vhandle;
pcl::PointCloud<pcl::PointXYZ>::Ptr pointCloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::fromPCLPointCloud2(trianglesMesh.cloud, *pointCloud);
int ptNum = pointCloud->points.size(); // 节点编号
int meshNum = trianglesMesh.polygons.size();
vhandle.resize(pointCloud->points.size());
for (int i = 0; i < ptNum; i += 1)
vhandle[i] = mesh.add_vertex(MyMesh::Point(pointCloud->points[i].x, pointCloud->points[i].y, pointCloud->points[i].z));
for (int mesh_i = 0; mesh_i < meshNum; ++mesh_i)
{
std::vector<MyMesh::VertexHandle> face_vhandles;
face_vhandles.push_back(vhandle[trianglesMesh.polygons[mesh_i].vertices[0]]);
face_vhandles.push_back(vhandle[trianglesMesh.polygons[mesh_i].vertices[1]]);
face_vhandles.push_back(vhandle[trianglesMesh.polygons[mesh_i].vertices[2]]);
mesh.add_face(face_vhandles);
}
}
PCL\OpenMesh 网格对象互转
最新推荐文章于 2024-02-03 11:33:17 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)