Rerun C++ SDK
Loading...
Searching...
No Matches
spherical_harmonics3rgb.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/build/re_type_definitions/rerun/datatypes/spherical_harmonics3rgb.def.rs".
3
4#pragma once
5
6#include "../half.hpp"
7#include "../result.hpp"
8
9#include <array>
10#include <cstdint>
11#include <memory>
12
13namespace arrow {
14 class Array;
15 class DataType;
16 class FixedSizeListBuilder;
17} // namespace arrow
18
19namespace rerun::datatypes {
20 /// **Datatype**: Spherical harmonics coefficients of degrees 1 through 3 for RGB, as 15 half-precision RGB triples.
21 ///
22 /// The coefficients are stored coefficient-major: `[c1.rgb, c2.rgb, …, c15.rgb]`.
23 /// The 15 coefficients `c1…c15` are ordered by ascending degree `l = 1, 2, 3`, and within
24 /// each degree by ascending order `m = -l … +l`:
25 /// degree 1 is `c1…c3`, degree 2 is `c4…c8`, and degree 3 is `c9…c15`.
26 /// The degrees are not exposed as separate groups, since each degree has a different
27 /// number of coefficients (3, 5, and 7).
28 ///
29 /// This per-coefficient order matches the `f_rest_*` properties of the PLY files used by
30 /// [3D Gaussian Splatting](https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/) (Kerbl et al., 2023),
31 /// but those store the channels channel-major (all 15 coefficients of R, then G, then B),
32 /// so they must be transposed on import.
33 ///
34 /// The degree-0 (DC) term is *not* included — it is represented as a `datatypes::Rgba32` color instead.
35 ///
36 /// Data of a lower spherical harmonics degree should be zero-padded,
37 /// which represents the exact same function (the spherical harmonics basis is orthonormal).
38 /// Conversely, truncating trailing coefficients at the degree boundaries (3 and 8 triples)
39 /// yields the optimal least-squares approximation of that lower degree.
40 ///
41 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
42 ///
44 /// Spherical harmonics coefficients of degrees 1 through 3, coefficient-major.
45 std::array<std::array<rerun::half, 3>, 15> coefficients;
46
47 public: // START of extensions from spherical_harmonics3rgb_ext.cpp:
48 /// The number of coefficients of degrees 1 through 3, i.e. the number of RGB triples.
49 static constexpr size_t NUM_COEFFICIENTS = 15;
50
51 /// Construct from 15 RGB coefficient triples of `float`, converting each to half-precision.
53 const std::array<std::array<float, 3>, NUM_COEFFICIENTS>& coefficients_
54 );
55
56 // END of extensions from spherical_harmonics3rgb_ext.cpp, start of generated code:
57
58 public:
59 SphericalHarmonics3Rgb() = default;
60
61 SphericalHarmonics3Rgb(std::array<std::array<rerun::half, 3>, 15> coefficients_)
62 : coefficients(coefficients_) {}
63
64 SphericalHarmonics3Rgb& operator=(std::array<std::array<rerun::half, 3>, 15> coefficients_
65 ) {
66 coefficients = coefficients_;
67 return *this;
68 }
69 };
70} // namespace rerun::datatypes
71
72namespace rerun {
73 template <typename T>
74 struct Loggable;
75
76 /// \private
77 template <>
78 struct Loggable<datatypes::SphericalHarmonics3Rgb> {
79 static constexpr std::string_view ComponentType = "rerun.datatypes.SphericalHarmonics3Rgb";
80
81 /// Returns the arrow data type this type corresponds to.
82 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
83
84 /// Serializes an array of `rerun::datatypes::SphericalHarmonics3Rgb` into an arrow array.
85 static Result<std::shared_ptr<arrow::Array>> to_arrow(
86 const datatypes::SphericalHarmonics3Rgb* instances, size_t num_instances
87 );
88
89 /// Fills an arrow array builder with an array of this type.
90 static rerun::Error fill_arrow_array_builder(
91 arrow::FixedSizeListBuilder* builder, const datatypes::SphericalHarmonics3Rgb* elements,
92 size_t num_elements
93 );
94 };
95} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:103
All built-in datatypes. See Types in the Rerun manual.
Definition rerun.hpp:93
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Datatype: Spherical harmonics coefficients of degrees 1 through 3 for RGB, as 15 half-precision RGB t...
Definition spherical_harmonics3rgb.hpp:43
static constexpr size_t NUM_COEFFICIENTS
The number of coefficients of degrees 1 through 3, i.e. the number of RGB triples.
Definition spherical_harmonics3rgb.hpp:49
std::array< std::array< rerun::half, 3 >, 15 > coefficients
Spherical harmonics coefficients of degrees 1 through 3, coefficient-major.
Definition spherical_harmonics3rgb.hpp:45
SphericalHarmonics3Rgb(const std::array< std::array< float, 3 >, NUM_COEFFICIENTS > &coefficients_)
Construct from 15 RGB coefficient triples of float, converting each to half-precision.