Rerun C++ SDK
Loading...
Searching...
No Matches
capsules3d.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/capsules3d.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/length.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 capsules; cylinders with hemispherical caps.
29 ///
30 /// Capsules are defined by two endpoints (the centers of their end cap spheres), which are located
31 /// at (0, 0, 0) and (0, 0, length), that is, extending along the positive direction of the Z axis.
32 /// Capsules in other orientations may be produced by applying a rotation to the entity or
33 /// instances.
34 ///
35 /// If there's more instance poses than lengths & radii, the last capsule's orientation will be repeated for the remaining poses.
36 /// Orienting and placing capsules forms a separate transform that is applied prior to `archetypes::InstancePoses3D` and `archetypes::Transform3D`.
37 ///
38 /// ## Example
39 ///
40 /// ### Batch of capsules
41 /// ![image](https://static.rerun.io/capsule3d_batch/6e6a4acafcf528359372147d7247f85d84434101/full.png)
42 ///
43 /// ```cpp
44 /// #include <rerun.hpp>
45 ///
46 /// int main(int argc, char* argv[]) {
47 /// const auto rec = rerun::RecordingStream("rerun_example_capsule3d_batch");
48 /// rec.spawn().exit_on_failure();
49 ///
50 /// rec.log(
51 /// "capsules",
52 /// rerun::Capsules3D::from_lengths_and_radii(
53 /// {0.0f, 2.0f, 4.0f, 6.0f, 8.0f},
54 /// {1.0f, 0.5f, 0.5f, 0.5f, 1.0f}
55 /// )
56 /// .with_colors({
57 /// rerun::Rgba32(255, 0, 0),
58 /// rerun::Rgba32(188, 188, 0),
59 /// rerun::Rgba32(0, 255, 0),
60 /// rerun::Rgba32(0, 188, 188),
61 /// rerun::Rgba32(0, 0, 255),
62 /// })
63 /// .with_translations({
64 /// {0.0f, 0.0f, 0.0f},
65 /// {2.0f, 0.0f, 0.0f},
66 /// {4.0f, 0.0f, 0.0f},
67 /// {6.0f, 0.0f, 0.0f},
68 /// {8.0f, 0.0f, 0.0f},
69 /// })
70 /// .with_rotation_axis_angles({
71 /// rerun::RotationAxisAngle(
72 /// {1.0f, 0.0f, 0.0f},
73 /// rerun::Angle::degrees(0.0)
74 /// ),
75 /// rerun::RotationAxisAngle(
76 /// {1.0f, 0.0f, 0.0f},
77 /// rerun::Angle::degrees(-22.5)
78 /// ),
79 /// rerun::RotationAxisAngle(
80 /// {1.0f, 0.0f, 0.0f},
81 /// rerun::Angle::degrees(-45.0)
82 /// ),
83 /// rerun::RotationAxisAngle(
84 /// {1.0f, 0.0f, 0.0f},
85 /// rerun::Angle::degrees(-67.5)
86 /// ),
87 /// rerun::RotationAxisAngle(
88 /// {1.0f, 0.0f, 0.0f},
89 /// rerun::Angle::degrees(-90.0)
90 /// ),
91 /// })
92 /// );
93 /// }
94 /// ```
95 struct Capsules3D {
96 /// Lengths of the capsules, defined as the distance between the centers of the endcaps.
97 std::optional<ComponentBatch> lengths;
98
99 /// Radii of the capsules.
100 std::optional<ComponentBatch> radii;
101
102 /// Optional translations of the capsules.
103 ///
104 /// If not specified, one end of each capsule will be at (0, 0, 0).
105 std::optional<ComponentBatch> translations;
106
107 /// Rotations via axis + angle.
108 ///
109 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
110 std::optional<ComponentBatch> rotation_axis_angles;
111
112 /// Rotations via quaternion.
113 ///
114 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
115 std::optional<ComponentBatch> quaternions;
116
117 /// Optional colors for the capsules.
118 ///
119 /// Alpha channel is used for transparency for solid fill-mode.
120 std::optional<ComponentBatch> colors;
121
122 /// Optional radii for the lines used when the cylinder is rendered as a wireframe.
123 std::optional<ComponentBatch> line_radii;
124
125 /// Optionally choose whether the cylinders are drawn with lines or solid.
126 std::optional<ComponentBatch> fill_mode;
127
128 /// Optional text labels for the capsules, which will be located at their centers.
129 std::optional<ComponentBatch> labels;
130
131 /// Whether the text labels should be shown.
132 ///
133 /// If not set, labels will automatically appear when there is exactly one label for this entity
134 /// or the number of instances on this entity is under a certain threshold.
135 std::optional<ComponentBatch> show_labels;
136
137 /// Optional class ID for the ellipsoids.
138 ///
139 /// The class ID provides colors and labels if not specified explicitly.
140 std::optional<ComponentBatch> class_ids;
141
142 public:
143 /// The name of the archetype as used in `ComponentDescriptor`s.
144 static constexpr const char ArchetypeName[] = "rerun.archetypes.Capsules3D";
145
146 /// `ComponentDescriptor` for the `lengths` field.
149 );
150 /// `ComponentDescriptor` for the `radii` field.
151 static constexpr auto Descriptor_radii = ComponentDescriptor(
153 );
154 /// `ComponentDescriptor` for the `translations` field.
156 ArchetypeName, "Capsules3D:translations",
158 );
159 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
161 ArchetypeName, "Capsules3D:rotation_axis_angles",
163 );
164 /// `ComponentDescriptor` for the `quaternions` field.
166 ArchetypeName, "Capsules3D:quaternions",
168 );
169 /// `ComponentDescriptor` for the `colors` field.
170 static constexpr auto Descriptor_colors = ComponentDescriptor(
172 );
173 /// `ComponentDescriptor` for the `line_radii` field.
175 ArchetypeName, "Capsules3D:line_radii",
177 );
178 /// `ComponentDescriptor` for the `fill_mode` field.
180 ArchetypeName, "Capsules3D:fill_mode",
182 );
183 /// `ComponentDescriptor` for the `labels` field.
184 static constexpr auto Descriptor_labels = ComponentDescriptor(
186 );
187 /// `ComponentDescriptor` for the `show_labels` field.
189 ArchetypeName, "Capsules3D:show_labels",
191 );
192 /// `ComponentDescriptor` for the `class_ids` field.
194 ArchetypeName, "Capsules3D:class_ids",
196 );
197
198 public: // START of extensions from capsules3d_ext.cpp:
199 /// Creates a new `Capsules3D` with the given axis-aligned lengths and radii.
200 ///
201 /// For multiple capsules, you should generally follow this with
202 /// `Capsules3D::with_translations()` and one of the rotation methods, in order to move them
203 /// apart from each other.
204 //
205 // TODO(andreas): This should not take an std::vector.
207 const std::vector<float>& lengths, const std::vector<float>& radii
208 ) {
209 return Capsules3D().with_lengths(std::move(lengths)).with_radii(std::move(radii));
210 }
211
212 /* TODO(kpreid): This should exist for parity with Rust, but actually implementing this
213 needs a bit of quaternion math.
214
215 /// Creates a new `Capsules3D` where each capsule extends between the given pairs of points.
216 //
217 // TODO(andreas): This should not take an std::vector.
218 //
219 static Capsules3D from_endpoints_and_radii(
220 const std::vector<encodings::Vec3D>& start_points,
221 const std::vector<encodings::Vec3D>& end_points,
222 const std::vector<float>& radii
223 );
224 */
225
226 // END of extensions from capsules3d_ext.cpp, start of generated code:
227
228 public:
229 Capsules3D() = default;
230 Capsules3D(Capsules3D&& other) = default;
231 Capsules3D(const Capsules3D& other) = default;
232 Capsules3D& operator=(const Capsules3D& other) = default;
233 Capsules3D& operator=(Capsules3D&& other) = default;
234
235 /// Update only some specific fields of a `Capsules3D`.
237 return Capsules3D();
238 }
239
240 /// Clear all the fields of a `Capsules3D`.
242
243 /// Lengths of the capsules, defined as the distance between the centers of the endcaps.
245 lengths = ComponentBatch::from_loggable(_lengths, Descriptor_lengths).value_or_throw();
246 return std::move(*this);
247 }
248
249 /// Radii of the capsules.
251 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
252 return std::move(*this);
253 }
254
255 /// Optional translations of the capsules.
256 ///
257 /// If not specified, one end of each capsule will be at (0, 0, 0).
260 ) && {
262 .value_or_throw();
263 return std::move(*this);
264 }
265
266 /// Rotations via axis + angle.
267 ///
268 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
270 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angles
271 ) && {
273 _rotation_axis_angles,
275 )
276 .value_or_throw();
277 return std::move(*this);
278 }
279
280 /// Rotations via quaternion.
281 ///
282 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
284 ) && {
286 .value_or_throw();
287 return std::move(*this);
288 }
289
290 /// Optional colors for the capsules.
291 ///
292 /// Alpha channel is used for transparency for solid fill-mode.
294 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
295 return std::move(*this);
296 }
297
298 /// Optional radii for the lines used when the cylinder is rendered as a wireframe.
300 line_radii =
301 ComponentBatch::from_loggable(_line_radii, Descriptor_line_radii).value_or_throw();
302 return std::move(*this);
303 }
304
305 /// Optionally choose whether the cylinders are drawn with lines or solid.
307 fill_mode =
308 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
309 return std::move(*this);
310 }
311
312 /// This method makes it possible to pack multiple `fill_mode` in a single component batch.
313 ///
314 /// This only makes sense when used in conjunction with `columns`. `with_fill_mode` should
315 /// be used when logging a single row's worth of data.
317 ) && {
318 fill_mode =
319 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
320 return std::move(*this);
321 }
322
323 /// Optional text labels for the capsules, which will be located at their centers.
325 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
326 return std::move(*this);
327 }
328
329 /// Whether the text labels should be shown.
330 ///
331 /// If not set, labels will automatically appear when there is exactly one label for this entity
332 /// or the number of instances on this entity is under a certain threshold.
335 .value_or_throw();
336 return std::move(*this);
337 }
338
339 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
340 ///
341 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
342 /// be used when logging a single row's worth of data.
345 ) && {
347 .value_or_throw();
348 return std::move(*this);
349 }
350
351 /// Optional class ID for the ellipsoids.
352 ///
353 /// The class ID provides colors and labels if not specified explicitly.
355 class_ids =
356 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
357 return std::move(*this);
358 }
359
360 /// Partitions the component data into multiple sub-batches.
361 ///
362 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
363 /// instead, via `ComponentBatch::partitioned`.
364 ///
365 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
366 ///
367 /// The specified `lengths` must sum to the total length of the component batch.
369 return detail::partition_batches(
370 {&lengths,
371 &radii,
375 &colors,
376 &line_radii,
377 &fill_mode,
378 &labels,
380 &class_ids},
381 lengths_
382 )
383 .value_or_throw();
384 }
385
386 /// Partitions the component data into unit-length sub-batches.
387 ///
388 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
389 /// where `n` is automatically guessed.
391 return detail::partition_batches_of_unit_length({&lengths,
392 &radii,
396 &colors,
397 &line_radii,
398 &fill_mode,
399 &labels,
401 &class_ids})
402 .value_or_throw();
403 }
404 };
405
406} // namespace rerun::archetypes
407
408namespace rerun {
409 /// \private
410 template <typename T>
411 struct AsComponents;
412
413 /// \private
414 template <>
415 struct AsComponents<archetypes::Capsules3D> {
416 /// Serialize all set component batches.
417 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Capsules3D& archetype
418 ) {
419 return detail::collect_batches(
420 {&archetype.lengths,
421 &archetype.radii,
422 &archetype.translations,
423 &archetype.rotation_axis_angles,
424 &archetype.quaternions,
425 &archetype.colors,
426 &archetype.line_radii,
427 &archetype.fill_mode,
428 &archetype.labels,
429 &archetype.show_labels,
430 &archetype.class_ids}
431 );
432 }
433 };
434} // 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 capsules; cylinders with hemispherical caps.
Definition capsules3d.hpp:95
std::optional< ComponentBatch > class_ids
Optional class ID for the ellipsoids.
Definition capsules3d.hpp:140
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition capsules3d.hpp:170
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition capsules3d.hpp:135
Capsules3D with_translations(const Collection< rerun::components::Translation3D > &_translations) &&
Optional translations of the capsules.
Definition capsules3d.hpp:258
static constexpr auto Descriptor_line_radii
ComponentDescriptor for the line_radii field.
Definition capsules3d.hpp:174
Capsules3D 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 capsules3d.hpp:316
Capsules3D with_fill_mode(const rerun::components::FillMode &_fill_mode) &&
Optionally choose whether the cylinders are drawn with lines or solid.
Definition capsules3d.hpp:306
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition capsules3d.hpp:184
Capsules3D with_rotation_axis_angles(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition capsules3d.hpp:269
static Capsules3D from_lengths_and_radii(const std::vector< float > &lengths, const std::vector< float > &radii)
Creates a new Capsules3D with the given axis-aligned lengths and radii.
Definition capsules3d.hpp:206
static constexpr auto Descriptor_fill_mode
ComponentDescriptor for the fill_mode field.
Definition capsules3d.hpp:179
static Capsules3D clear_fields()
Clear all the fields of a Capsules3D.
std::optional< ComponentBatch > translations
Optional translations of the capsules.
Definition capsules3d.hpp:105
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition capsules3d.hpp:188
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition capsules3d.hpp:193
std::optional< ComponentBatch > lengths
Lengths of the capsules, defined as the distance between the centers of the endcaps.
Definition capsules3d.hpp:97
Capsules3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the capsules.
Definition capsules3d.hpp:293
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition capsules3d.hpp:368
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition capsules3d.hpp:160
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition capsules3d.hpp:390
static constexpr auto Descriptor_translations
ComponentDescriptor for the translations field.
Definition capsules3d.hpp:155
std::optional< ComponentBatch > colors
Optional colors for the capsules.
Definition capsules3d.hpp:120
Capsules3D with_lengths(const Collection< rerun::components::Length > &_lengths) &&
Lengths of the capsules, defined as the distance between the centers of the endcaps.
Definition capsules3d.hpp:244
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition capsules3d.hpp:144
Capsules3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class ID for the ellipsoids.
Definition capsules3d.hpp:354
Capsules3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition capsules3d.hpp:333
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition capsules3d.hpp:115
Capsules3D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Radii of the capsules.
Definition capsules3d.hpp:250
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition capsules3d.hpp:110
std::optional< ComponentBatch > fill_mode
Optionally choose whether the cylinders are drawn with lines or solid.
Definition capsules3d.hpp:126
Capsules3D with_quaternions(const Collection< rerun::components::RotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition capsules3d.hpp:283
Capsules3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the capsules, which will be located at their centers.
Definition capsules3d.hpp:324
std::optional< ComponentBatch > radii
Radii of the capsules.
Definition capsules3d.hpp:100
std::optional< ComponentBatch > line_radii
Optional radii for the lines used when the cylinder is rendered as a wireframe.
Definition capsules3d.hpp:123
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition capsules3d.hpp:151
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition capsules3d.hpp:165
std::optional< ComponentBatch > labels
Optional text labels for the capsules, which will be located at their centers.
Definition capsules3d.hpp:129
static constexpr auto Descriptor_lengths
ComponentDescriptor for the lengths field.
Definition capsules3d.hpp:147
Capsules3D with_line_radii(const Collection< rerun::components::Radius > &_line_radii) &&
Optional radii for the lines used when the cylinder is rendered as a wireframe.
Definition capsules3d.hpp:299
static Capsules3D update_fields()
Update only some specific fields of a Capsules3D.
Definition capsules3d.hpp:236
Capsules3D 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 capsules3d.hpp:343
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18