在二维三角测量中添加约束时出错

Error when add constraint in 2D Triangulation

本文关键字:添加 约束 出错 测量 三角 二维      更新时间:2023-10-16

我有一些二维约束三角测量。当我添加约束时发生错误。这是我使用它的简单示例:

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

那是我的数据.bin文件数据.bin那是我的项目链接

模板类CGAL::Constrained_Delaunay_triangulation_2有三个模板参数。第三个参数的默认参数 ITagCGAL::No_intersection_tag 。这意味着不会处理约束的交集。

可能您的输入约束确实相交。