使用 cgal 创建参数化 3D 图元

Create parameterized 3D primitives with cgal

我正在使用 cgal 评估科学数据(多面体表面、质量分数、空隙率等)。

我预先进行布尔运算以切出我的测量体积(我想要平均数据的子体积)。在这种特殊情况下,它是一个圆柱体。到目前为止,我将从 STL 文件中读取一个通用圆柱体并将其转换为所需的大小和位置。这不是很优雅。例如,无法调整表面三角剖分的分辨率。

更好(更通用的方法)是在运行时生成我的探测体积。 cgal 是否有创建 3D 图元的模块?我在文档中找不到类似的东西。

我对 cgal 很陌生,对这些文档有点困惑。所以我很可能忽略了一些东西。

如果有人能给我提示如何开始解决这个问题,那就太好了!

提前致谢!

我的解决方案是对于所有在此处尝试类似方法的人:

#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/convex_hull_3.h>

Nef_polyhedron_3 create_probe_cylinder(unsigned int argNum_segments, double argRadius, double argZmin, double argZmax)
{

    std::vector<Point_3> probecylinder_points;
    double x, y;
    for (unsigned int point_index = 0; point_index < argNum_segments; point_index++)
    {
        x = argRadius*cos(2*M_PI*point_index/argNum_segments);
        y = argRadius*sin(2*M_PI*point_index/argNum_segments);;

        Point_3 point_bot(x,y, argZmin);
        Point_3 point_top(x,y, argZmax);

        probecylinder_points.push_back(point_bot);
        probecylinder_points.push_back(point_top);
    }

    std::cout << "creating convex hull.." << std::endl;

    Polyhedron_3 poly_cylinder;
    CGAL::convex_hull_3(probecylinder_points.begin(), probecylinder_points.end(), poly_cylinder);

    std::cout << "converting to nef poly.." << std::endl;
    Nef_polyhedron_3 nef_cylinder(poly_cylinder);

    return nef_cylinder;
}

代码摘要:

1) 创建点列表(底部/顶部边缘)。 argNum_segments设置柱面分辨率(段数)

2) 从点列表创建一个凸包

3) 将多面体转换为 nef 表示(布尔运算需要)

可能有更好的解决方案。如果有人知道如何以更优雅的方式执行此任务,请告诉我。