如何访问 PCLPointCloud2 类型的点

how to access a point in the type of PCLPointCloud2

通过以下代码从 STL 文件 'sphere.stl' 获取点云是否正确?

pcl::PolygonMesh mesh;
pcl::io::loadPolygonFileSTL("sphere.stl", mesh);
pcl::PCLPointCloud2::Ptr ThisCloud = boost::make_shared<pcl::PCLPointCloud2>(mesh.ThisCloud);

那么,如何访问'ThisCloud'的各个点呢?

我想我已将 pcl::PCLPointCloud2 转换为 pcl::PointCloud<PointXYZ>:

...
// conversion
pcl::PointCloud<pcl::PointXYZ>::Ptr vertices( new pcl::PointCloud<pcl::PointXYZ> );
pcl::fromPCLPointCloud2( mesh.cloud, *vertices ); 

// access each vertex 
for( int idx = 0; idx < vertices->size(); idx++ )
{
   pcl::PointXYZ v = vertices->points[ idx ];

   float x = v._PointXYZ::data[ 0 ];
   float y = v._PointXYZ::data[ 1 ];
   float z = v._PointXYZ::data[ 2 ];
}