C++ 代码示例:遍历并显示 std::vector<pcl::PointXYZ> 的值
#include
int main() { // 创建一个 std::vectorpcl::PointXYZ 对象 std::vectorpcl::PointXYZ fon;
// 向 vector 中添加一些点
fon.push_back(pcl::PointXYZ(1.0, 2.0, 3.0));
fon.push_back(pcl::PointXYZ(4.0, 5.0, 6.0));
fon.push_back(pcl::PointXYZ(7.0, 8.0, 9.0));
// 使用迭代器遍历 vector 中的所有点
for (std::vector<pcl::PointXYZ>::iterator it = fon.begin(); it != fon.end(); ++it)
{
// 输出当前点的坐标值
std::cout << 'Point: (' << it->x << ', ' << it->y << ', ' << it->z << ')' << std::endl;
}
return 0;
}
在这个示例中,我们使用了 PCL(点云库)中的 pcl::PointXYZ 类型来表示点的坐标。我们创建了一个 std::vectorpcl::PointXYZ 对象,并使用 push_back() 函数向其中添加了三个点。然后,我们使用一个迭代器来遍历 vector 中的所有点,并输出它们的坐标值。
AI 优化版
原文地址:https://www.cveoy.top/t/topic/ofOD 著作权归作者所有。请勿转载和采集!