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