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