【问题标题】:CGAL Alpha_shape_2 extract boundary verticesCGAL Alpha_shape_2 提取边界顶点
【发布时间】:2015-04-22 14:54:06
【问题描述】:

如果您能在 alpha_shape_2 方面帮助我,不胜感激。我是 CGAL 的新手。

我正在尝试从 2D 数据中提取边界。

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

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

非常感谢一些例子。

【问题讨论】:

  • 边界顶点叫什么?

标签: c++ cgal


【解决方案1】:

这里是如何获得积分,但它们没有排序:

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.

    .....

}

你会得到这样的东西:

这是在我的排序功能之后(抱歉不能分享。但写起来没那么复杂):

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多