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/build/re_type_definitions/rerun/archetypes/ellipsoids3d.def.rs".
3
4#pragma once
5
6#include "../archetype_utils.hpp"
7#include "../collection.hpp"
8#include "../component_batch.hpp"
9#include "../component_column.hpp"
10#include "../components/class_id.hpp"
11#include "../components/color.hpp"
12#include "../components/fill_mode.hpp"
13#include "../components/half_size3d.hpp"
14#include "../components/radius.hpp"
15#include "../components/rotation_axis_angle.hpp"
16#include "../components/rotation_quat.hpp"
17#include "../components/show_labels.hpp"
18#include "../components/text.hpp"
19#include "../components/translation3d.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 /// If there's more instance poses than half sizes, the last ellipsoid/sphere's orientation will be repeated for the remaining poses.
35 /// Orienting and placing ellipsoids/spheres forms a separate transform that is applied prior to `archetypes::InstancePoses3D` and `archetypes::Transform3D`.
36 ///
37 /// ## Example
38 ///
39 /// ### Covariance ellipsoid
40 /// ![image](https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/full.png)
41 ///
42 /// ```cpp
43 /// #include <rerun.hpp>
44 ///
45 /// #include <algorithm>
46 /// #include <random>
47 /// #include <vector>
48 ///
49 /// int main(int argc, char* argv[]) {
50 /// const auto rec = rerun::RecordingStream("rerun_example_ellipsoid_simple");
51 /// rec.spawn().exit_on_failure();
52 ///
53 /// const float sigmas[3] = {5.0f, 3.0f, 1.0f};
54 ///
55 /// std::default_random_engine gen;
56 /// std::normal_distribution<float> dist(0.0, 1.0f);
57 ///
58 /// std::vector<rerun::Position3D> points3d(50000);
59 /// std::generate(points3d.begin(), points3d.end(), [&] {
60 /// return rerun::Position3D(
61 /// sigmas[0] * dist(gen),
62 /// sigmas[1] * dist(gen),
63 /// sigmas[2] * dist(gen)
64 /// );
65 /// });
66 ///
67 /// rec.log(
68 /// "points",
69 /// rerun::Points3D(points3d).with_radii(0.02f).with_colors(
70 /// rerun::Rgba32(188, 77, 185)
71 /// )
72 /// );
73 ///
74 /// rec.log(
75 /// "ellipsoid",
76 /// rerun::Ellipsoids3D::from_centers_and_half_sizes(
77 /// {
78 /// {0.0f, 0.0f, 0.0f},
79 /// {0.0f, 0.0f, 0.0f},
80 /// },
81 /// {
82 /// {sigmas[0], sigmas[1], sigmas[2]},
83 /// {3.0f * sigmas[0], 3.0f * sigmas[1], 3.0f * sigmas[2]},
84 /// }
85 /// )
86 /// .with_colors({
87 /// rerun::Rgba32(255, 255, 0),
88 /// rerun::Rgba32(64, 64, 0),
89 /// })
90 /// );
91 /// }
92 /// ```
93 struct Ellipsoids3D {
94 /// For each ellipsoid, half of its size on its three axes.
95 ///
96 /// If all components are equal, then it is a sphere with that radius.
97 std::optional<ComponentBatch> half_sizes;
98
99 /// Optional center positions of the ellipsoids.
100 ///
101 /// If not specified, the centers will be at (0, 0, 0).
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 std::optional<ComponentBatch> rotation_axis_angles;
108
109 /// Rotations via quaternion.
110 ///
111 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
112 std::optional<ComponentBatch> quaternions;
113
114 /// Optional colors for the ellipsoids.
115 ///
116 /// Alpha channel is used for transparency for solid fill-mode.
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 /// Whether the text labels should be shown.
129 ///
130 /// If not set, labels will automatically appear when there is exactly one label for this entity
131 /// or the number of instances on this entity is under a certain threshold.
132 std::optional<ComponentBatch> show_labels;
133
134 /// Optional class ID for the ellipsoids.
135 ///
136 /// The class ID provides colors and labels if not specified explicitly.
137 std::optional<ComponentBatch> class_ids;
138
139 public:
140 /// The name of the archetype as used in `ComponentDescriptor`s.
141 static constexpr const char ArchetypeName[] = "rerun.archetypes.Ellipsoids3D";
142
143 /// `ComponentDescriptor` for the `half_sizes` field.
145 ArchetypeName, "Ellipsoids3D:half_sizes",
147 );
148 /// `ComponentDescriptor` for the `centers` field.
150 ArchetypeName, "Ellipsoids3D:centers",
152 );
153 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
155 ArchetypeName, "Ellipsoids3D:rotation_axis_angles",
157 );
158 /// `ComponentDescriptor` for the `quaternions` field.
160 ArchetypeName, "Ellipsoids3D:quaternions",
162 );
163 /// `ComponentDescriptor` for the `colors` field.
164 static constexpr auto Descriptor_colors = ComponentDescriptor(
166 );
167 /// `ComponentDescriptor` for the `line_radii` field.
169 ArchetypeName, "Ellipsoids3D:line_radii",
171 );
172 /// `ComponentDescriptor` for the `fill_mode` field.
174 ArchetypeName, "Ellipsoids3D:fill_mode",
176 );
177 /// `ComponentDescriptor` for the `labels` field.
178 static constexpr auto Descriptor_labels = ComponentDescriptor(
180 );
181 /// `ComponentDescriptor` for the `show_labels` field.
183 ArchetypeName, "Ellipsoids3D:show_labels",
185 );
186 /// `ComponentDescriptor` for the `class_ids` field.
188 ArchetypeName, "Ellipsoids3D:class_ids",
190 );
191
192 public: // START of extensions from ellipsoids3d_ext.cpp:
193 /// Creates new `Ellipsoids3D` that are spheres, with `half_sizes` created from radii.
194 //
195 // TODO(andreas): This should not take an std::vector.
196 static Ellipsoids3D from_radii(const std::vector<float>& sizes);
197
198 /// Creates new `Ellipsoids3D` that are spheres, with `half_sizes` and `centers` created
199 /// from centers and radii.
200 //
201 // TODO(andreas): This should not take an std::vector.
203 const std::vector<encodings::Vec3D>& centers, const std::vector<float>& radii
204 );
205
206 /// Creates new `Ellipsoids3D` with `half_sizes` centered around the local origin.
208 return Ellipsoids3D().with_half_sizes(std::move(half_sizes));
209 }
210
211 /// Creates new `Ellipsoids3D` with `centers` and `half_sizes`.
215 ) {
216 return Ellipsoids3D()
217 .with_half_sizes(std::move(half_sizes))
218 .with_centers(std::move(centers));
219 }
220
221 // END of extensions from ellipsoids3d_ext.cpp, start of generated code:
222
223 public:
224 Ellipsoids3D() = default;
225 Ellipsoids3D(Ellipsoids3D&& other) = default;
226 Ellipsoids3D(const Ellipsoids3D& other) = default;
227 Ellipsoids3D& operator=(const Ellipsoids3D& other) = default;
228 Ellipsoids3D& operator=(Ellipsoids3D&& other) = default;
229
230 /// Update only some specific fields of a `Ellipsoids3D`.
232 return Ellipsoids3D();
233 }
234
235 /// Clear all the fields of a `Ellipsoids3D`.
237
238 /// For each ellipsoid, half of its size on its three axes.
239 ///
240 /// If all components are equal, then it is a sphere with that radius.
242 ) && {
243 half_sizes =
244 ComponentBatch::from_loggable(_half_sizes, Descriptor_half_sizes).value_or_throw();
245 return std::move(*this);
246 }
247
248 /// Optional center positions of the ellipsoids.
249 ///
250 /// If not specified, the centers will be at (0, 0, 0).
252 centers = ComponentBatch::from_loggable(_centers, Descriptor_centers).value_or_throw();
253 return std::move(*this);
254 }
255
256 /// Rotations via axis + angle.
257 ///
258 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
260 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angles
261 ) && {
263 _rotation_axis_angles,
265 )
266 .value_or_throw();
267 return std::move(*this);
268 }
269
270 /// Rotations via quaternion.
271 ///
272 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
275 ) && {
277 .value_or_throw();
278 return std::move(*this);
279 }
280
281 /// Optional colors for the ellipsoids.
282 ///
283 /// Alpha channel is used for transparency for solid fill-mode.
285 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
286 return std::move(*this);
287 }
288
289 /// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
291 line_radii =
292 ComponentBatch::from_loggable(_line_radii, Descriptor_line_radii).value_or_throw();
293 return std::move(*this);
294 }
295
296 /// Optionally choose whether the ellipsoids are drawn with lines or solid.
298 fill_mode =
299 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
300 return std::move(*this);
301 }
302
303 /// This method makes it possible to pack multiple `fill_mode` in a single component batch.
304 ///
305 /// This only makes sense when used in conjunction with `columns`. `with_fill_mode` should
306 /// be used when logging a single row's worth of data.
308 ) && {
309 fill_mode =
310 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
311 return std::move(*this);
312 }
313
314 /// Optional text labels for the ellipsoids.
316 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
317 return std::move(*this);
318 }
319
320 /// Whether the text labels should be shown.
321 ///
322 /// If not set, labels will automatically appear when there is exactly one label for this entity
323 /// or the number of instances on this entity is under a certain threshold.
326 .value_or_throw();
327 return std::move(*this);
328 }
329
330 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
331 ///
332 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
333 /// be used when logging a single row's worth of data.
336 ) && {
338 .value_or_throw();
339 return std::move(*this);
340 }
341
342 /// Optional class ID for the ellipsoids.
343 ///
344 /// The class ID provides colors and labels if not specified explicitly.
346 class_ids =
347 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
348 return std::move(*this);
349 }
350
351 /// Partitions the component data into multiple sub-batches.
352 ///
353 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
354 /// instead, via `ComponentBatch::partitioned`.
355 ///
356 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
357 ///
358 /// The specified `lengths` must sum to the total length of the component batch.
360 return detail::partition_batches(
361 {&half_sizes,
362 &centers,
365 &colors,
366 &line_radii,
367 &fill_mode,
368 &labels,
370 &class_ids},
371 lengths_
372 )
373 .value_or_throw();
374 }
375
376 /// Partitions the component data into unit-length sub-batches.
377 ///
378 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
379 /// where `n` is automatically guessed.
381 return detail::partition_batches_of_unit_length({&half_sizes,
382 &centers,
385 &colors,
386 &line_radii,
387 &fill_mode,
388 &labels,
390 &class_ids})
391 .value_or_throw();
392 }
393 };
394
395} // namespace rerun::archetypes
396
397namespace rerun {
398 /// \private
399 template <typename T>
400 struct AsComponents;
401
402 /// \private
403 template <>
404 struct AsComponents<archetypes::Ellipsoids3D> {
405 /// Serialize all set component batches.
406 static Result<Collection<ComponentBatch>> as_batches(
407 const archetypes::Ellipsoids3D& archetype
408 ) {
409 return detail::collect_batches(
410 {&archetype.half_sizes,
411 &archetype.centers,
412 &archetype.rotation_axis_angles,
413 &archetype.quaternions,
414 &archetype.colors,
415 &archetype.line_radii,
416 &archetype.fill_mode,
417 &archetype.labels,
418 &archetype.show_labels,
419 &archetype.class_ids}
420 );
421 }
422 };
423} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:90
FillMode
Component: How a geometric shape is drawn and colored.
Definition fill_mode.hpp:24
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
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 ellipsoids or spheres.
Definition ellipsoids3d.hpp:93
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:241
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition ellipsoids3d.hpp:159
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition ellipsoids3d.hpp:359
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition ellipsoids3d.hpp:107
static Ellipsoids3D from_centers_and_radii(const std::vector< encodings::Vec3D > &centers, const std::vector< float > &radii)
Creates new Ellipsoids3D that are spheres, with half_sizes and centers created from centers and radii...
Ellipsoids3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class ID for the ellipsoids.
Definition ellipsoids3d.hpp:345
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:168
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition ellipsoids3d.hpp:154
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition ellipsoids3d.hpp:182
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition ellipsoids3d.hpp:164
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:231
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:307
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition ellipsoids3d.hpp:178
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:187
Ellipsoids3D with_rotation_axis_angles(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition ellipsoids3d.hpp:259
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition ellipsoids3d.hpp:380
static constexpr auto Descriptor_half_sizes
ComponentDescriptor for the half_sizes field.
Definition ellipsoids3d.hpp:144
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition ellipsoids3d.hpp:141
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) &&
Whether the text labels should be shown.
Definition ellipsoids3d.hpp:324
std::optional< ComponentBatch > half_sizes
For each ellipsoid, half of its size on its three axes.
Definition ellipsoids3d.hpp:97
Ellipsoids3D with_quaternions(const Collection< rerun::components::RotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition ellipsoids3d.hpp:273
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition ellipsoids3d.hpp:112
Ellipsoids3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the ellipsoids.
Definition ellipsoids3d.hpp:315
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:290
static Ellipsoids3D from_centers_and_half_sizes(Collection< components::Translation3D > centers, Collection< components::HalfSize3D > half_sizes)
Creates new Ellipsoids3D with centers and half_sizes.
Definition ellipsoids3d.hpp:212
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:137
Ellipsoids3D with_fill_mode(const rerun::components::FillMode &_fill_mode) &&
Optionally choose whether the ellipsoids are drawn with lines or solid.
Definition ellipsoids3d.hpp:297
Ellipsoids3D with_centers(const Collection< rerun::components::Translation3D > &_centers) &&
Optional center positions of the ellipsoids.
Definition ellipsoids3d.hpp:251
static constexpr auto Descriptor_fill_mode
ComponentDescriptor for the fill_mode field.
Definition ellipsoids3d.hpp:173
static Ellipsoids3D from_half_sizes(Collection< components::HalfSize3D > half_sizes)
Creates new Ellipsoids3D with half_sizes centered around the local origin.
Definition ellipsoids3d.hpp:207
static constexpr auto Descriptor_centers
ComponentDescriptor for the centers field.
Definition ellipsoids3d.hpp:149
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
Whether the text labels should be shown.
Definition ellipsoids3d.hpp:132
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:334
Ellipsoids3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the ellipsoids.
Definition ellipsoids3d.hpp:284
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18