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_sdk_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/radius.hpp"
14#include "../components/rotation_axis_angle.hpp"
15#include "../components/rotation_quat.hpp"
16#include "../components/show_labels.hpp"
17#include "../components/text.hpp"
18#include "../components/translation3d.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(int argc, char* argv[]) {
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(
69 /// rerun::Rgba32(188, 77, 185)
70 /// )
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 std::optional<ComponentBatch> centers;
102
103 /// Rotations via axis + angle.
104 ///
105 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
106 std::optional<ComponentBatch> rotation_axis_angles;
107
108 /// Rotations via quaternion.
109 ///
110 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
111 std::optional<ComponentBatch> quaternions;
112
113 /// Optional colors for the ellipsoids.
114 ///
115 /// Alpha channel is used for transparency for solid fill-mode.
116 std::optional<ComponentBatch> colors;
117
118 /// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
119 std::optional<ComponentBatch> line_radii;
120
121 /// Optionally choose whether the ellipsoids are drawn with lines or solid.
122 std::optional<ComponentBatch> fill_mode;
123
124 /// Optional text labels for the ellipsoids.
125 std::optional<ComponentBatch> labels;
126
127 /// Whether the text labels should be shown.
128 ///
129 /// If not set, labels will automatically appear when there is exactly one label for this entity
130 /// or the number of instances on this entity is under a certain threshold.
131 std::optional<ComponentBatch> show_labels;
132
133 /// Optional class ID for the ellipsoids.
134 ///
135 /// The class ID provides colors and labels if not specified explicitly.
136 std::optional<ComponentBatch> class_ids;
137
138 public:
139 /// The name of the archetype as used in `ComponentDescriptor`s.
140 static constexpr const char ArchetypeName[] = "rerun.archetypes.Ellipsoids3D";
141
142 /// `ComponentDescriptor` for the `half_sizes` field.
144 ArchetypeName, "Ellipsoids3D:half_sizes",
146 );
147 /// `ComponentDescriptor` for the `centers` field.
149 ArchetypeName, "Ellipsoids3D:centers",
151 );
152 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
154 ArchetypeName, "Ellipsoids3D:rotation_axis_angles",
156 );
157 /// `ComponentDescriptor` for the `quaternions` field.
159 ArchetypeName, "Ellipsoids3D:quaternions",
161 );
162 /// `ComponentDescriptor` for the `colors` field.
163 static constexpr auto Descriptor_colors = ComponentDescriptor(
165 );
166 /// `ComponentDescriptor` for the `line_radii` field.
168 ArchetypeName, "Ellipsoids3D:line_radii",
170 );
171 /// `ComponentDescriptor` for the `fill_mode` field.
173 ArchetypeName, "Ellipsoids3D:fill_mode",
175 );
176 /// `ComponentDescriptor` for the `labels` field.
177 static constexpr auto Descriptor_labels = ComponentDescriptor(
179 );
180 /// `ComponentDescriptor` for the `show_labels` field.
182 ArchetypeName, "Ellipsoids3D:show_labels",
184 );
185 /// `ComponentDescriptor` for the `class_ids` field.
187 ArchetypeName, "Ellipsoids3D:class_ids",
189 );
190
191 public: // START of extensions from ellipsoids3d_ext.cpp:
192 /// Creates new `Ellipsoids3D` that are spheres, with `half_sizes` created from radii.
193 //
194 // TODO(andreas): This should not take an std::vector.
195 static Ellipsoids3D from_radii(const std::vector<float>& sizes);
196
197 /// Creates new `Ellipsoids3D` that are spheres, with `half_sizes` and `centers` created
198 /// from centers and radii.
199 //
200 // TODO(andreas): This should not take an std::vector.
202 const std::vector<datatypes::Vec3D>& centers, const std::vector<float>& radii
203 );
204
205 /// Creates new `Ellipsoids3D` with `half_sizes` centered around the local origin.
207 return Ellipsoids3D().with_half_sizes(std::move(half_sizes));
208 }
209
210 /// Creates new `Ellipsoids3D` with `centers` and `half_sizes`.
214 ) {
215 return Ellipsoids3D()
216 .with_half_sizes(std::move(half_sizes))
217 .with_centers(std::move(centers));
218 }
219
220 // END of extensions from ellipsoids3d_ext.cpp, start of generated code:
221
222 public:
223 Ellipsoids3D() = default;
224 Ellipsoids3D(Ellipsoids3D&& other) = default;
225 Ellipsoids3D(const Ellipsoids3D& other) = default;
226 Ellipsoids3D& operator=(const Ellipsoids3D& other) = default;
227 Ellipsoids3D& operator=(Ellipsoids3D&& other) = default;
228
229 /// Update only some specific fields of a `Ellipsoids3D`.
231 return Ellipsoids3D();
232 }
233
234 /// Clear all the fields of a `Ellipsoids3D`.
236
237 /// For each ellipsoid, half of its size on its three axes.
238 ///
239 /// If all components are equal, then it is a sphere with that radius.
241 ) && {
242 half_sizes =
243 ComponentBatch::from_loggable(_half_sizes, Descriptor_half_sizes).value_or_throw();
244 return std::move(*this);
245 }
246
247 /// Optional center positions of the ellipsoids.
248 ///
249 /// If not specified, the centers will be at (0, 0, 0).
251 centers = ComponentBatch::from_loggable(_centers, Descriptor_centers).value_or_throw();
252 return std::move(*this);
253 }
254
255 /// Rotations via axis + angle.
256 ///
257 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
259 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angles
260 ) && {
262 _rotation_axis_angles,
264 )
265 .value_or_throw();
266 return std::move(*this);
267 }
268
269 /// Rotations via quaternion.
270 ///
271 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
274 ) && {
276 .value_or_throw();
277 return std::move(*this);
278 }
279
280 /// Optional colors for the ellipsoids.
281 ///
282 /// Alpha channel is used for transparency for solid fill-mode.
284 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
285 return std::move(*this);
286 }
287
288 /// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
290 line_radii =
291 ComponentBatch::from_loggable(_line_radii, Descriptor_line_radii).value_or_throw();
292 return std::move(*this);
293 }
294
295 /// Optionally choose whether the ellipsoids are drawn with lines or solid.
297 fill_mode =
298 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
299 return std::move(*this);
300 }
301
302 /// This method makes it possible to pack multiple `fill_mode` in a single component batch.
303 ///
304 /// This only makes sense when used in conjunction with `columns`. `with_fill_mode` should
305 /// be used when logging a single row's worth of data.
307 ) && {
308 fill_mode =
309 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
310 return std::move(*this);
311 }
312
313 /// Optional text labels for the ellipsoids.
315 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
316 return std::move(*this);
317 }
318
319 /// Whether the text labels should be shown.
320 ///
321 /// If not set, labels will automatically appear when there is exactly one label for this entity
322 /// or the number of instances on this entity is under a certain threshold.
325 .value_or_throw();
326 return std::move(*this);
327 }
328
329 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
330 ///
331 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
332 /// be used when logging a single row's worth of data.
335 ) && {
337 .value_or_throw();
338 return std::move(*this);
339 }
340
341 /// Optional class ID for the ellipsoids.
342 ///
343 /// The class ID provides colors and labels if not specified explicitly.
345 class_ids =
346 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
347 return std::move(*this);
348 }
349
350 /// Partitions the component data into multiple sub-batches.
351 ///
352 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
353 /// instead, via `ComponentBatch::partitioned`.
354 ///
355 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
356 ///
357 /// The specified `lengths` must sum to the total length of the component batch.
359
360 /// Partitions the component data into unit-length sub-batches.
361 ///
362 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
363 /// where `n` is automatically guessed.
365 };
366
367} // namespace rerun::archetypes
368
369namespace rerun {
370 /// \private
371 template <typename T>
372 struct AsComponents;
373
374 /// \private
375 template <>
376 struct AsComponents<archetypes::Ellipsoids3D> {
377 /// Serialize all set component batches.
378 static Result<Collection<ComponentBatch>> as_batches(
379 const archetypes::Ellipsoids3D& archetype
380 );
381 };
382} // 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:87
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:92
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:240
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition ellipsoids3d.hpp:158
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:106
Ellipsoids3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class ID for the ellipsoids.
Definition ellipsoids3d.hpp:344
std::optional< ComponentBatch > centers
Optional center positions of the ellipsoids.
Definition ellipsoids3d.hpp:101
static constexpr auto Descriptor_line_radii
ComponentDescriptor for the line_radii field.
Definition ellipsoids3d.hpp:167
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition ellipsoids3d.hpp:153
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition ellipsoids3d.hpp:181
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition ellipsoids3d.hpp:163
std::optional< ComponentBatch > labels
Optional text labels for the ellipsoids.
Definition ellipsoids3d.hpp:125
static Ellipsoids3D update_fields()
Update only some specific fields of a Ellipsoids3D.
Definition ellipsoids3d.hpp:230
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:306
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition ellipsoids3d.hpp:177
std::optional< ComponentBatch > line_radii
Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
Definition ellipsoids3d.hpp:119
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition ellipsoids3d.hpp:186
Ellipsoids3D with_rotation_axis_angles(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition ellipsoids3d.hpp:258
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
static constexpr auto Descriptor_half_sizes
ComponentDescriptor for the half_sizes field.
Definition ellipsoids3d.hpp:143
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition ellipsoids3d.hpp:140
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:323
std::optional< ComponentBatch > half_sizes
For each ellipsoid, half of its size on its three axes.
Definition ellipsoids3d.hpp:96
Ellipsoids3D with_quaternions(const Collection< rerun::components::RotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition ellipsoids3d.hpp:272
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition ellipsoids3d.hpp:111
Ellipsoids3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the ellipsoids.
Definition ellipsoids3d.hpp:314
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:289
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:211
std::optional< ComponentBatch > colors
Optional colors for the ellipsoids.
Definition ellipsoids3d.hpp:116
std::optional< ComponentBatch > class_ids
Optional class ID for the ellipsoids.
Definition ellipsoids3d.hpp:136
Ellipsoids3D with_fill_mode(const rerun::components::FillMode &_fill_mode) &&
Optionally choose whether the ellipsoids are drawn with lines or solid.
Definition ellipsoids3d.hpp:296
Ellipsoids3D with_centers(const Collection< rerun::components::Translation3D > &_centers) &&
Optional center positions of the ellipsoids.
Definition ellipsoids3d.hpp:250
static constexpr auto Descriptor_fill_mode
ComponentDescriptor for the fill_mode field.
Definition ellipsoids3d.hpp:172
static Ellipsoids3D from_half_sizes(Collection< components::HalfSize3D > half_sizes)
Creates new Ellipsoids3D with half_sizes centered around the local origin.
Definition ellipsoids3d.hpp:206
static constexpr auto Descriptor_centers
ComponentDescriptor for the centers field.
Definition ellipsoids3d.hpp:148
std::optional< ComponentBatch > fill_mode
Optionally choose whether the ellipsoids are drawn with lines or solid.
Definition ellipsoids3d.hpp:122
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:131
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:333
Ellipsoids3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the ellipsoids.
Definition ellipsoids3d.hpp:283
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18