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