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 "../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() {
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).with_origins(origins).with_colors(colors)
61 /// );
62 /// }
63 /// ```
64 struct Arrows3D {
65 /// All the vectors for each arrow in the batch.
66 std::optional<ComponentBatch> vectors;
67
68 /// All the origin (base) positions for each arrow in the batch.
69 ///
70 /// If no origins are set, (0, 0, 0) is used as the origin for each arrow.
71 std::optional<ComponentBatch> origins;
72
73 /// Optional radii for the arrows.
74 ///
75 /// The shaft is rendered as a line with `radius = 0.5 * radius`.
76 /// The tip is rendered with `height = 2.0 * radius` and `radius = 1.0 * radius`.
77 std::optional<ComponentBatch> radii;
78
79 /// Optional colors for the points.
80 std::optional<ComponentBatch> colors;
81
82 /// Optional text labels for the arrows.
83 ///
84 /// If there's a single label present, it will be placed at the center of the entity.
85 /// Otherwise, each instance will have its own label.
86 std::optional<ComponentBatch> labels;
87
88 /// Whether the text labels should be shown.
89 ///
90 /// If not set, labels will automatically appear when there is exactly one label for this entity
91 /// or the number of instances on this entity is under a certain threshold.
92 std::optional<ComponentBatch> show_labels;
93
94 /// Optional class Ids for the points.
95 ///
96 /// The `components::ClassId` provides colors and labels if not specified explicitly.
97 std::optional<ComponentBatch> class_ids;
98
99 public:
100 /// The name of the archetype as used in `ComponentDescriptor`s.
101 static constexpr const char ArchetypeName[] = "rerun.archetypes.Arrows3D";
102
103 /// `ComponentDescriptor` for the `vectors` field.
106 );
107 /// `ComponentDescriptor` for the `origins` field.
109 ArchetypeName, "Arrows3D:origins",
111 );
112 /// `ComponentDescriptor` for the `radii` field.
113 static constexpr auto Descriptor_radii = ComponentDescriptor(
115 );
116 /// `ComponentDescriptor` for the `colors` field.
117 static constexpr auto Descriptor_colors = ComponentDescriptor(
119 );
120 /// `ComponentDescriptor` for the `labels` field.
121 static constexpr auto Descriptor_labels = ComponentDescriptor(
123 );
124 /// `ComponentDescriptor` for the `show_labels` field.
126 ArchetypeName, "Arrows3D:show_labels",
128 );
129 /// `ComponentDescriptor` for the `class_ids` field.
132 );
133
134 public: // START of extensions from arrows3d_ext.cpp:
135 /// Creates new 3D arrows pointing in the given directions, with a base at the origin (0, 0,
136 /// 0).
138 return Arrows3D().with_vectors(vectors_);
139 }
140
141 // END of extensions from arrows3d_ext.cpp, start of generated code:
142
143 public:
144 Arrows3D() = default;
145 Arrows3D(Arrows3D&& other) = default;
146 Arrows3D(const Arrows3D& other) = default;
147 Arrows3D& operator=(const Arrows3D& other) = default;
148 Arrows3D& operator=(Arrows3D&& other) = default;
149
150 /// Update only some specific fields of a `Arrows3D`.
152 return Arrows3D();
153 }
154
155 /// Clear all the fields of a `Arrows3D`.
157
158 /// All the vectors for each arrow in the batch.
160 vectors = ComponentBatch::from_loggable(_vectors, Descriptor_vectors).value_or_throw();
161 return std::move(*this);
162 }
163
164 /// All the origin (base) positions for each arrow in the batch.
165 ///
166 /// If no origins are set, (0, 0, 0) is used as the origin for each arrow.
168 origins = ComponentBatch::from_loggable(_origins, Descriptor_origins).value_or_throw();
169 return std::move(*this);
170 }
171
172 /// Optional radii for the arrows.
173 ///
174 /// The shaft is rendered as a line with `radius = 0.5 * radius`.
175 /// The tip is rendered with `height = 2.0 * radius` and `radius = 1.0 * radius`.
177 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
178 return std::move(*this);
179 }
180
181 /// Optional colors for the points.
183 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
184 return std::move(*this);
185 }
186
187 /// Optional text labels for the arrows.
188 ///
189 /// If there's a single label present, it will be placed at the center of the entity.
190 /// Otherwise, each instance will have its own label.
192 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
193 return std::move(*this);
194 }
195
196 /// Whether the text labels should be shown.
197 ///
198 /// If not set, labels will automatically appear when there is exactly one label for this entity
199 /// or the number of instances on this entity is under a certain threshold.
202 .value_or_throw();
203 return std::move(*this);
204 }
205
206 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
207 ///
208 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
209 /// be used when logging a single row's worth of data.
211 ) && {
213 .value_or_throw();
214 return std::move(*this);
215 }
216
217 /// Optional class Ids for the points.
218 ///
219 /// The `components::ClassId` provides colors and labels if not specified explicitly.
221 class_ids =
222 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
223 return std::move(*this);
224 }
225
226 /// Partitions the component data into multiple sub-batches.
227 ///
228 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
229 /// instead, via `ComponentBatch::partitioned`.
230 ///
231 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
232 ///
233 /// The specified `lengths` must sum to the total length of the component batch.
235
236 /// Partitions the component data into unit-length sub-batches.
237 ///
238 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
239 /// where `n` is automatically guessed.
241 };
242
243} // namespace rerun::archetypes
244
245namespace rerun {
246 /// \private
247 template <typename T>
248 struct AsComponents;
249
250 /// \private
251 template <>
252 struct AsComponents<archetypes::Arrows3D> {
253 /// Serialize all set component batches.
254 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Arrows3D& archetype);
255 };
256} // 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: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:64
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:113
Arrows3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the arrows.
Definition arrows3d.hpp:191
Arrows3D with_origins(const Collection< rerun::components::Position3D > &_origins) &&
All the origin (base) positions for each arrow in the batch.
Definition arrows3d.hpp:167
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition arrows3d.hpp:117
Arrows3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition arrows3d.hpp:200
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition arrows3d.hpp:101
Arrows3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class Ids for the points.
Definition arrows3d.hpp:220
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition arrows3d.hpp:125
std::optional< ComponentBatch > labels
Optional text labels for the arrows.
Definition arrows3d.hpp:86
std::optional< ComponentBatch > radii
Optional radii for the arrows.
Definition arrows3d.hpp:77
static Arrows3D update_fields()
Update only some specific fields of a Arrows3D.
Definition arrows3d.hpp:151
Arrows3D with_vectors(const Collection< rerun::components::Vector3D > &_vectors) &&
All the vectors for each arrow in the batch.
Definition arrows3d.hpp:159
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:137
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:97
std::optional< ComponentBatch > origins
All the origin (base) positions for each arrow in the batch.
Definition arrows3d.hpp:71
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:210
Arrows3D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the arrows.
Definition arrows3d.hpp:176
static constexpr auto Descriptor_vectors
ComponentDescriptor for the vectors field.
Definition arrows3d.hpp:104
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition arrows3d.hpp:121
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition arrows3d.hpp:130
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition arrows3d.hpp:92
static constexpr auto Descriptor_origins
ComponentDescriptor for the origins field.
Definition arrows3d.hpp:108
static Arrows3D clear_fields()
Clear all the fields of a Arrows3D.
std::optional< ComponentBatch > colors
Optional colors for the points.
Definition arrows3d.hpp:80
std::optional< ComponentBatch > vectors
All the vectors for each arrow in the batch.
Definition arrows3d.hpp:66
Arrows3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the points.
Definition arrows3d.hpp:182
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18