CGAL 的数字居然是一个类,有专门的函数导出成c++的标准类型。
导出形式为
.exact().convert_to<double>()
比如我计算并集的多边形最后导出外轮廓是这样
typename Polygon_2::Vertex_const_iterator vit;
Polygon_2 P_out = unionR.outer_boundary();
std::vector<Polygon_2> holes_out;
for (vit = P_out.vertices_begin(); vit != P_out.vertices_end(); ++vit)
{
double x = vit->x().exact().convert_to<double>();
double y = vit->y().exact().convert_to<double>();
}
计算多边形并集的程序在 CGAL源码包按安装与初步测试。
另一种方式,这种是他自己封装的
typename Polygon_2::Vertex_const_iterator vit;
Polygon_2 P_out = unionR.outer_boundary();
std::vector<Polygon_2> holes_out;
for (vit = P_out.vertices_begin(); vit != P_out.vertices_end(); ++vit)
{
double x = CGAL::to_double(vit->x());
double y = CGAL::to_double(vit->y());
}