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 "../datatypes/vec3d.hpp"
7#include "../result.hpp"
8
9#include <array>
10#include <cstdint>
11#include <memory>
12
13namespace rerun::components {
14 /// **Component**: A position in 3D space.
15 struct Position3D {
17
18 public: // START of extensions from position3d_ext.cpp:
19 /// Construct Position3D from x/y/z values.
20 Position3D(float x, float y, float z) : xyz{x, y, z} {}
21
22 float x() const {
23 return xyz.x();
24 }
25
26 float y() const {
27 return xyz.y();
28 }
29
30 float z() const {
31 return xyz.z();
32 }
33
34 // END of extensions from position3d_ext.cpp, start of generated code:
35
36 public:
37 Position3D() = default;
38
39 Position3D(rerun::datatypes::Vec3D xyz_) : xyz(xyz_) {}
40
41 Position3D& operator=(rerun::datatypes::Vec3D xyz_) {
42 xyz = xyz_;
43 return *this;
44 }
45
46 Position3D(std::array<float, 3> xyz_) : xyz(xyz_) {}
47
48 Position3D& operator=(std::array<float, 3> xyz_) {
49 xyz = xyz_;
50 return *this;
51 }
52
53 /// Cast to the underlying Vec3D datatype
54 operator rerun::datatypes::Vec3D() const {
55 return xyz;
56 }
57 };
58} // namespace rerun::components
59
60namespace rerun {
61 static_assert(sizeof(rerun::datatypes::Vec3D) == sizeof(components::Position3D));
62
63 /// \private
64 template <>
65 struct Loggable<components::Position3D> {
66 static constexpr const char Name[] = "rerun.components.Position3D";
67
68 /// Returns the arrow data type this type corresponds to.
69 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
70 return Loggable<rerun::datatypes::Vec3D>::arrow_datatype();
71 }
72
73 /// Serializes an array of `rerun::components::Position3D` into an arrow array.
74 static Result<std::shared_ptr<arrow::Array>> to_arrow(
75 const components::Position3D* instances, size_t num_instances
76 ) {
77 if (num_instances == 0) {
78 return Loggable<rerun::datatypes::Vec3D>::to_arrow(nullptr, 0);
79 } else if (instances == nullptr) {
80 return rerun::Error(
81 ErrorCode::UnexpectedNullArgument,
82 "Passed array instances is null when num_elements> 0."
83 );
84 } else {
85 return Loggable<rerun::datatypes::Vec3D>::to_arrow(&instances->xyz, num_instances);
86 }
87 }
88 };
89} // 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:79
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
Component: A position in 3D space.
Definition position3d.hpp:15
Position3D(float x, float y, float z)
Construct Position3D from x/y/z values.
Definition position3d.hpp:20
Datatype: A vector in 3D space.
Definition vec3d.hpp:20