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