Rerun C++ SDK
Loading...
Searching...
No Matches
ellipsoids3d.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/ellipsoids3d.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/fill_mode.hpp"
12#include "../components/half_size3d.hpp"
13#include "../components/pose_rotation_axis_angle.hpp"
14#include "../components/pose_rotation_quat.hpp"
15#include "../components/pose_translation3d.hpp"
16#include "../components/radius.hpp"
17#include "../components/show_labels.hpp"
18#include "../components/text.hpp"
19#include "../indicator_component.hpp"
20#include "../result.hpp"
21
22#include <cstdint>
23#include <optional>
24#include <utility>
25#include <vector>
26
27namespace rerun::archetypes {
28 /// **Archetype**: 3D ellipsoids or spheres.
29 ///
30 /// This archetype is for ellipsoids or spheres whose size is a key part of the data
31 /// (e.g. a bounding sphere).
32 /// For points whose radii are for the sake of visualization, use `archetypes::Points3D` instead.
33 ///
34 /// Note that orienting and placing the ellipsoids/spheres is handled via `[archetypes.InstancePoses3D]`.
35 /// Some of its component are repeated here for convenience.
36 /// If there's more instance poses than half sizes, the last half size will be repeated for the remaining poses.
37 ///
38 /// ## Example
39 ///
40 /// ### Covariance ellipsoid
41 /// ![image](https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/full.png)
42 ///
43 /// ```cpp
44 /// #include <rerun.hpp>
45 ///
46 /// #include <algorithm>
47 /// #include <random>
48 /// #include <vector>
49 ///
50 /// int main() {
51 /// const auto rec = rerun::RecordingStream("rerun_example_ellipsoid_simple");
52 /// rec.spawn().exit_on_failure();
53 ///
54 /// const float sigmas[3] = {5.0f, 3.0f, 1.0f};
55 ///
56 /// std::default_random_engine gen;
57 /// std::normal_distribution<float> dist(0.0, 1.0f);
58 ///
59 /// std::vector<rerun::Position3D> points3d(50000);
60 /// std::generate(points3d.begin(), points3d.end(), [&] {
61 /// return rerun::Position3D(
62 /// sigmas[0] * dist(gen),
63 /// sigmas[1] * dist(gen),
64 /// sigmas[2] * dist(gen)
65 /// );
66 /// });
67 ///
68 /// rec.log(
69 /// "points",
70 /// rerun::Points3D(points3d).with_radii(0.02f).with_colors(rerun::Rgba32(188, 77, 185))
71 /// );
72 ///
73 /// rec.log(
74 /// "ellipsoid",
75 /// rerun::Ellipsoids3D::from_centers_and_half_sizes(
76 /// {
77 /// {0.0f, 0.0f, 0.0f},
78 /// {0.0f, 0.0f, 0.0f},
79 /// },
80 /// {
81 /// {sigmas[0], sigmas[1], sigmas[2]},
82 /// {3.0f * sigmas[0], 3.0f * sigmas[1], 3.0f * sigmas[2]},
83 /// }
84 /// )
85 /// .with_colors({
86 /// rerun::Rgba32(255, 255, 0),
87 /// rerun::Rgba32(64, 64, 0),
88 /// })
89 /// );
90 /// }
91 /// ```
92 struct Ellipsoids3D {
93 /// For each ellipsoid, half of its size on its three axes.
94 ///
95 /// If all components are equal, then it is a sphere with that radius.
96 std::optional<ComponentBatch> half_sizes;
97
98 /// Optional center positions of the ellipsoids.
99 ///
100 /// If not specified, the centers will be at (0, 0, 0).
101 /// Note that this uses a `components::PoseTranslation3D` which is also used by `archetypes::InstancePoses3D`.
102 std::optional<ComponentBatch> centers;
103
104 /// Rotations via axis + angle.
105 ///
106 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
107 /// Note that this uses a `components::PoseRotationAxisAngle` which is also used by `archetypes::InstancePoses3D`.
108 std::optional<ComponentBatch> rotation_axis_angles;
109
110 /// Rotations via quaternion.
111 ///
112 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
113 /// Note that this uses a `components::PoseRotationQuat` which is also used by `archetypes::InstancePoses3D`.
114 std::optional<ComponentBatch> quaternions;
115
116 /// Optional colors for the ellipsoids.
117 std::optional<ComponentBatch> colors;
118
119 /// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
120 std::optional<ComponentBatch> line_radii;
121
122 /// Optionally choose whether the ellipsoids are drawn with lines or solid.
123 std::optional<ComponentBatch> fill_mode;
124
125 /// Optional text labels for the ellipsoids.
126 std::optional<ComponentBatch> labels;
127
128 /// Optional choice of whether the text labels should be shown by default.
129 std::optional<ComponentBatch> show_labels;
130
131 /// Optional class ID for the ellipsoids.
132 ///
133 /// The class ID provides colors and labels if not specified explicitly.
134 std::optional<ComponentBatch> class_ids;
135
136 public:
137 static constexpr const char IndicatorComponentName[] =
138 "rerun.components.Ellipsoids3DIndicator";
139
140 /// Indicator component, used to identify the archetype when converting to a list of components.
142 /// The name of the archetype as used in `ComponentDescriptor`s.
143 static constexpr const char ArchetypeName[] = "rerun.archetypes.Ellipsoids3D";
144
145 /// `ComponentDescriptor` for the `half_sizes` field.
147 ArchetypeName, "half_sizes",
149 );
150 /// `ComponentDescriptor` for the `centers` field.
152 ArchetypeName, "centers",
154 );
155 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
157 ArchetypeName, "rotation_axis_angles",
159 );
160 /// `ComponentDescriptor` for the `quaternions` field.
162 ArchetypeName, "quaternions",
164 );
165 /// `ComponentDescriptor` for the `colors` field.
166 static constexpr auto Descriptor_colors = ComponentDescriptor(
168 );
169 /// `ComponentDescriptor` for the `line_radii` field.
171 ArchetypeName, "line_radii",
173 );
174 /// `ComponentDescriptor` for the `fill_mode` field.
176 ArchetypeName, "fill_mode",
178 );
179 /// `ComponentDescriptor` for the `labels` field.
180 static constexpr auto Descriptor_labels = ComponentDescriptor(
182 );
183 /// `ComponentDescriptor` for the `show_labels` field.
185 ArchetypeName, "show_labels",
187 );
188 /// `ComponentDescriptor` for the `class_ids` field.
190 ArchetypeName, "class_ids",
192 );
193
194 public: // START of extensions from ellipsoids3d_ext.cpp:
195 /// Creates new `Ellipsoids3D` that are spheres, with `half_sizes` created from radii.
196 //
197 // TODO(andreas): This should not take an std::vector.
198 static Ellipsoids3D from_radii(const std::vector<float>& sizes);
199
200 /// Creates new `Ellipsoids3D` that are spheres, with `half_sizes` and `centers` created
201 /// from centers and radii.
202 //
203 // TODO(andreas): This should not take an std::vector.
205 const std::vector<datatypes::Vec3D>& centers, const std::vector<float>& radii
206 );
207
208 /// Creates new `Ellipsoids3D` with `half_sizes` centered around the local origin.
210 return Ellipsoids3D().with_half_sizes(std::move(half_sizes));
211 }
212
213 /// Creates new `Ellipsoids3D` with `centers` and `half_sizes`.
217 ) {
218 return Ellipsoids3D()
219 .with_half_sizes(std::move(half_sizes))
220 .with_centers(std::move(centers));
221 }
222
223 // END of extensions from ellipsoids3d_ext.cpp, start of generated code:
224
225 public:
226 Ellipsoids3D() = default;
227 Ellipsoids3D(Ellipsoids3D&& other) = default;
228 Ellipsoids3D(const Ellipsoids3D& other) = default;
229 Ellipsoids3D& operator=(const Ellipsoids3D& other) = default;
230 Ellipsoids3D& operator=(Ellipsoids3D&& other) = default;
231
232 /// Update only some specific fields of a `Ellipsoids3D`.
234 return Ellipsoids3D();
235 }
236
237 /// Clear all the fields of a `Ellipsoids3D`.
239
240 /// For each ellipsoid, half of its size on its three axes.
241 ///
242 /// If all components are equal, then it is a sphere with that radius.
244 ) && {
245 half_sizes =
246 ComponentBatch::from_loggable(_half_sizes, Descriptor_half_sizes).value_or_throw();
247 return std::move(*this);
248 }
249
250 /// Optional center positions of the ellipsoids.
251 ///
252 /// If not specified, the centers will be at (0, 0, 0).
253 /// Note that this uses a `components::PoseTranslation3D` which is also used by `archetypes::InstancePoses3D`.
255 ) && {
256 centers = ComponentBatch::from_loggable(_centers, Descriptor_centers).value_or_throw();
257 return std::move(*this);
258 }
259
260 /// Rotations via axis + angle.
261 ///
262 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
263 /// Note that this uses a `components::PoseRotationAxisAngle` which is also used by `archetypes::InstancePoses3D`.
266 ) && {
268 _rotation_axis_angles,
270 )
271 .value_or_throw();
272 return std::move(*this);
273 }
274
275 /// Rotations via quaternion.
276 ///
277 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
278 /// Note that this uses a `components::PoseRotationQuat` which is also used by `archetypes::InstancePoses3D`.
281 ) && {
283 .value_or_throw();
284 return std::move(*this);
285 }
286
287 /// Optional colors for the ellipsoids.
289 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
290 return std::move(*this);
291 }
292
293 /// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
295 line_radii =
296 ComponentBatch::from_loggable(_line_radii, Descriptor_line_radii).value_or_throw();
297 return std::move(*this);
298 }
299
300 /// Optionally choose whether the ellipsoids are drawn with lines or solid.
302 fill_mode =
303 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
304 return std::move(*this);
305 }
306
307 /// This method makes it possible to pack multiple `fill_mode` in a single component batch.
308 ///
309 /// This only makes sense when used in conjunction with `columns`. `with_fill_mode` should
310 /// be used when logging a single row's worth of data.
312 ) && {
313 fill_mode =
314 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
315 return std::move(*this);
316 }
317
318 /// Optional text labels for the ellipsoids.
320 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
321 return std::move(*this);
322 }
323
324 /// Optional choice of whether the text labels should be shown by default.
327 .value_or_throw();
328 return std::move(*this);
329 }
330
331 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
332 ///
333 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
334 /// be used when logging a single row's worth of data.
337 ) && {
339 .value_or_throw();
340 return std::move(*this);
341 }
342
343 /// Optional class ID for the ellipsoids.
344 ///
345 /// The class ID provides colors and labels if not specified explicitly.
347 class_ids =
348 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
349 return std::move(*this);
350 }
351
352 /// Partitions the component data into multiple sub-batches.
353 ///
354 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
355 /// instead, via `ComponentBatch::partitioned`.
356 ///
357 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
358 ///
359 /// The specified `lengths` must sum to the total length of the component batch.
361
362 /// Partitions the component data into unit-length sub-batches.
363 ///
364 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
365 /// where `n` is automatically guessed.
367 };
368
369} // namespace rerun::archetypes
370
371namespace rerun {
372 /// \private
373 template <typename T>
374 struct AsComponents;
375
376 /// \private
377 template <>
378 struct AsComponents<archetypes::Ellipsoids3D> {
379 /// Serialize all set component batches.
380 static Result<Collection<ComponentBatch>> as_batches(
381 const archetypes::Ellipsoids3D& archetype
382 );
383 };
384} // 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
FillMode
Component: How a geometric shape is drawn and colored.
Definition fill_mode.hpp:25
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 ellipsoids or spheres.
Definition ellipsoids3d.hpp:92
Ellipsoids3D with_quaternions(const Collection< rerun::components::PoseRotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition ellipsoids3d.hpp:279
Ellipsoids3D with_half_sizes(const Collection< rerun::components::HalfSize3D > &_half_sizes) &&
For each ellipsoid, half of its size on its three axes.
Definition ellipsoids3d.hpp:243
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition ellipsoids3d.hpp:161
static Ellipsoids3D from_centers_and_radii(const std::vector< datatypes::Vec3D > &centers, const std::vector< float > &radii)
Creates new Ellipsoids3D that are spheres, with half_sizes and centers created from centers and radii...
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition ellipsoids3d.hpp:108
Ellipsoids3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class ID for the ellipsoids.
Definition ellipsoids3d.hpp:346
std::optional< ComponentBatch > centers
Optional center positions of the ellipsoids.
Definition ellipsoids3d.hpp:102
static constexpr auto Descriptor_line_radii
ComponentDescriptor for the line_radii field.
Definition ellipsoids3d.hpp:170
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition ellipsoids3d.hpp:156
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition ellipsoids3d.hpp:184
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition ellipsoids3d.hpp:166
std::optional< ComponentBatch > labels
Optional text labels for the ellipsoids.
Definition ellipsoids3d.hpp:126
static Ellipsoids3D update_fields()
Update only some specific fields of a Ellipsoids3D.
Definition ellipsoids3d.hpp:233
Ellipsoids3D with_many_fill_mode(const Collection< rerun::components::FillMode > &_fill_mode) &&
This method makes it possible to pack multiple fill_mode in a single component batch.
Definition ellipsoids3d.hpp:311
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition ellipsoids3d.hpp:180
std::optional< ComponentBatch > line_radii
Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
Definition ellipsoids3d.hpp:120
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition ellipsoids3d.hpp:189
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Ellipsoids3D with_centers(const Collection< rerun::components::PoseTranslation3D > &_centers) &&
Optional center positions of the ellipsoids.
Definition ellipsoids3d.hpp:254
static constexpr auto Descriptor_half_sizes
ComponentDescriptor for the half_sizes field.
Definition ellipsoids3d.hpp:146
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition ellipsoids3d.hpp:143
Ellipsoids3D with_rotation_axis_angles(const Collection< rerun::components::PoseRotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition ellipsoids3d.hpp:264
static Ellipsoids3D from_centers_and_half_sizes(Collection< components::PoseTranslation3D > centers, Collection< components::HalfSize3D > half_sizes)
Creates new Ellipsoids3D with centers and half_sizes.
Definition ellipsoids3d.hpp:214
static Ellipsoids3D from_radii(const std::vector< float > &sizes)
Creates new Ellipsoids3D that are spheres, with half_sizes created from radii.
Ellipsoids3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Optional choice of whether the text labels should be shown by default.
Definition ellipsoids3d.hpp:325
std::optional< ComponentBatch > half_sizes
For each ellipsoid, half of its size on its three axes.
Definition ellipsoids3d.hpp:96
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition ellipsoids3d.hpp:114
Ellipsoids3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the ellipsoids.
Definition ellipsoids3d.hpp:319
Ellipsoids3D with_line_radii(const Collection< rerun::components::Radius > &_line_radii) &&
Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
Definition ellipsoids3d.hpp:294
std::optional< ComponentBatch > colors
Optional colors for the ellipsoids.
Definition ellipsoids3d.hpp:117
std::optional< ComponentBatch > class_ids
Optional class ID for the ellipsoids.
Definition ellipsoids3d.hpp:134
Ellipsoids3D with_fill_mode(const rerun::components::FillMode &_fill_mode) &&
Optionally choose whether the ellipsoids are drawn with lines or solid.
Definition ellipsoids3d.hpp:301
static constexpr auto Descriptor_fill_mode
ComponentDescriptor for the fill_mode field.
Definition ellipsoids3d.hpp:175
static Ellipsoids3D from_half_sizes(Collection< components::HalfSize3D > half_sizes)
Creates new Ellipsoids3D with half_sizes centered around the local origin.
Definition ellipsoids3d.hpp:209
static constexpr auto Descriptor_centers
ComponentDescriptor for the centers field.
Definition ellipsoids3d.hpp:151
std::optional< ComponentBatch > fill_mode
Optionally choose whether the ellipsoids are drawn with lines or solid.
Definition ellipsoids3d.hpp:123
static Ellipsoids3D clear_fields()
Clear all the fields of a Ellipsoids3D.
std::optional< ComponentBatch > show_labels
Optional choice of whether the text labels should be shown by default.
Definition ellipsoids3d.hpp:129
Ellipsoids3D 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 ellipsoids3d.hpp:335
Ellipsoids3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the ellipsoids.
Definition ellipsoids3d.hpp:288
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