Триангуляция полигона с использованием CGAL::Constrained_Delaunay_triangulation_2

Я пытаюсь триангулировать 2D-многоугольник, используя ограниченную триангуляцию Делоне CGAL. Но программа генерирует эту ошибку времени выполнения:

~ what(): ОШИБКА CGAL: нарушение предусловия! Выражение: vaa != vbb Файл: /usr/include/CGAL/Constrained_triangulation_2.h Строка: 463 Программа неожиданно завершилась.~

Кто-нибудь знает, что это может быть?

Это файл cpp:

void CTriangulation3D::loadFeaturePoints(std::list<Point3DTexturable*> tlist){
//Loads Triangulation from points of tlist (closed polygon with no hole)

std::list<Point3DTexturable*>::iterator it;

Point3DTexturable *q;

for (it = tlist.begin(); it != tlist.end() ; it++){
    q = *it;
    polygon.push_back(CPoint(q->getX(), q->getZ()));
}

if ( polygon.is_empty() ) return;

//Tries to load triangulation and close a polygon using insert_constraint. Runtime error appears on the first call to insert_constraints

CVertex_handle v_prev = T.insert(*CGAL::cpp11::prev(polygon.vertices_end()));
for (Polygon_2::Vertex_iterator vit = polygon.vertices_begin(); vit != polygon.vertices_end(); ++vit){
    CVertex_handle vh = T.insert(*vit);
    T.insert_constraint(vh,v_prev);
    v_prev=vh;
}
}

Это объявления, я пробовал и с неточными конструкциями, и с точными предикатами

#ifndef CTRIANGULATION3D_H
#define CTRIANGULATION3D_H

#include "Point3DTexturable.h"
#include "Triangle.h"

#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>
#include <CGAL/Triangulation_hierarchy_2.h>
#include <CGAL/Polygon_2.h>
#include <iostream>

typedef CGAL::Exact_predicates_exact_constructions_kernel               Ke; 
typedef CGAL::Triangulation_vertex_base_with_info_2<double,Ke>          Vbc;
typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vbc>                Vbhc;
typedef CGAL::Constrained_triangulation_face_base_2<Ke>                 Fb;
typedef CGAL::Triangulation_data_structure_2<Vbhc,Fb>                   TDS;

typedef CGAL::Exact_intersections_tag                                   Itag;
typedef CGAL::Constrained_Delaunay_triangulation_2<Ke, TDS, Itag>       CDT;
typedef CGAL::Triangulation_hierarchy_2<CDT>                            Dhh;

typedef CDT::Point                                                      CPoint;
typedef Dhh::Finite_faces_iterator                      CFinite_faces_iterator;
typedef Dhh::Vertex_handle                                      CVertex_handle;
typedef Dhh::Face_handle                                              CFace_handle;

typedef CGAL::Polygon_2<Ke>                                             Polygon_2;


class CTriangulation3D{

public:

Dhh T;

std::list<double> lheight;

std::list<Triangle> triangles;

Polygon_2 polygon;

CTriangulation3D(std::list<Point3DTexturable*> tlist);

std::list<Triangle*> getTriangleList();

void loadIterationTriangulation();
void loadFeaturePoints(std::list<Point3DTexturable*> tlist);
};



#endif // CTRIANGULATION3D_H

Спасибо!


person user3666771    schedule 22.05.2014    source источник


Ответы (1)


В какой-то момент вам нужно отметить, что находится внутри и снаружи полигона. Вот рабочий пример.

person sloriot    schedule 23.05.2014
comment
на самом деле ошибка генерируется, когда я отмечаю первое ограничение - person user3666771; 26.05.2014
comment
В сообщении говорится, что вы пытаетесь вставить ограничение с одинаковыми конечными точками, то есть вершины одинаковы. - person sloriot; 27.05.2014