Rerun C++ SDK
Loading...
Searching...
No Matches
half_size2d.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/half_size2d.fbs".
3
4#pragma once
5
6#include "../component_descriptor.hpp"
7#include "../datatypes/vec2d.hpp"
8#include "../result.hpp"
9
10#include <array>
11#include <cstdint>
12#include <memory>
13
14namespace rerun::components {
15 /// **Component**: Half-size (radius) of a 2D box.
16 ///
17 /// Measured in its local coordinate system.
18 ///
19 /// The box extends both in negative and positive direction along each axis.
20 /// Negative sizes indicate that the box is flipped along the respective axis, but this has no effect on how it is displayed.
21 struct HalfSize2D {
23
24 public: // START of extensions from half_size2d_ext.cpp:
25 /// Construct HalfSize2D from x/y values.
26 HalfSize2D(float x, float y) : xy{x, y} {}
27
28 float x() const {
29 return xy.x();
30 }
31
32 float y() const {
33 return xy.y();
34 }
35
36 // END of extensions from half_size2d_ext.cpp, start of generated code:
37
38 public:
39 HalfSize2D() = default;
40
41 HalfSize2D(rerun::datatypes::Vec2D xy_) : xy(xy_) {}
42
43 HalfSize2D& operator=(rerun::datatypes::Vec2D xy_) {
44 xy = xy_;
45 return *this;
46 }
47
48 HalfSize2D(std::array<float, 2> xy_) : xy(xy_) {}
49
50 HalfSize2D& operator=(std::array<float, 2> xy_) {
51 xy = xy_;
52 return *this;
53 }
54
55 /// Cast to the underlying Vec2D datatype
56 operator rerun::datatypes::Vec2D() const {
57 return xy;
58 }
59 };
60} // namespace rerun::components
61
62namespace rerun {
63 static_assert(sizeof(rerun::datatypes::Vec2D) == sizeof(components::HalfSize2D));
64
65 /// \private
66 template <>
67 struct Loggable<components::HalfSize2D> {
68 static constexpr ComponentDescriptor Descriptor = "rerun.components.HalfSize2D";
69
70 /// Returns the arrow data type this type corresponds to.
71 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
72 return Loggable<rerun::datatypes::Vec2D>::arrow_datatype();
73 }
74
75 /// Serializes an array of `rerun::components::HalfSize2D` into an arrow array.
76 static Result<std::shared_ptr<arrow::Array>> to_arrow(
77 const components::HalfSize2D* instances, size_t num_instances
78 ) {
79 if (num_instances == 0) {
80 return Loggable<rerun::datatypes::Vec2D>::to_arrow(nullptr, 0);
81 } else if (instances == nullptr) {
82 return rerun::Error(
83 ErrorCode::UnexpectedNullArgument,
84 "Passed array instances is null when num_elements> 0."
85 );
86 } else {
87 return Loggable<rerun::datatypes::Vec2D>::to_arrow(&instances->xy, num_instances);
88 }
89 }
90 };
91} // 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: Half-size (radius) of a 2D box.
Definition half_size2d.hpp:21
HalfSize2D(float x, float y)
Construct HalfSize2D from x/y values.
Definition half_size2d.hpp:26
Datatype: A vector in 2D space.
Definition vec2d.hpp:21