CGAL 不计算完整的 delaunay 三角剖分

CGAL is not computing a complete delaunay triangulation

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

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());

其中 points 是给定的 Point 向量。我 运行 多个实例的代码,大多数时候三角剖分计算正确。但是有时(我无法在某些情况下重现它)三角测量只给了我预期面孔的一小部分。我实现了以下辅助函数

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 时遇到过类似的错误,并且知道我该如何调试它。由于实例阅读过程,很难提供最小的工作示例。

编辑:

为清楚起见:以下代码

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));

产生以下输出:

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 个面并且 while 循环没有终止。

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++)