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 = rerun::RecordingStream("rerun_example_transform3d_hierarchy");
35 /// rec.spawn().exit_on_failure();
36 ///
37 /// rec.set_time_sequence("time", 0);
38 /// rec.log(
39 /// "red_box",
40 /// rerun::Boxes3D::from_half_sizes({{0.5f, 0.5f, 0.5f}}
41 /// ).with_colors({rerun::Color(255, 0, 0)}),
42 /// // Use Transform3D to place the box, so we actually change the underlying coordinate frame and not just the box's pose.
43 /// rerun::Transform3D::from_translation({2.0f, 0.0f, 0.0f})
44 /// );
45 /// rec.log(
46 /// "blue_box",
47 /// rerun::Boxes3D::from_half_sizes({{0.5f, 0.5f, 0.5f}}
48 /// ).with_colors({rerun::Color(0, 0, 255)}),
49 /// // Use Transform3D to place the box, so we actually change the underlying coordinate frame and not just the box's pose.
50 /// rerun::Transform3D::from_translation({-2.0f, 0.0f, 0.0f})
51 /// );
52 /// rec.log("point", rerun::Points3D({{0.0f, 0.0f, 0.0f}}).with_radii({0.5f}));
53 ///
54 /// // Change where the point is located by cycling through its coordinate frame.
55 /// const char* frame_ids[] = {"tf#/red_box", "tf#/blue_box"};
56 /// for (int t = 0; t <2; t++) {
57 /// rec.set_time_sequence("time", t + 1); // leave it untouched at t==0.
58 /// rec.log("point", rerun::CoordinateFrame(frame_ids[t]));
59 /// }
60 /// }
61 /// ```
63 /// The coordinate frame to use for the current entity.
64 ///
65 /// Note that empty strings are not valid transform frame IDs.
66 std::optional<ComponentBatch> frame;
67
68 public:
69 /// The name of the archetype as used in `ComponentDescriptor`s.
70 static constexpr const char ArchetypeName[] = "rerun.archetypes.CoordinateFrame";
71
72 /// `ComponentDescriptor` for the `frame` field.
73 static constexpr auto Descriptor_frame = ComponentDescriptor(
74 ArchetypeName, "CoordinateFrame:frame",
76 );
77
78 public:
79 CoordinateFrame() = default;
80 CoordinateFrame(CoordinateFrame&& other) = default;
81 CoordinateFrame(const CoordinateFrame& other) = default;
82 CoordinateFrame& operator=(const CoordinateFrame& other) = default;
83 CoordinateFrame& operator=(CoordinateFrame&& other) = default;
84
86 : frame(ComponentBatch::from_loggable(std::move(_frame), Descriptor_frame)
87 .value_or_throw()) {}
88
89 /// Update only some specific fields of a `CoordinateFrame`.
91 return CoordinateFrame();
92 }
93
94 /// Clear all the fields of a `CoordinateFrame`.
96
97 /// The coordinate frame to use for the current entity.
98 ///
99 /// Note that empty strings are not valid transform frame IDs.
101 frame = ComponentBatch::from_loggable(_frame, Descriptor_frame).value_or_throw();
102 return std::move(*this);
103 }
104
105 /// This method makes it possible to pack multiple `frame` in a single component batch.
106 ///
107 /// This only makes sense when used in conjunction with `columns`. `with_frame` should
108 /// be used when logging a single row's worth of data.
111 ) && {
112 frame = ComponentBatch::from_loggable(_frame, Descriptor_frame).value_or_throw();
113 return std::move(*this);
114 }
115
116 /// Partitions the component data into multiple sub-batches.
117 ///
118 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
119 /// instead, via `ComponentBatch::partitioned`.
120 ///
121 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
122 ///
123 /// The specified `lengths` must sum to the total length of the component batch.
125
126 /// Partitions the component data into unit-length sub-batches.
127 ///
128 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
129 /// where `n` is automatically guessed.
131 };
132
133} // namespace rerun::archetypes
134
135namespace rerun {
136 /// \private
137 template <typename T>
138 struct AsComponents;
139
140 /// \private
141 template <>
142 struct AsComponents<archetypes::CoordinateFrame> {
143 /// Serialize all set component batches.
144 static Result<Collection<ComponentBatch>> as_batches(
145 const archetypes::CoordinateFrame& archetype
146 );
147 };
148} // 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:81
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:62
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:66
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:109
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:100
static constexpr auto Descriptor_frame
ComponentDescriptor for the frame field.
Definition coordinate_frame.hpp:73
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition coordinate_frame.hpp:70
static CoordinateFrame update_fields()
Update only some specific fields of a CoordinateFrame.
Definition coordinate_frame.hpp:90
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