c++ - 使用 CGAL::Constrained_Delaunay_triangulation_2 三角化多边形

标签 c++ polygon triangulation cgal delaunay

我正在尝试使用 CGAL 的 Constrained Delaunay Triangulation 对 2D 多边形进行三角剖分。但是该程序正在生成此运行时错误:

~ 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

谢谢!

最佳答案

有时您需要标记多边形的内部和外部。 这是一个工作 example .

关于c++ - 使用 CGAL::Constrained_Delaunay_triangulation_2 三角化多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23817142/

相关文章:

c# - 如何检测重叠的多边形?

gis - 我如何获得矩形所有四个角的坐标?

c++ - 如何在 Boost 中对多边形进行三角剖分?

opencv - OpenCV中的相机坐标系是如何定向的?

computational-geometry - 网格到网格的交叉点

c++ - 如何在 Boost.Spirit 语义 Action 中获得函数结果

c++ - 我如何将 vector 中的数字打印到文件中?

c++ - 如何将文件保存到可能的新目录中?

c++ - 如何使用 QSqlQuery 和 SQLite 从新插入的行中获取 ID?

opencv - 包含不需要的点的轮廓近似