Rerun C++ SDK
Loading...
Searching...
No Matches
coordinate_frame.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_sdk_types/definitions/rerun/archetypes/coordinate_frame.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/transform_frame_id.hpp"
10#include "../result.hpp"
11
12#include <cstdint>
13#include <optional>
14#include <utility>
15#include <vector>
16
17namespace rerun::archetypes {
18 /// **Archetype**: Specifies the coordinate frame for an entity.
19 ///
20 /// If not specified, the coordinate frame uses an implicit frame derived from the entity path.
21 /// The implicit frame's name is `tf#/your/entity/path` and has an identity transform connection to its parent path.
22 ///
23 /// To learn more about transforms see [Spaces & Transforms](https://rerun.io/docs/concepts/spaces-and-transforms) in the reference.
24 ///
25 /// ## Example
26 ///
27 /// ### Change coordinate frame to different built-in frames
28 /// ![image](https://static.rerun.io/coordinate_frame_builtin_frame/71f941f35cf73c299c6ea7fbc4487a140db8e8f8/full.png)
29 ///
30 /// ```cpp
31 /// #include <rerun.hpp>
32 ///
33 /// int main(int argc, char* argv[]) {
34 /// const auto rec =
35 /// rerun::RecordingStream("rerun_example_transform3d_hierarchy");
36 /// rec.spawn().exit_on_failure();
37 ///
38 /// rec.set_time_sequence("time", 0);
39 /// rec.log(
40 /// "red_box",
41 /// rerun::Boxes3D::from_half_sizes({{0.5f, 0.5f, 0.5f}}
42 /// ).with_colors({rerun::Color(255, 0, 0)}),
43 /// // Use Transform3D to place the box, so we actually change the underlying coordinate frame and not just the box's pose.
44 /// rerun::Transform3D::from_translation({2.0f, 0.0f, 0.0f})
45 /// );
46 /// rec.log(
47 /// "blue_box",
48 /// rerun::Boxes3D::from_half_sizes({{0.5f, 0.5f, 0.5f}}
49 /// ).with_colors({rerun::Color(0, 0, 255)}),
50 /// // Use Transform3D to place the box, so we actually change the underlying coordinate frame and not just the box's pose.
51 /// rerun::Transform3D::from_translation({-2.0f, 0.0f, 0.0f})
52 /// );
53 /// rec.log("point", rerun::Points3D({{0.0f, 0.0f, 0.0f}}).with_radii({0.5f}));
54 ///
55 /// // Change where the point is located by cycling through its coordinate frame.
56 /// const char* frame_ids[] = {"tf#/red_box", "tf#/blue_box"};
57 /// for (int t = 0; t <2; t++) {
58 /// rec.set_time_sequence("time", t + 1); // leave it untouched at t==0.
59 /// rec.log("point", rerun::CoordinateFrame(frame_ids[t]));
60 /// }
61 /// }
62 /// ```
64 /// The coordinate frame to use for the current entity.
65 ///
66 /// Note that empty strings are not valid transform frame IDs.
67 std::optional<ComponentBatch> frame;
68
69 public:
70 /// The name of the archetype as used in `ComponentDescriptor`s.
71 static constexpr const char ArchetypeName[] = "rerun.archetypes.CoordinateFrame";
72
73 /// `ComponentDescriptor` for the `frame` field.
74 static constexpr auto Descriptor_frame = ComponentDescriptor(
75 ArchetypeName, "CoordinateFrame:frame",
77 );
78
79 public:
80 CoordinateFrame() = default;
81 CoordinateFrame(CoordinateFrame&& other) = default;
82 CoordinateFrame(const CoordinateFrame& other) = default;
83 CoordinateFrame& operator=(const CoordinateFrame& other) = default;
84 CoordinateFrame& operator=(CoordinateFrame&& other) = default;
85
87 : frame(ComponentBatch::from_loggable(std::move(_frame), Descriptor_frame)
88 .value_or_throw()) {}
89
90 /// Update only some specific fields of a `CoordinateFrame`.
92 return CoordinateFrame();
93 }
94
95 /// Clear all the fields of a `CoordinateFrame`.
97
98 /// The coordinate frame to use for the current entity.
99 ///
100 /// Note that empty strings are not valid transform frame IDs.
102 frame = ComponentBatch::from_loggable(_frame, Descriptor_frame).value_or_throw();
103 return std::move(*this);
104 }
105
106 /// This method makes it possible to pack multiple `frame` in a single component batch.
107 ///
108 /// This only makes sense when used in conjunction with `columns`. `with_frame` should
109 /// be used when logging a single row's worth of data.
112 ) && {
113 frame = ComponentBatch::from_loggable(_frame, Descriptor_frame).value_or_throw();
114 return std::move(*this);
115 }
116
117 /// Partitions the component data into multiple sub-batches.
118 ///
119 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
120 /// instead, via `ComponentBatch::partitioned`.
121 ///
122 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
123 ///
124 /// The specified `lengths` must sum to the total length of the component batch.
126
127 /// Partitions the component data into unit-length sub-batches.
128 ///
129 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
130 /// where `n` is automatically guessed.
132 };
133
134} // namespace rerun::archetypes
135
136namespace rerun {
137 /// \private
138 template <typename T>
139 struct AsComponents;
140
141 /// \private
142 template <>
143 struct AsComponents<archetypes::CoordinateFrame> {
144 /// Serialize all set component batches.
145 static Result<Collection<ComponentBatch>> as_batches(
146 const archetypes::CoordinateFrame& archetype
147 );
148 };
149} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:87
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: Specifies the coordinate frame for an entity.
Definition coordinate_frame.hpp:63
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
std::optional< ComponentBatch > frame
The coordinate frame to use for the current entity.
Definition coordinate_frame.hpp:67
CoordinateFrame with_many_frame(const Collection< rerun::components::TransformFrameId > &_frame) &&
This method makes it possible to pack multiple frame in a single component batch.
Definition coordinate_frame.hpp:110
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
CoordinateFrame with_frame(const rerun::components::TransformFrameId &_frame) &&
The coordinate frame to use for the current entity.
Definition coordinate_frame.hpp:101
static constexpr auto Descriptor_frame
ComponentDescriptor for the frame field.
Definition coordinate_frame.hpp:74
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition coordinate_frame.hpp:71
static CoordinateFrame update_fields()
Update only some specific fields of a CoordinateFrame.
Definition coordinate_frame.hpp:91
static CoordinateFrame clear_fields()
Clear all the fields of a CoordinateFrame.
Component: A string identifier for a transform frame.
Definition transform_frame_id.hpp:24