0

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;
        }
    }
}
  • A triangulation of a point set is always a triangulation of its convex hull. Thus if you have almost collinear points, there is no magic you will have almost degenerate triangles. – sloriot Dec 02 '14 at 09:36
  • There are not collinear points. I've met such cases and I've solved problem of collinear points in my task. But now it's a valid convex hull and bad triangles are appeared. I drew this convex hull and this mesh by VTK and I've seen that problem is not concluded in collinear points. If I have collinear points, programm produce many triangles in small area around these points. Now I don't have such points and I don't have a lot of such triangles. And I'm trying to understand what is it? – Artem Blonsky Dec 02 '14 at 11:55
  • If you want only nicely shaped triangles you need to use a mesher that will add more points. – sloriot Dec 02 '14 at 13:16
  • I use mesher and he add more points, but triangles are built incorrectly. If you run it, you will see, triangles which have a small area are built by points which lie on the one line. For example p1(0, 0), p2(0, 0.1) and p3(0, 0.2). – Artem Blonsky Dec 02 '14 at 14:04
  • These triangles are outside of your domain and are triangle produce by almost collinear points (because the edge refinement cannot create points that are really collinear with double coordinates). – sloriot Dec 02 '14 at 19:17
  • How can I prevent generating of these triangles by cgal? Can it be avoided or do I need to remove it manually? – Artem Blonsky Dec 03 '14 at 13:23
  • Use something like in [this example](http://doc.cgal.org/latest/Triangulation_2/index.html#title29). – sloriot Dec 04 '14 at 09:04

0 Answers0