PLY文件格式及cpp解析

PLY (Polygon File Format, 多边形文件格式)文件用于存储Geometry Object Data(包括vertices, face and other element顶点/面片/其它属性)

文件格式:

Header
Vertex List
Face List
(lists of other elements)
  • ply开始,以end_header结束
  • 第二行format 指定是文本格式(ASCII),还是二进制格式(大端/小端之分)
  • 注释comment
  • element: 指定元素类型及其num
  • property: 指定元素的属性(数据类型及属性名)

tinyply解析库

  1. 解析文件头
PlyFile file;
file.parse_header(*file_stream);
  1. 获取元素(element)的具体属性(properties)
std::shared_ptr<PlyData> vertices;

try { vertices = file.request_properties_from_element("vertex", { "x", "y", "z" }); }
catch (const std::exception & e) { std::cerr << "tinyply exception: " << e.what() << std::endl; }

参考链接

posted @ 2024-05-12 10:04  达可奈特  阅读(131)  评论(0编辑  收藏  举报