PLY (Polygon File Format, 多邊形文件格式)文件用於存儲Geometry Object Data(包括vertices, face and other element頂點/面片/其它屬性)
文件格式:
Header
Vertex List
Face List
(lists of other elements)
Header:
- 以
ply
開始,以end_header
結束 - 第二行
format
指定是文本格式(ASCII),還是二進制格式(大端/小端之分) - 註釋
comment
element
: 指定元素類型及其numproperty
: 指定元素的屬性(數據類型及屬性名)
tinyply解析庫
- 解析文件頭
PlyFile file;
file.parse_header(*file_stream);
- 獲取元素(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; }