0

I have some 2D constrained triangulation. When I add a constraint error occurs. This is my simple example for using it:

#include "stdafx.h"

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Constrained_triangulation_plus_2.h>
#include <vector>
#include <fstream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_2<K>                     Vb;
typedef CGAL::Constrained_triangulation_face_base_2<K>           Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb>              TDS;
typedef CGAL::Exact_predicates_tag                               Itag;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, TDS, Itag> CDT;
typedef CGAL::Constrained_triangulation_plus_2<CDT> CDTPlus;
typedef CDT::Constraint Constraint; 

typedef std::vector<Constraint> Constraints;

void load_data(const char* filename, Constraints &c)
{   
    std::fstream stream(filename, std::ios::in | std::ios::binary);     
    stream.seekp(0, std::fstream::end);
    std::streamoff size = stream.tellp() / sizeof(Constraint);
    stream.seekp(0, std::fstream::beg);
    c.resize((size_t)size); 
    stream.read(reinterpret_cast<char *>(&c.front()), sizeof(Constraint) * size);
}

int _tmain(int argc, _TCHAR* argv[])
{   
    Constraints c;
    load_data("e:\\data.bin", c);

    CDTPlus cdt;
    // when i == 53376 - error      
    for (size_t i = 0; i < c.size(); ++i)       
        cdt.insert_constraint(c[i].first, c[i].second);         
    return 0;
}

That is my data.bin file data.bin That is my project link

devcrio
  • 1
  • 1

1 Answers1

0

The template class CGAL::Constrained_Delaunay_triangulation_2 has three template parameters. The default argument for the third one, ITag, is CGAL::No_intersection_tag. That means that the intersections of constraints is not handled.

Probably your input constraints do intersect.

lrineau
  • 6,036
  • 3
  • 34
  • 47