Module: Gsplat::IO::Ply
- Defined in:
- lib/gsplat/io/ply.rb
Overview
Inria-compatible Gaussian-splat PLY input and output.
Constant Summary collapse
- BASE_PROPERTIES =
Leading vertex properties in the Inria layout.
%w[x y z nx ny nz].freeze
- TRAILING_PROPERTIES =
Properties following spherical-harmonic coefficients.
%w[opacity scale_0 scale_1 scale_2 rot_0 rot_1 rot_2 rot_3].freeze
- REQUIRED_PROPERTIES =
Minimum property set required for a readable Gaussian model.
(%w[x y z] + %w[f_dc_0 f_dc_1 f_dc_2] + TRAILING_PROPERTIES).freeze
Class Method Summary collapse
-
.read(source) ⇒ Hash{Symbol=>Numo::SFloat}
Reads Inria-layout Gaussian parameters from ASCII or little-endian PLY.
-
.write(target, params, format: :binary_little_endian) ⇒ Integer
Writes raw Gaussian parameters with the Inria property layout.
Class Method Details
.read(source) ⇒ Hash{Symbol=>Numo::SFloat}
Reads Inria-layout Gaussian parameters from ASCII or little-endian PLY.
37 38 39 40 41 42 43 |
# File 'lib/gsplat/io/ply.rb', line 37 def read(source) columns = PlyReader.decode(read_bytes(source)) missing = REQUIRED_PROPERTIES - columns.keys raise Gsplat::Error, "missing PLY properties: #{missing.join(', ')}" unless missing.empty? build_params(columns) end |
.write(target, params, format: :binary_little_endian) ⇒ Integer
Writes raw Gaussian parameters with the Inria property layout.
24 25 26 27 28 29 30 31 |
# File 'lib/gsplat/io/ply.rb', line 24 def write(target, params, format: :binary_little_endian) arrays = normalize_params(params) rows = parameter_rows(arrays).select { |row| row.all?(&:finite?) } properties = property_names(arrays.fetch(:shN).shape[1]) header = build_header(format, rows.length, properties) payload = encode_rows(rows, format) write_bytes(target, header + payload) end |