bad triangles in triangulation of CGAL

572 views Asked by At

I'm trying to build a triangulation (or mesh) of 2D figure. But it fails for some figures, because bad triangles are produced. These triangles are built by points which lie at the one line. I identify these triangles by the area.

Does anybody know how to fix it?

my code:

#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;
        }
    }
}
0

There are 0 answers