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

參考鏈接

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章