|
楼主 |
发表于 2024-11-1 09:28:08
|
显示全部楼层
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/poisson_surface_reconstruction.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/property_map.h>
#include <vector>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef std::pair<Point, Vector> PointWithNormal;
typedef std::vector<PointWithNormal> PointList;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
Polyhedron reconstructSurface(const pcl::PointCloud<PointType>::Ptr& cloud) {
PointList points;
for (const auto& pt : cloud->points) {
points.emplace_back(Point(pt.x, pt.y, pt.z), Vector(0, 0, 1)); // 简化处理,假设法线为 (0, 0, 1)
}
// 估计点云平均间距,用于 Poisson Surface Reconstruction
double spacing = CGAL::compute_average_spacing<CGAL::Sequential_tag>(points, 6);
// 重建曲面
Polyhedron output_mesh;
CGAL::poisson_surface_reconstruction_delaunay(points.begin(), points.end(),
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type()),
output_mesh, spacing);
return output_mesh;
}
|
|