CGAL 点云循环输出教程:使用迭代器遍历点云
CGAL 点云循环输出教程:使用迭代器遍历点云
在 CGAL 中,点云通常使用 Point_3 类表示。要循环输出点云内容,可以使用 CGAL 的迭代器遍历点云中的所有点,并将其打印出来。以下是一个示例代码:
#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/point_generators_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point_3;
int main()
{
// 生成一个点云
std::vector<Point_3> points;
CGAL::Random_points_in_cube_3<Point_3> generator(1.0);
for (int i = 0; i < 10; i++)
{
points.push_back(*generator++);
}
// 循环输出点云
for (std::vector<Point_3>::iterator it = points.begin(); it != points.end(); it++)
{
std::cout << *it << std::endl;
}
return 0;
}
在上面的代码中,我们首先使用 CGAL 的 Random_points_in_cube_3 生成了一个包含 10 个随机点的点云。然后,我们使用一个迭代器循环遍历点云中的所有点,并将它们打印出来。请注意,我们使用了 CGAL 的 Point_3 类的输出运算符 << 来打印每个点的坐标。
原文地址: https://www.cveoy.top/t/topic/jTTg 著作权归作者所有。请勿转载和采集!