Rerun C++ SDK
Loading...
Searching...
No Matches
arrows3d.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/arrows3d.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/class_id.hpp"
10#include "../components/color.hpp"
11#include "../components/position3d.hpp"
12#include "../components/radius.hpp"
13#include "../components/show_labels.hpp"
14#include "../components/text.hpp"
15#include "../components/vector3d.hpp"
16#include "../result.hpp"
17
18#include <cstdint>
19#include <optional>
20#include <utility>
21#include <vector>
22
23namespace rerun::archetypes {
24 /// **Archetype**: 3D arrows with optional colors, radii, labels, etc.
25 ///
26 /// ## Example
27 ///
28 /// ### Simple batch of 3D arrows
29 /// ![image](https://static.rerun.io/arrow3d_simple/55e2f794a520bbf7527d7b828b0264732146c5d0/full.png)
30 ///
31 /// ```cpp
32 /// #include <rerun.hpp>
33 ///
34 /// #include <cmath>
35 /// #include <vector>
36 ///
37 /// constexpr float TAU = 6.28318530717958647692528676655900577f;
38 ///
39 /// int main(int argc, char* argv[]) {
40 /// const auto rec = rerun::RecordingStream("rerun_example_arrow3d");
41 /// rec.spawn().exit_on_failure();
42 ///
43 /// std::vector<rerun::Position3D> origins;
44 /// std::vector<rerun::Vector3D> vectors;
45 /// std::vector<rerun::Color> colors;
46 ///
47 /// for (int i = 0; i <100; ++i) {
48 /// origins.push_back({0, 0, 0});
49 ///
50 /// float angle = TAU * static_cast<float>(i) * 0.01f;
51 /// float length = static_cast<float>(log2(i + 1));
52 /// vectors.push_back({length * sinf(angle), 0.0, length * cosf(angle)});
53 ///
54 /// uint8_t c = static_cast<uint8_t>(round(angle / TAU * 255.0f));
55 /// colors.push_back({static_cast<uint8_t>(255 - c), c, 128, 128});
56 /// }
57 ///
58 /// rec.log(
59 /// "arrows",
60 /// rerun::Arrows3D::from_vectors(vectors)
61 /// .with_origins(origins)
62 /// .with_colors(colors)
63 /// );
64 /// }
65 /// ```
66 struct Arrows3D {
67 /// All the vectors for each arrow in the batch.
68 std::optional<ComponentBatch> vectors;
69
70 /// All the origin (base) positions for each arrow in the batch.
71 ///
72 /// If no origins are set, (0, 0, 0) is used as the origin for each arrow.
73 std::optional<ComponentBatch> origins;
74
75 /// Optional radii for the arrows.
76 ///
77 /// The shaft is rendered as a line with `radius = 0.5 * radius`.
78 /// The tip is rendered with `height = 2.0 * radius` and `radius = 1.0 * radius`.
79 std::optional<ComponentBatch> radii;
80
81 /// Optional colors for the points.
82 std::optional<ComponentBatch> colors;
83
84 /// Optional text labels for the arrows.
85 ///
86 /// If there's a single label present, it will be placed at the center of the entity.
87 /// Otherwise, each instance will have its own label.
88 std::optional<ComponentBatch> labels;
89
90 /// Whether the text labels should be shown.
91 ///
92 /// If not set, labels will automatically appear when there is exactly one label for this entity
93 /// or the number of instances on this entity is under a certain threshold.
94 std::optional<ComponentBatch> show_labels;
95
96 /// Optional class Ids for the points.
97 ///
98 /// The `components::ClassId` provides colors and labels if not specified explicitly.
99 std::optional<ComponentBatch> class_ids;
100
101 public:
102 /// The name of the archetype as used in `ComponentDescriptor`s.
103 static constexpr const char ArchetypeName[] = "rerun.archetypes.Arrows3D";
104
105 /// `ComponentDescriptor` for the `vectors` field.
108 );
109 /// `ComponentDescriptor` for the `origins` field.
111 ArchetypeName, "Arrows3D:origins",
113 );
114 /// `ComponentDescriptor` for the `radii` field.
115 static constexpr auto Descriptor_radii = ComponentDescriptor(
117 );
118 /// `ComponentDescriptor` for the `colors` field.
119 static constexpr auto Descriptor_colors = ComponentDescriptor(
121 );
122 /// `ComponentDescriptor` for the `labels` field.
123 static constexpr auto Descriptor_labels = ComponentDescriptor(
125 );
126 /// `ComponentDescriptor` for the `show_labels` field.
128 ArchetypeName, "Arrows3D:show_labels",
130 );
131 /// `ComponentDescriptor` for the `class_ids` field.
134 );
135
136 public: // START of extensions from arrows3d_ext.cpp:
137 /// Creates new 3D arrows pointing in the given directions, with a base at the origin (0, 0,
138 /// 0).
140 return Arrows3D().with_vectors(vectors_);
141 }
142
143 // END of extensions from arrows3d_ext.cpp, start of generated code:
144
145 public:
146 Arrows3D() = default;
147 Arrows3D(Arrows3D&& other) = default;
148 Arrows3D(const Arrows3D& other) = default;
149 Arrows3D& operator=(const Arrows3D& other) = default;
150 Arrows3D& operator=(Arrows3D&& other) = default;
151
152 /// Update only some specific fields of a `Arrows3D`.
154 return Arrows3D();
155 }
156
157 /// Clear all the fields of a `Arrows3D`.
159
160 /// All the vectors for each arrow in the batch.
162 vectors = ComponentBatch::from_loggable(_vectors, Descriptor_vectors).value_or_throw();
163 return std::move(*this);
164 }
165
166 /// All the origin (base) positions for each arrow in the batch.
167 ///
168 /// If no origins are set, (0, 0, 0) is used as the origin for each arrow.
170 origins = ComponentBatch::from_loggable(_origins, Descriptor_origins).value_or_throw();
171 return std::move(*this);
172 }
173
174 /// Optional radii for the arrows.
175 ///
176 /// The shaft is rendered as a line with `radius = 0.5 * radius`.
177 /// The tip is rendered with `height = 2.0 * radius` and `radius = 1.0 * radius`.
179 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
180 return std::move(*this);
181 }
182
183 /// Optional colors for the points.
185 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
186 return std::move(*this);
187 }
188
189 /// Optional text labels for the arrows.
190 ///
191 /// If there's a single label present, it will be placed at the center of the entity.
192 /// Otherwise, each instance will have its own label.
194 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
195 return std::move(*this);
196 }
197
198 /// Whether the text labels should be shown.
199 ///
200 /// If not set, labels will automatically appear when there is exactly one label for this entity
201 /// or the number of instances on this entity is under a certain threshold.
204 .value_or_throw();
205 return std::move(*this);
206 }
207
208 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
209 ///
210 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
211 /// be used when logging a single row's worth of data.
213 ) && {
215 .value_or_throw();
216 return std::move(*this);
217 }
218
219 /// Optional class Ids for the points.
220 ///
221 /// The `components::ClassId` provides colors and labels if not specified explicitly.
223 class_ids =
224 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
225 return std::move(*this);
226 }
227
228 /// Partitions the component data into multiple sub-batches.
229 ///
230 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
231 /// instead, via `ComponentBatch::partitioned`.
232 ///
233 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
234 ///
235 /// The specified `lengths` must sum to the total length of the component batch.
237
238 /// Partitions the component data into unit-length sub-batches.
239 ///
240 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
241 /// where `n` is automatically guessed.
243 };
244
245} // namespace rerun::archetypes
246
247namespace rerun {
248 /// \private
249 template <typename T>
250 struct AsComponents;
251
252 /// \private
253 template <>
254 struct AsComponents<archetypes::Arrows3D> {
255 /// Serialize all set component batches.
256 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Arrows3D& archetype);
257 };
258} // 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
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: 3D arrows with optional colors, radii, labels, etc.
Definition arrows3d.hpp:66
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition arrows3d.hpp:115
Arrows3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the arrows.
Definition arrows3d.hpp:193
Arrows3D with_origins(const Collection< rerun::components::Position3D > &_origins) &&
All the origin (base) positions for each arrow in the batch.
Definition arrows3d.hpp:169
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition arrows3d.hpp:119
Arrows3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition arrows3d.hpp:202
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition arrows3d.hpp:103
Arrows3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class Ids for the points.
Definition arrows3d.hpp:222
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition arrows3d.hpp:127
std::optional< ComponentBatch > labels
Optional text labels for the arrows.
Definition arrows3d.hpp:88
std::optional< ComponentBatch > radii
Optional radii for the arrows.
Definition arrows3d.hpp:79
static Arrows3D update_fields()
Update only some specific fields of a Arrows3D.
Definition arrows3d.hpp:153
Arrows3D with_vectors(const Collection< rerun::components::Vector3D > &_vectors) &&
All the vectors for each arrow in the batch.
Definition arrows3d.hpp:161
static Arrows3D from_vectors(Collection< components::Vector3D > vectors_)
Creates new 3D arrows pointing in the given directions, with a base at the origin (0,...
Definition arrows3d.hpp:139
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
std::optional< ComponentBatch > class_ids
Optional class Ids for the points.
Definition arrows3d.hpp:99
std::optional< ComponentBatch > origins
All the origin (base) positions for each arrow in the batch.
Definition arrows3d.hpp:73
Arrows3D with_many_show_labels(const Collection< rerun::components::ShowLabels > &_show_labels) &&
This method makes it possible to pack multiple show_labels in a single component batch.
Definition arrows3d.hpp:212
Arrows3D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the arrows.
Definition arrows3d.hpp:178
static constexpr auto Descriptor_vectors
ComponentDescriptor for the vectors field.
Definition arrows3d.hpp:106
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition arrows3d.hpp:123
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition arrows3d.hpp:132
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition arrows3d.hpp:94
static constexpr auto Descriptor_origins
ComponentDescriptor for the origins field.
Definition arrows3d.hpp:110
static Arrows3D clear_fields()
Clear all the fields of a Arrows3D.
std::optional< ComponentBatch > colors
Optional colors for the points.
Definition arrows3d.hpp:82
std::optional< ComponentBatch > vectors
All the vectors for each arrow in the batch.
Definition arrows3d.hpp:68
Arrows3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the points.
Definition arrows3d.hpp:184
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18