【问题标题】:CGAL output parametrized meshCGAL 输出参数化网格
【发布时间】:2020-09-14 16:27:46
【问题描述】:

我目前正在使用 CGAL 从封闭网格计算参数化。 这是我正在关注的示例: https://doc.cgal.org/latest/Surface_mesh_parameterization/Surface_mesh_parameterization_2seam_Polyhedron_3_8cpp-example.html

有没有办法用 CGAL 输出带有 uv 坐标/纹理贴图的 3D 网格? 例如,在 obj 文件或层上。

看起来很简单,但我找不到它的功能。

谢谢!

【问题讨论】:

    标签: c++ computational-geometry cgal


    【解决方案1】:

    CGAL 目前没有处理纹理的功能。但是,处理 UV 属性是可行的。将属性输出到文件的最简单方法是:

    例如,如果我运行这段代码:

    #include <CGAL/Simple_cartesian.h>
    #include <CGAL/Surface_mesh.h>
    #include <CGAL/Surface_mesh/IO.h>
    
    using Kernel = CGAL::Simple_cartesian<double>;
    using Point_3 = Kernel::Point_3;
    using Mesh = CGAL::Surface_mesh<Point_3>;
    using Vertex_index = Mesh::Vertex_index;
    using Halfedge_index = Mesh::Halfedge_index;
    using Edge_index = Mesh::Edge_index;
    
    int main()
    {
      Mesh mesh;
    
      Mesh::Property_map<Edge_index, double> u_map
        = mesh.add_property_map<Edge_index, double>("U").first;
      Mesh::Property_map<Edge_index, double> v_map
        = mesh.add_property_map<Edge_index, double>("V").first;
    
      Vertex_index v0 = mesh.add_vertex(Point_3(0,0,0));
      Vertex_index v1 = mesh.add_vertex(Point_3(0,0,1));
      Halfedge_index hi = mesh.add_edge (v0, v1);
      Edge_index ei = mesh.edge(hi);
    
      u_map[ei] = 0.2;
      v_map[ei] = 0.8;
    
      std::ofstream ofile ("out.ply");
      CGAL::write_ply (ofile, mesh);
    
      return EXIT_SUCCESS;
    }
    

    我得到以下输出 PLY 文件,它确实将 UV 属性存储在边缘:

    ply
    format ascii 1.0
    comment Generated by the CGAL library
    element vertex 2
    property double x
    property double y
    property double z
    element face 0
    property list uchar int vertex_indices
    element edge 1
    property int v0
    property int v1
    property double U
    property double V
    end_header
    0 0 0 
    0 0 1 
    1 0 0.2 0.8 
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-20
    • 1970-01-01
    相关资源
    最近更新 更多