簡體   English   中英

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

其中pointsPoint的給定向量。 我在多個實例上運行代碼,並且大多數時候都正確計算了三角剖分。 但是有時(在某些情況下我無法重現)三角剖分僅給了我一些預期的面孔。 我實現了以下助手功能

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM