是否有一种计算CGAL中Surface_mesh对象的PCA的方法

Is there a method to compute pca of a Surface_mesh object in CGAL?

本文关键字:Surface mesh 对象 PCA 方法 CGAL 计算 一种 是否      更新时间:2023-10-16

我是CGAL库的新手。我想计算Surface_mesh对象的PCA。

CGAL::Surface_mesh<Kernel::Point_3> mesh;
std::ifstream cactus("cat.off");
cactus >> mesh;

正如我在计算PCA的CGAL文档中提到的那样,此处讨论了一组点或三角形的PCA。

我尝试了鲍泽代码以适合一条线,但是提出了错误:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/linear_least_squares_fitting_3.h>
#include <iostream>
#include <fstream>
#include <sstream>
typedef double                      FT;
typedef CGAL::Simple_cartesian<FT>  K;
typedef K::Line_3                   Line;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Surface_mesh<Kernel::Point_3> SM;
int main(void)
{
    Line line;
    SM mesh;
    std::ifstream cat("cat.off");
    cat >> mesh;
    linear_least_squares_fitting_3(mesh.faces_begin(),mesh.faces_end(),line, CGAL::Dimension_tag<0>());
    return 0;
}

传递给linear_leastrongquares_fitting_3的迭代器的值类型只能是几何内核类型。但是,您可以构造Triangle_3的向量并将此范围传递给该函数,也可以将Boost的转换器与简单的结构结合使用,该结构从Surface_mesh的脸部构造Triangle_3