使用CGAL构建三角网,实现三角剖分,用于CPU下快速正射校正
环境说明:
windows7;
CGAL4.13-Setup.exe 官网下载;
boost_1_67_0-msvc-12.0-64.exe 官网下载;
cmake-3.14.0-rc2-win64-x64.msi 官网下载;
VS2014需要更新到5,vs2013.5。
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Constrained_Delaunay_triangulation_2<K> CDT;
typedef CDT::Point Point;
typedef CDT::Vertex_handle Vertex_handle;
int main( )
{
std::ifstream in("data/triangulation_prog1.cin");//实验数据
std::istream_iterator<Point> begin(in);
std::istream_iterator<Point> end;
CDT T;
T.insert(begin, end);
int count = 1;
CDT::Finite_faces_iterator f_iter;
for (f_iter=T.finite_faces_begin(); f_iter!=T.finite_faces_end(); f_iter++)
{
std::cout<<"Delaunay_triangulation index : " << count++ << std::endl;
for (int i=0; i<3; i++)//输出所有三角网,3点位置
{
Point p = f_iter->vertex(i)->point();
std::cout<<"("<<p.x()<<","<<p.y()<<")"<< std::endl;
}
}
return 0;
}
可以使用约束来限制非有效区域网格。