Rerun C++ SDK
Loading...
Searching...
No Matches
position3d.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/position3d.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 position in 3D space.
16 struct Position3D {
18
19 public: // START of extensions from position3d_ext.cpp:
20 /// Construct Position3D from x/y/z values.
21 Position3D(float x, float y, float z) : xyz{x, y, z} {}
22
23 float x() const {
24 return xyz.x();
25 }
26
27 float y() const {
28 return xyz.y();
29 }
30
31 float z() const {
32 return xyz.z();
33 }
34
35 // END of extensions from position3d_ext.cpp, start of generated code:
36
37 public:
38 Position3D() = default;
39
40 Position3D(rerun::datatypes::Vec3D xyz_) : xyz(xyz_) {}
41
42 Position3D& operator=(rerun::datatypes::Vec3D xyz_) {
43 xyz = xyz_;
44 return *this;
45 }
46
47 Position3D(std::array<float, 3> xyz_) : xyz(xyz_) {}
48
49 Position3D& operator=(std::array<float, 3> xyz_) {
50 xyz = xyz_;
51 return *this;
52 }
53
54 /// Cast to the underlying Vec3D datatype
55 operator rerun::datatypes::Vec3D() const {
56 return xyz;
57 }
58 };
59} // namespace rerun::components
60
61namespace rerun {
62 static_assert(sizeof(rerun::datatypes::Vec3D) == sizeof(components::Position3D));
63
64 /// \private
65 template <>
66 struct Loggable<components::Position3D> {
67 static constexpr ComponentDescriptor Descriptor = "rerun.components.Position3D";
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::Vec3D>::arrow_datatype();
72 }
73
74 /// Serializes an array of `rerun::components::Position3D` into an arrow array.
75 static Result<std::shared_ptr<arrow::Array>> to_arrow(
76 const components::Position3D* instances, size_t num_instances
77 ) {
78 if (num_instances == 0) {
79 return Loggable<rerun::datatypes::Vec3D>::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::Vec3D>::to_arrow(&instances->xyz, 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:80
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Component: A position in 3D space.
Definition position3d.hpp:16
Position3D(float x, float y, float z)
Construct Position3D from x/y/z values.
Definition position3d.hpp:21
Datatype: A vector in 3D space.
Definition vec3d.hpp:21