首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CGAL不计算完全delaunay三角剖分

CGAL不计算完全delaunay三角剖分
EN

Stack Overflow用户
提问于 2019-04-24 09:32:31
回答 1查看 68关注 0票数 0

目前,我在使用CGAL库的Delaunay三角剖分时遇到了错误。我计算三角剖分如下

代码语言:javascript
复制
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point;
typedef CGAL::Delaunay_triangulation_2<Kernel> DelaunayTriangulation;

auto triangulation = DelaunayTriangulation();
triangulation.insert(points.begin(),points.end());

其中pointsPoint的一个给定向量,我在几个实例上运行代码,并且大多数情况下三角剖分是正确计算的。然而,有时(我不能在某一情况下再现)三角剖分只给我一小部分期望的面孔。我实现了以下帮助函数

代码语言:javascript
复制
auto face_count = [](DelaunayTriangulation &triangulation)
{
    std::size_t face_count = 0;
    for (auto it = triangulation.finite_faces_begin(); it < triangulation.finite_faces_end(); it++) {
        face_count ++;
    }

    return face_count;
};

auto is_correct = [&convex_hull_size, &face_count, &points](DelaunayTriangulation &triangulation)
{
    return face_count(triangulation) != 2*points.size() - convex_hull_size - 2;
};

以计算计算三角剖分的面数。在某些情况下,可以在相同的点上重新计算三角剖分,从而产生正确的三角形数量。然而,在其他情况下,我总是得到零三角形,这真的很烦人。

我的问题是,在使用CGAL时,是否有人经历过类似的错误,并且知道如何调试它。由于实例读取过程,提供一个最小的工作示例是很困难的。

编辑:

为了清晰起见:下面的代码

代码语言:javascript
复制
do
{
    triangulation = DelaunayTriangulation();
    triangulation.insert(points.begin(),points.end());
    std::cout << "Calculated triangulation with " << face_count(triangulation) << " faces the correct amount is " << 2*points.size() - convex_hull_size - 2 << std::endl;
} while(is_correct(triangulation));

产生以下输出:

代码语言:javascript
复制
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 60 faces the correct amount is 60

在某些情况下(但并非总是如此)。对于其他实例,我反复获得0 faces,while循环不终止。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-24 12:42:26

for (auto it = triangulation.finite_faces_begin(); it < triangulation.finite_faces_end(); it++)

应代之以

for (auto it = triangulation.finite_faces_begin(); it !=triangulation.finite_faces_end(); it++)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55826846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档