CGAL输出参数化网格



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

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

看起来很简单,但我找不到它的函数。

谢谢!

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

  • 使用CGAL::Surface_mesh存储网格
  • 使用简单属性(double、int等(存储U V信息
  • 使用CGAL::write_ply()写入文件

例如,如果我运行以下代码:

#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 

最新更新