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