CGAL三角剖分中的坏三角形

CGAL三角剖分中的坏三角形,cgal,delaunay,Cgal,Delaunay,我正在尝试建立一个二维图形的三角剖分或网格。但是对于某些图形它失败了,因为生成了不好的三角形。这些三角形由位于一条直线上的点构成。我根据面积来识别这些三角形 有人知道怎么修吗 我的代码: #include <iostream> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Constrained_Delaunay_triangulation_2.h>

我正在尝试建立一个二维图形的三角剖分或网格。但是对于某些图形它失败了,因为生成了不好的三角形。这些三角形由位于一条直线上的点构成。我根据面积来识别这些三角形

有人知道怎么修吗

我的代码:

#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_conformer_2.h>
#include <CGAL/Delaunay_mesher_2.h>
#include <CGAL/Delaunay_mesh_face_base_2.h>
#include <CGAL/Delaunay_mesh_size_criteria_2.h>
#include <CGAL/Constrained_triangulation_plus_2.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
typedef CGAL::Delaunay_mesh_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, Tds, CGAL::Exact_predicates_tag> CDT;

typedef CGAL::Constrained_triangulation_plus_2<CDT> CDT_plus;
typedef CGAL::Delaunay_mesh_size_criteria_2<CDT_plus> Criteria;
typedef CGAL::Delaunay_mesher_2<CDT_plus, Criteria> Mesher;
typedef CDT::Vertex_handle Vertex_handle;
typedef CDT::Point Point;

void some_function()
{
    CDT_plus cdt;

    Point hp[6];

    hp[0] = Point(0.500000091410, 0.486455788882);
    hp[1] = Point(-0.334032111870, 0.486455788837);
    hp[2] = Point(-0.500000091424, 0.120965046601);
    hp[3] = Point(-0.500000091430, 0.008971885303);
    hp[4] = Point(0.482938375290, -0.486030074474);
    hp[5] = Point(0.500000091434, -0.448457168454);


    for (int i = 0; i < 6; ++i)
    {
        cdt.insert_constraint(hp[i], hp[i + 1 < 6 ? i + 1 : 0]);
    }

    Mesher mesher(cdt, Criteria(0.125, 0.3));
    int i = 0;

    mesher.refine_mesh();
    for (CDT::Finite_faces_iterator it = mesher.triangulation().finite_faces_begin(); it != mesher.triangulation().finite_faces_end(); it++)
    {

        CDT::Triangle trr = cdt.triangle(it);
        if (trr.area()< 1e-12)
        {
            cout << "i am very saaad" << endl;
        }
    }
}

点集的三角剖分始终是其凸包的三角剖分。因此,如果你有几乎共线的点,你就不会有几乎退化的三角形。我遇到过这样的情况,并且在我的任务中解决了共线点的问题。但现在它是一个有效的凸包,出现了坏三角形。我用VTK画了这个凸包和这个网格,我看到这个问题不是在共线点上结束的。若我有共线点,程序会在这些点周围的小范围内生成许多三角形。现在我没有这样的点,也没有很多这样的三角形。我在试着理解它是什么?如果你只想要形状很好的三角形,你需要使用一个可以添加更多点的网格器。我使用网格器,他可以添加更多点,但是三角形的构建是错误的。如果你运行它,你会看到,有一个小面积的三角形是由位于一条线上的点构成的。例如,p10、0、p20、0.1和p30、0.2。这些三角形位于您的域之外,是由几乎共线的点生成的三角形,因为边细化无法创建与双坐标真正共线的点。