CGAL SurfaceMesh 保存颜色

typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;

typedef CGAL::Surface_mesh<Point_3> SurfaceMesh;
void main()

{
  SurfaceMesh mesh;

  SurfaceMesh::Vertex_index v0 = mesh.add_vertex(Point_3(0, 0, 0));
  SurfaceMesh::Vertex_index v1 = mesh.add_vertex(Point_3(1, 0, 0));
  SurfaceMesh::Vertex_index v2 = mesh.add_vertex(Point_3(0, 1, 0));
  mesh.add_face(v0, v1, v2);

  auto color_map = mesh.add_property_map <SurfaceMesh::vertex_index, CGAL::Color>("v:color").first;

  color_map[v0] = CGAL::Color(255, 0, 0);
  color_map[v1] = CGAL::Color(255, 0, 0);
  color_map[v2] = CGAL::Color(255, 0, 0);

  CGAL::IO::write_PLY("test.ply", mesh);

}

 

posted @ 2024-03-28 11:00  lma_o  阅读(35)  评论(0编辑  收藏  举报