【问题标题】:Get a mesh_3 'off' from Projection_traits_xy_3 constrained delaunay从 Projection_traits_xy_3 约束 delaunay 中获取 mesh_3 'off'
【发布时间】:2015-11-24 09:16:21
【问题描述】:

我使用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/

【问题讨论】:

    标签: c++ cgal


    【解决方案1】:

    这里是用于将其写入关闭文件的伪代码

    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;  
    }
    

    【讨论】:

    • 我已经完成了,如果您希望我写另一个答案,请还原更改,我会提交一个正确的答案。
    • grmbl,我的编辑被拒绝了:/ 这个编辑偏离了帖子的初衷。即使是必须进行重大更改的编辑也应努力维护帖子所有者的目标
    【解决方案2】:

    来自@Andreas 的建议:

    这里是把它写入一个关闭文件的代码

    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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-06
      • 2014-05-16
      • 2014-02-06
      相关资源
      最近更新 更多