从 Projection_traits_xy_3 constrained delaunay 获取 mesh_3 'off'

Get a mesh_3 'off' from Projection_traits_xy_3 constrained delaunay

我使用 projection_traits_xy_3 [1] 从 2.5D 数据计算了 2D 约束 delaunay 三角剖分。现在我想要一个可以可视化的网格。

我已经按照手册[2]用 3d delaunay 做到了,我怎么能用 2.5D CDT 实现呢?

[...]
typedef CGAL::Projection_traits_xy_3<K>  Gt;
typedef CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds> CDT;
[...]
CDT cdt;
cdt.insert(points.begin(),points.end());
[...]
¿?
[...]
std::ofstream out(outdir + "out.off");
Polyhedron output_mesh;
CGAL::output_surface_facets_to_polyhedron(¿?, output_mesh);
out << output_mesh;

[1] http://pastebin.com/HzAwrnW5

[2] http://doc.cgal.org/latest/Point_set_processing_3/index.html#chappoint_set_processing_3 http://doc.cgal.org/latest/Surface_reconstruction_points_3/

写入off文件的伪代码来了

cout << "OFF\n"  << cdt.number_of_vertices() 
      << " "  << cdt.number_of_faces() << " 0" << std::endl;

std::map<vertex_handle,int> indices;
int counter = 0;

for all finite vertices v  {   
  cout << v->point() <<std::endl;
  indices.insert(v, counter++); 
}

for all finite faces f {  
  cout << "3 " << indices[f->vertex(0)]    
       << " "  << indices[f->vertex(1)] 
       << " "  << indices[f->vertex(2)] << std::endl;  
}

来自@Andreas 建议:

写入off文件的代码来了

std::ofstream outstream("output.off");
outstream << "OFF\n"  << cdt.number_of_vertices()
      << " "  << cdt.number_of_faces() << " 0" << std::endl;

std::map<CDT::Vertex_handle,int> indices;
int counter = 0;

for(CDT::Finite_vertices_iterator it = cdt.finite_vertices_begin(); it != cdt.finite_vertices_end(); ++it)
{
  outstream << it->point() << std::endl;
  indices.insert(std::pair<CDT::Vertex_handle,int>(it, counter++));
}

for(CDT::Finite_faces_iterator it = cdt.finite_faces_begin(); it != cdt.finite_faces_end(); ++it)
{
  outstream << "3 " << indices[it->vertex(0)] 
            << " "  << indices[it->vertex(1)]
            << " "  << indices[it->vertex(2)] << std::endl;
}