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