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