Rerun C++ SDK
Loading...
Searching...
No Matches
half_sizes2d.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/re_types/definitions/rerun/components/half_sizes2d.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-sizes (extents) of a 2D box along its local axis, starting at its local origin/center.
15 ///
16 /// The box extends both in negative and positive direction along each axis.
17 /// Negative sizes indicate that the box is flipped along the respective axis, but this has no effect on how it is displayed.
18 struct HalfSizes2D {
20
21 public:
22 // Extensions to generated type defined in 'half_sizes2d_ext.cpp'
23
24 /// Construct HalfSizes2D from x/y values.
25 HalfSizes2D(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 public:
36 HalfSizes2D() = default;
37
38 HalfSizes2D(rerun::datatypes::Vec2D xy_) : xy(xy_) {}
39
40 HalfSizes2D& operator=(rerun::datatypes::Vec2D xy_) {
41 xy = xy_;
42 return *this;
43 }
44
45 HalfSizes2D(std::array<float, 2> xy_) : xy(xy_) {}
46
47 HalfSizes2D& operator=(std::array<float, 2> xy_) {
48 xy = xy_;
49 return *this;
50 }
51
52 /// Cast to the underlying Vec2D datatype
53 operator rerun::datatypes::Vec2D() const {
54 return xy;
55 }
56 };
57} // namespace rerun::components
58
59namespace rerun {
60 static_assert(sizeof(rerun::datatypes::Vec2D) == sizeof(components::HalfSizes2D));
61
62 /// \private
63 template <>
64 struct Loggable<components::HalfSizes2D> {
65 static constexpr const char Name[] = "rerun.components.HalfSizes2D";
66
67 /// Returns the arrow data type this type corresponds to.
68 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
69 return Loggable<rerun::datatypes::Vec2D>::arrow_datatype();
70 }
71
72 /// Serializes an array of `rerun::components::HalfSizes2D` into an arrow array.
73 static Result<std::shared_ptr<arrow::Array>> to_arrow(
74 const components::HalfSizes2D* instances, size_t num_instances
75 ) {
76 return Loggable<rerun::datatypes::Vec2D>::to_arrow(&instances->xy, num_instances);
77 }
78 };
79} // namespace rerun
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:21
Component: Half-sizes (extents) of a 2D box along its local axis, starting at its local origin/center...
Definition half_sizes2d.hpp:18
HalfSizes2D(float x, float y)
Construct HalfSizes2D from x/y values.
Definition half_sizes2d.hpp:25
Datatype: A vector in 2D space.
Definition vec2d.hpp:20