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 /// 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() {
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(rerun::Rgba32(188, 77, 185))
70 /// );
71 ///
72 /// rec.log(
73 /// "ellipsoid",
74 /// rerun::Ellipsoids3D::from_centers_and_half_sizes(
75 /// {
76 /// {0.0f, 0.0f, 0.0f},
77 /// {0.0f, 0.0f, 0.0f},
78 /// },
79 /// {
80 /// {sigmas[0], sigmas[1], sigmas[2]},
81 /// {3.0f * sigmas[0], 3.0f * sigmas[1], 3.0f * sigmas[2]},
82 /// }
83 /// )
84 /// .with_colors({
85 /// rerun::Rgba32(255, 255, 0),
86 /// rerun::Rgba32(64, 64, 0),
87 /// })
88 /// );
89 /// }
90 /// ```
91 struct Ellipsoids3D {
92 /// For each ellipsoid, half of its size on its three axes.
93 ///
94 /// If all components are equal, then it is a sphere with that radius.
95 std::optional<ComponentBatch> half_sizes;
96
97 /// Optional center positions of the ellipsoids.
98 ///
99 /// If not specified, the centers will be at (0, 0, 0).
100 std::optional<ComponentBatch> centers;
101
102 /// Rotations via axis + angle.
103 ///
104 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
105 std::optional<ComponentBatch> rotation_axis_angles;
106
107 /// Rotations via quaternion.
108 ///
109 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
110 std::optional<ComponentBatch> quaternions;
111
112 /// Optional colors for the ellipsoids.
113 std::optional<ComponentBatch> colors;
114
115 /// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
116 std::optional<ComponentBatch> line_radii;
117
118 /// Optionally choose whether the ellipsoids are drawn with lines or solid.
119 std::optional<ComponentBatch> fill_mode;
120
121 /// Optional text labels for the ellipsoids.
122 std::optional<ComponentBatch> labels;
123
124 /// Whether the text labels should be shown.
125 ///
126 /// If not set, labels will automatically appear when there is exactly one label for this entity
127 /// or the number of instances on this entity is under a certain threshold.
128 std::optional<ComponentBatch> show_labels;
129
130 /// Optional class ID for the ellipsoids.
131 ///
132 /// The class ID provides colors and labels if not specified explicitly.
133 std::optional<ComponentBatch> class_ids;
134
135 public:
136 static constexpr const char IndicatorComponentName[] =
137 "rerun.components.Ellipsoids3DIndicator";
138
139 /// Indicator component, used to identify the archetype when converting to a list of components.
141 /// The name of the archetype as used in `ComponentDescriptor`s.
142 static constexpr const char ArchetypeName[] = "rerun.archetypes.Ellipsoids3D";
143
144 /// `ComponentDescriptor` for the `half_sizes` field.
146 ArchetypeName, "half_sizes",
148 );
149 /// `ComponentDescriptor` for the `centers` field.
151 ArchetypeName, "centers",
153 );
154 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
156 ArchetypeName, "rotation_axis_angles",
158 );
159 /// `ComponentDescriptor` for the `quaternions` field.
161 ArchetypeName, "quaternions",
163 );
164 /// `ComponentDescriptor` for the `colors` field.
165 static constexpr auto Descriptor_colors = ComponentDescriptor(
167 );
168 /// `ComponentDescriptor` for the `line_radii` field.
170 ArchetypeName, "line_radii",
172 );
173 /// `ComponentDescriptor` for the `fill_mode` field.
175 ArchetypeName, "fill_mode",
177 );
178 /// `ComponentDescriptor` for the `labels` field.
179 static constexpr auto Descriptor_labels = ComponentDescriptor(
181 );
182 /// `ComponentDescriptor` for the `show_labels` field.
184 ArchetypeName, "show_labels",
186 );
187 /// `ComponentDescriptor` for the `class_ids` field.
189 ArchetypeName, "class_ids",
191 );
192
193 public: // START of extensions from ellipsoids3d_ext.cpp:
194 /// Creates new `Ellipsoids3D` that are spheres, with `half_sizes` created from radii.
195 //
196 // TODO(andreas): This should not take an std::vector.
197 static Ellipsoids3D from_radii(const std::vector<float>& sizes);
198
199 /// Creates new `Ellipsoids3D` that are spheres, with `half_sizes` and `centers` created
200 /// from centers and radii.
201 //
202 // TODO(andreas): This should not take an std::vector.
204 const std::vector<datatypes::Vec3D>& centers, const std::vector<float>& radii
205 );
206
207 /// Creates new `Ellipsoids3D` with `half_sizes` centered around the local origin.
209 return Ellipsoids3D().with_half_sizes(std::move(half_sizes));
210 }
211
212 /// Creates new `Ellipsoids3D` with `centers` and `half_sizes`.
216 ) {
217 return Ellipsoids3D()
218 .with_half_sizes(std::move(half_sizes))
219 .with_centers(std::move(centers));
220 }
221
222 // END of extensions from ellipsoids3d_ext.cpp, start of generated code:
223
224 public:
225 Ellipsoids3D() = default;
226 Ellipsoids3D(Ellipsoids3D&& other) = default;
227 Ellipsoids3D(const Ellipsoids3D& other) = default;
228 Ellipsoids3D& operator=(const Ellipsoids3D& other) = default;
229 Ellipsoids3D& operator=(Ellipsoids3D&& other) = default;
230
231 /// Update only some specific fields of a `Ellipsoids3D`.
233 return Ellipsoids3D();
234 }
235
236 /// Clear all the fields of a `Ellipsoids3D`.
238
239 /// For each ellipsoid, half of its size on its three axes.
240 ///
241 /// If all components are equal, then it is a sphere with that radius.
243 ) && {
244 half_sizes =
245 ComponentBatch::from_loggable(_half_sizes, Descriptor_half_sizes).value_or_throw();
246 return std::move(*this);
247 }
248
249 /// Optional center positions of the ellipsoids.
250 ///
251 /// If not specified, the centers will be at (0, 0, 0).
253 ) && {
254 centers = ComponentBatch::from_loggable(_centers, Descriptor_centers).value_or_throw();
255 return std::move(*this);
256 }
257
258 /// Rotations via axis + angle.
259 ///
260 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
263 ) && {
265 _rotation_axis_angles,
267 )
268 .value_or_throw();
269 return std::move(*this);
270 }
271
272 /// Rotations via quaternion.
273 ///
274 /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
277 ) && {
279 .value_or_throw();
280 return std::move(*this);
281 }
282
283 /// Optional colors for the ellipsoids.
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
361 /// Partitions the component data into unit-length sub-batches.
362 ///
363 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
364 /// where `n` is automatically guessed.
366 };
367
368} // namespace rerun::archetypes
369
370namespace rerun {
371 /// \private
372 template <typename T>
373 struct AsComponents;
374
375 /// \private
376 template <>
377 struct AsComponents<archetypes::Ellipsoids3D> {
378 /// Serialize all set component batches.
379 static Result<Collection<ComponentBatch>> as_batches(
380 const archetypes::Ellipsoids3D& archetype
381 );
382 };
383} // 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)
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:91
Ellipsoids3D with_quaternions(const Collection< rerun::components::PoseRotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition ellipsoids3d.hpp:275
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:242
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition ellipsoids3d.hpp:160
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:105
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:100
static constexpr auto Descriptor_line_radii
ComponentDescriptor for the line_radii field.
Definition ellipsoids3d.hpp:169
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition ellipsoids3d.hpp:155
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition ellipsoids3d.hpp:183
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition ellipsoids3d.hpp:165
std::optional< ComponentBatch > labels
Optional text labels for the ellipsoids.
Definition ellipsoids3d.hpp:122
static Ellipsoids3D update_fields()
Update only some specific fields of a Ellipsoids3D.
Definition ellipsoids3d.hpp:232
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:179
std::optional< ComponentBatch > line_radii
Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
Definition ellipsoids3d.hpp:116
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition ellipsoids3d.hpp:188
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:252
static constexpr auto Descriptor_half_sizes
ComponentDescriptor for the half_sizes field.
Definition ellipsoids3d.hpp:145
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition ellipsoids3d.hpp:142
Ellipsoids3D with_rotation_axis_angles(const Collection< rerun::components::PoseRotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition ellipsoids3d.hpp:261
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:213
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:95
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition ellipsoids3d.hpp:110
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
std::optional< ComponentBatch > colors
Optional colors for the ellipsoids.
Definition ellipsoids3d.hpp:113
std::optional< ComponentBatch > class_ids
Optional class ID for the ellipsoids.
Definition ellipsoids3d.hpp:133
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
static constexpr auto Descriptor_fill_mode
ComponentDescriptor for the fill_mode field.
Definition ellipsoids3d.hpp:174
static Ellipsoids3D from_half_sizes(Collection< components::HalfSize3D > half_sizes)
Creates new Ellipsoids3D with half_sizes centered around the local origin.
Definition ellipsoids3d.hpp:208
static constexpr auto Descriptor_centers
ComponentDescriptor for the centers field.
Definition ellipsoids3d.hpp:150
std::optional< ComponentBatch > fill_mode
Optionally choose whether the ellipsoids are drawn with lines or solid.
Definition ellipsoids3d.hpp:119
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:128
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
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