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() {
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 std::optional<ComponentBatch> frame;
65
66 public:
67 /// The name of the archetype as used in `ComponentDescriptor`s.
68 static constexpr const char ArchetypeName[] = "rerun.archetypes.CoordinateFrame";
69
70 /// `ComponentDescriptor` for the `frame` field.
71 static constexpr auto Descriptor_frame = ComponentDescriptor(
72 ArchetypeName, "CoordinateFrame:frame",
74 );
75
76 public:
77 CoordinateFrame() = default;
78 CoordinateFrame(CoordinateFrame&& other) = default;
79 CoordinateFrame(const CoordinateFrame& other) = default;
80 CoordinateFrame& operator=(const CoordinateFrame& other) = default;
81 CoordinateFrame& operator=(CoordinateFrame&& other) = default;
82
84 : frame(ComponentBatch::from_loggable(std::move(_frame), Descriptor_frame)
85 .value_or_throw()) {}
86
87 /// Update only some specific fields of a `CoordinateFrame`.
89 return CoordinateFrame();
90 }
91
92 /// Clear all the fields of a `CoordinateFrame`.
94
95 /// The coordinate frame to use for the current entity.
97 frame = ComponentBatch::from_loggable(_frame, Descriptor_frame).value_or_throw();
98 return std::move(*this);
99 }
100
101 /// This method makes it possible to pack multiple `frame` in a single component batch.
102 ///
103 /// This only makes sense when used in conjunction with `columns`. `with_frame` should
104 /// be used when logging a single row's worth of data.
107 ) && {
108 frame = ComponentBatch::from_loggable(_frame, Descriptor_frame).value_or_throw();
109 return std::move(*this);
110 }
111
112 /// Partitions the component data into multiple sub-batches.
113 ///
114 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
115 /// instead, via `ComponentBatch::partitioned`.
116 ///
117 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
118 ///
119 /// The specified `lengths` must sum to the total length of the component batch.
121
122 /// Partitions the component data into unit-length sub-batches.
123 ///
124 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
125 /// where `n` is automatically guessed.
127 };
128
129} // namespace rerun::archetypes
130
131namespace rerun {
132 /// \private
133 template <typename T>
134 struct AsComponents;
135
136 /// \private
137 template <>
138 struct AsComponents<archetypes::CoordinateFrame> {
139 /// Serialize all set component batches.
140 static Result<Collection<ComponentBatch>> as_batches(
141 const archetypes::CoordinateFrame& archetype
142 );
143 };
144} // 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:76
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:64
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:105
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:96
static constexpr auto Descriptor_frame
ComponentDescriptor for the frame field.
Definition coordinate_frame.hpp:71
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition coordinate_frame.hpp:68
static CoordinateFrame update_fields()
Update only some specific fields of a CoordinateFrame.
Definition coordinate_frame.hpp:88
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