c++ - CGAL Alpha_shape_2 提取边界顶点

标签 c++ cgal

如果您能协助我处理 alpha_shape_2,我将不胜感激。我是 CGAL 的新手。

我正在尝试从二维数据中提取边界。

Alpha_shape_2 alpha(lp.begin(), lp.end(), FT(1000), Alpha_shape_2::GENERAL);

Alpha_shape_2 调用完美无缺。但是,我对如何只提取边界顶点感到困惑。

非常感谢一些例子。

最佳答案

这里是获取积分的方法,但是积分没有排序:

std::vector<Point> result;

for(Alpha_shape_2::Alpha_shape_vertices_iterator it =  alpha_shape.Alpha_shape_vertices_begin();
    it != alpha_shape.Alpha_shape_vertices_end();
    ++it){

    Alpha_shape_2::Vertex_handle handle = *it;
    Point p = handle->point();
    result.push_back(p);
}

您需要开始阅读 manual on official website了解一些概念。 CGAL 中的简单示例没有那么多解释和功能。您需要更加熟悉 CGAL 的实际结构。

这就是如何按边获取线段。但是段也没有排序,你需要自己做。

for(Alpha_shape_2::Alpha_shape_edges_iterator it =  alpha_shape.Alpha_shape_edges_begin();
    it != alpha_shape.alpha_shape_edges_end();
        ++it){

    CGAL::Kernel::Segment segment = alpha_shape.segment(*it);

    Point p1 = segment.vertex(0);
    Point p2 = segment.vertex(1);
    // so here you will get p1 and p2 of segment, which is part of shape.

    .....

}

你会得到这样的东西: enter image description here

那是在我的排序函数之后(抱歉不能分享。但是写起来没那么复杂): CGAL ALpha Shape 2D

更新 我找到了 this source ,也许会有帮助。

关于c++ - CGAL Alpha_shape_2 提取边界顶点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29801402/

相关文章:

c++ - CGAL 是否与 OSX 上的 Clang 编译器兼容?

c++ - 自动排除如何与带有嵌套小部件的 QRadioButtons 一起使用?

cgal - 标记(或着色)CGAL 对象

c++ - 允许模拟类继承自最终类

c++ - 服务器内存管理

c++ - 使用 CGAL 简化组合映射

python - CGAL 的 python 绑定(bind)发生了什么?

c++ - 如何使用 CGAL 存储折叠的边缘

c++ - 使用一些库分发程序(源文件)

c++ - C++ 中基类指针引用的对象的打印类型?