Rerun C++ SDK
Loading...
Searching...
No Matches
scale3d.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/store/re_types/definitions/rerun/components/scale3d.fbs".
3
4#pragma once
5
6#include "../datatypes/vec3d.hpp"
7#include "../result.hpp"
8
9#include <array>
10#include <cstdint>
11#include <memory>
12
13namespace rerun::components {
14 /// **Component**: A 3D scale factor.
15 ///
16 /// A scale of 1.0 means no scaling.
17 /// A scale of 2.0 means doubling the size.
18 /// Each component scales along the corresponding axis.
19 struct Scale3D {
21
22 public: // START of extensions from scale3d_ext.cpp:
23 /// Construct `Scale3D` from x/y/z values.
24 Scale3D(float x, float y, float z) : scale{x, y, z} {}
25
26 /// Construct `Scale3D` from x/y/z float pointer.
27 explicit Scale3D(const float* xyz) : scale{xyz[0], xyz[1], xyz[2]} {}
28
29 /// Construct a `Scale3D` from a uniform scale factor.
30 explicit Scale3D(float uniform_scale)
31 : Scale3D(datatypes::Vec3D{uniform_scale, uniform_scale, uniform_scale}) {}
32
33 /// Explicitly construct a `Scale3D` from a uniform scale factor.
34 static Scale3D uniform(float uniform_scale) {
35 return Scale3D(uniform_scale);
36 }
37
38 /// Explicitly construct a `Scale3D` from a 3D scale factor.
40 return Scale3D(scale);
41 }
42
43 // END of extensions from scale3d_ext.cpp, start of generated code:
44
45 public:
46 Scale3D() = default;
47
48 Scale3D(rerun::datatypes::Vec3D scale_) : scale(scale_) {}
49
50 Scale3D& operator=(rerun::datatypes::Vec3D scale_) {
51 scale = scale_;
52 return *this;
53 }
54
55 Scale3D(std::array<float, 3> xyz_) : scale(xyz_) {}
56
57 Scale3D& operator=(std::array<float, 3> xyz_) {
58 scale = xyz_;
59 return *this;
60 }
61
62 /// Cast to the underlying Vec3D datatype
63 operator rerun::datatypes::Vec3D() const {
64 return scale;
65 }
66 };
67} // namespace rerun::components
68
69namespace rerun {
70 static_assert(sizeof(rerun::datatypes::Vec3D) == sizeof(components::Scale3D));
71
72 /// \private
73 template <>
74 struct Loggable<components::Scale3D> {
75 static constexpr const char Name[] = "rerun.components.Scale3D";
76
77 /// Returns the arrow data type this type corresponds to.
78 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
79 return Loggable<rerun::datatypes::Vec3D>::arrow_datatype();
80 }
81
82 /// Serializes an array of `rerun::components::Scale3D` into an arrow array.
83 static Result<std::shared_ptr<arrow::Array>> to_arrow(
84 const components::Scale3D* instances, size_t num_instances
85 ) {
86 if (num_instances == 0) {
87 return Loggable<rerun::datatypes::Vec3D>::to_arrow(nullptr, 0);
88 } else if (instances == nullptr) {
89 return rerun::Error(
90 ErrorCode::UnexpectedNullArgument,
91 "Passed array instances is null when num_elements> 0."
92 );
93 } else {
94 return Loggable<rerun::datatypes::Vec3D>::to_arrow(
95 &instances->scale,
96 num_instances
97 );
98 }
99 }
100 };
101} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:79
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
Component: A 3D scale factor.
Definition scale3d.hpp:19
Scale3D(const float *xyz)
Construct Scale3D from x/y/z float pointer.
Definition scale3d.hpp:27
Scale3D(float x, float y, float z)
Construct Scale3D from x/y/z values.
Definition scale3d.hpp:24
Scale3D(float uniform_scale)
Construct a Scale3D from a uniform scale factor.
Definition scale3d.hpp:30
static Scale3D uniform(float uniform_scale)
Explicitly construct a Scale3D from a uniform scale factor.
Definition scale3d.hpp:34
static Scale3D three_d(datatypes::Vec3D scale)
Explicitly construct a Scale3D from a 3D scale factor.
Definition scale3d.hpp:39
Datatype: A vector in 3D space.
Definition vec3d.hpp:20