Loading...
Searching...
No Matches
PlyParser.hpp
1#pragma once
2
3#include <ossia/dataflow/geometry_port.hpp>
4
5#include <span>
6#include <string_view>
7
8namespace Threedim::PrimitiveCloud
9{
10
11// Cheap header-only sniff: is the PLY file at `path` shaped like a
12// primitive cloud (no `face` element, or has columns outside the
13// standard mesh set {x,y,z,nx,ny,nz,red,green,blue,alpha,s,t,u,v})?
14// Reads only the textual header, doesn't load row data.
15bool ply_is_splat_shaped(std::string_view path);
16
17// Parse `path` and produce a primitive_cloud_component. The component's
18// raw_data is a single tightly-packed buffer of the PLY rows: each row
19// is a struct of the columns in their PLY-declared order, std430-style
20// natural alignment (each float at +4, each int at +4, each uchar at
21// +1 with no inter-field padding — but the row stride is rounded to
22// the largest field alignment within the row, see
23// internal::row_stride_for).
24//
25// Returns nullptr if the PLY is not splat-shaped, or if parsing fails.
26//
27// Sets format_id to a recognized signature when columns match a known
28// fingerprint:
29// - has f_dc_0/1/2 + f_rest_* + scale_0/1/2 + rot_0/1/2/3 + opacity
30// -> "3dgs.classic"
31// - else empty (the user wires the chain by hand or saves a preset)
32ossia::primitive_cloud_component_ptr parse_ply(std::string_view path);
33
34} // namespace Threedim::PrimitiveCloud