如果您能协助我处理 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.
.....
}
那是在我的排序函数之后(抱歉不能分享。但是写起来没那么复杂):
更新 我找到了 this source ,也许会有帮助。
关于c++ - CGAL Alpha_shape_2 提取边界顶点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29801402/