【问题标题】:CGAL triangulation failsCGAL 三角剖分失败
【发布时间】:2014-10-21 21:03:13
【问题描述】:

我开始使用 CGAL 使用以下代码对一组点进行三角测量

#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
typedef CGAL::Triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
typedef CGAL::Delaunay_triangulation_2<K,Tds> Triangulation;

typedef Triangulation::Point Point;
typedef Triangulation::Triangulation_data_structure tds;


using namespace std;


void main()
{
    Triangulation t;
    t.insert(Point(0,0));
    t.insert(Point(0,20));
    t.insert(Point(30,15));
    t.insert(Point(30,-15));

    Triangulation::Finite_faces_iterator fib = t.finite_faces_begin(), it;
    Triangulation::Finite_faces_iterator fie = t.finite_faces_end();
    Triangulation::Triangle tri;
    std::cout << "Triangular faces"<<endl;
    for (it=fib; it!=fie; ++it)
    {
        tri = t.triangle(it);
        std::cout<<tri[0]<<" "<<tri[1]<<" "<<tri[2]<<" "<<endl;
    }   
    char c;
    std::cin>>c;
}

这会将面打印为 0,20 0,0 30,15 和 0,0 30,-15 30,15。我对这个输出不满意,因为第一个三角形完全在第二个三角形内。据我了解三角测量它应该返回 3 个三角形,而不仅仅是 2 个覆盖我的 4 个输入点的复杂外壳,并且不应该有重叠的三角形。有人可以解释我做错了什么吗?

我的最终目标是在最小角度约束下对凸多边形进行三角剖分(并通过在集合中添加额外的点)。任何 CGAL 代码示例都将不胜感激。

谢谢,

【问题讨论】:

    标签: c++ triangulation cgal


    【解决方案1】:

    我认为你不太了解这里的几何或三角测量,所以我画了一些图片。

    这是你的设置:

    这是 Delaunay_Triangulation_2 生成的第一个三角形:

    (0,20), (0,0), (30, 15)

    这是生成的第二个三角形:

    (0,0) (30,-15) (30,15)

    显然,两个三角形都不包含在另一个三角形中。此外,三角形的联合,去除共享边,完美地创建了点的凸包。

    此外,鉴于您总共只有四个点,因此不可能构建一个由 3 个不重叠的三角形组成的三角剖分,因此只创建了 2 个。

    【讨论】:

    • 谢谢,我已经交换了我的 (20,0) 点的坐标,因此过去 2 小时的混乱!
    猜你喜欢
    • 1970-01-01
    • 2020-05-06
    • 1970-01-01
    • 1970-01-01
    • 2015-07-23
    • 2016-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多