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/store/re_types/definitions/rerun/archetypes/capsules3d.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/length.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 capsules; cylinders with hemispherical caps.
28 ///
29 /// Capsules are defined by two endpoints (the centers of their end cap spheres), which are located
30 /// at (0, 0, 0) and (0, 0, length), that is, extending along the positive direction of the Z axis.
31 /// Capsules in other orientations may be produced by applying a rotation to the entity or
32 /// instances.
33 ///
34 /// If there's more instance poses than lengths & radii, the last capsule's orientation will be repeated for the remaining poses.
35 /// Orienting and placing capsules forms a separate transform that is applied prior to `archetypes::InstancePoses3D` and `archetypes::Transform3D`.
36 ///
37 /// ## Example
38 ///
39 /// ### Batch of capsules
40 /// ![image](https://static.rerun.io/capsule3d_batch/6e6a4acafcf528359372147d7247f85d84434101/full.png)
41 ///
42 /// ```cpp
43 /// #include <rerun.hpp>
44 ///
45 /// int main() {
46 /// const auto rec = rerun::RecordingStream("rerun_example_capsule3d_batch");
47 /// rec.spawn().exit_on_failure();
48 ///
49 /// rec.log(
50 /// "capsules",
51 /// rerun::Capsules3D::from_lengths_and_radii(
52 /// {0.0f, 2.0f, 4.0f, 6.0f, 8.0f},
53 /// {1.0f, 0.5f, 0.5f, 0.5f, 1.0f}
54 /// )
55 /// .with_colors({
56 /// rerun::Rgba32(255, 0, 0),
57 /// rerun::Rgba32(188, 188, 0),
58 /// rerun::Rgba32(0, 255, 0),
59 /// rerun::Rgba32(0, 188, 188),
60 /// rerun::Rgba32(0, 0, 255),
61 /// })
62 /// .with_translations({
63 /// {0.0f, 0.0f, 0.0f},
64 /// {2.0f, 0.0f, 0.0f},
65 /// {4.0f, 0.0f, 0.0f},
66 /// {6.0f, 0.0f, 0.0f},
67 /// {8.0f, 0.0f, 0.0f},
68 /// })
69 /// .with_rotation_axis_angles({
70 /// rerun::RotationAxisAngle({1.0f, 0.0f, 0.0f}, rerun::Angle::degrees(0.0)),
71 /// rerun::RotationAxisAngle({1.0f, 0.0f, 0.0f}, rerun::Angle::degrees(-22.5)),
72 /// rerun::RotationAxisAngle({1.0f, 0.0f, 0.0f}, rerun::Angle::degrees(-45.0)),
73 /// rerun::RotationAxisAngle({1.0f, 0.0f, 0.0f}, rerun::Angle::degrees(-67.5)),
74 /// rerun::RotationAxisAngle({1.0f, 0.0f, 0.0f}, rerun::Angle::degrees(-90.0)),
75 /// })
76 /// );
77 /// }
78 /// ```
79 struct Capsules3D {
80 /// Lengths of the capsules, defined as the distance between the centers of the endcaps.
81 std::optional<ComponentBatch> lengths;
82
83 /// Radii of the capsules.
84 std::optional<ComponentBatch> radii;
85
86 /// Optional translations of the capsules.
87 ///
88 /// If not specified, one end of each capsule will be at (0, 0, 0).
89 std::optional<ComponentBatch> translations;
90
91 /// Rotations via axis + angle.
92 ///
93 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
94 std::optional<ComponentBatch> rotation_axis_angles;
95
96 /// Rotations via quaternion.
97 ///
98 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
99 std::optional<ComponentBatch> quaternions;
100
101 /// Optional colors for the capsules.
102 ///
103 /// Alpha channel is used for transparency for solid fill-mode.
104 std::optional<ComponentBatch> colors;
105
106 /// Optional radii for the lines used when the cylinder is rendered as a wireframe.
107 std::optional<ComponentBatch> line_radii;
108
109 /// Optionally choose whether the cylinders are drawn with lines or solid.
110 std::optional<ComponentBatch> fill_mode;
111
112 /// Optional text labels for the capsules, which will be located at their centers.
113 std::optional<ComponentBatch> labels;
114
115 /// Whether the text labels should be shown.
116 ///
117 /// If not set, labels will automatically appear when there is exactly one label for this entity
118 /// or the number of instances on this entity is under a certain threshold.
119 std::optional<ComponentBatch> show_labels;
120
121 /// Optional class ID for the ellipsoids.
122 ///
123 /// The class ID provides colors and labels if not specified explicitly.
124 std::optional<ComponentBatch> class_ids;
125
126 public:
127 /// The name of the archetype as used in `ComponentDescriptor`s.
128 static constexpr const char ArchetypeName[] = "rerun.archetypes.Capsules3D";
129
130 /// `ComponentDescriptor` for the `lengths` field.
133 );
134 /// `ComponentDescriptor` for the `radii` field.
135 static constexpr auto Descriptor_radii = ComponentDescriptor(
137 );
138 /// `ComponentDescriptor` for the `translations` field.
140 ArchetypeName, "Capsules3D:translations",
142 );
143 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
145 ArchetypeName, "Capsules3D:rotation_axis_angles",
147 );
148 /// `ComponentDescriptor` for the `quaternions` field.
150 ArchetypeName, "Capsules3D:quaternions",
152 );
153 /// `ComponentDescriptor` for the `colors` field.
154 static constexpr auto Descriptor_colors = ComponentDescriptor(
156 );
157 /// `ComponentDescriptor` for the `line_radii` field.
159 ArchetypeName, "Capsules3D:line_radii",
161 );
162 /// `ComponentDescriptor` for the `fill_mode` field.
164 ArchetypeName, "Capsules3D:fill_mode",
166 );
167 /// `ComponentDescriptor` for the `labels` field.
168 static constexpr auto Descriptor_labels = ComponentDescriptor(
170 );
171 /// `ComponentDescriptor` for the `show_labels` field.
173 ArchetypeName, "Capsules3D:show_labels",
175 );
176 /// `ComponentDescriptor` for the `class_ids` field.
178 ArchetypeName, "Capsules3D:class_ids",
180 );
181
182 public: // START of extensions from capsules3d_ext.cpp:
183 /// Creates a new `Capsules3D` with the given axis-aligned lengths and radii.
184 ///
185 /// For multiple capsules, you should generally follow this with
186 /// `Capsules3D::with_translations()` and one of the rotation methods, in order to move them
187 /// apart from each other.
188 //
189 // TODO(andreas): This should not take an std::vector.
191 const std::vector<float>& lengths, const std::vector<float>& radii
192 ) {
193 return Capsules3D().with_lengths(std::move(lengths)).with_radii(std::move(radii));
194 }
195
196 /* TODO(kpreid): This should exist for parity with Rust, but actually implementing this
197 needs a bit of quaternion math.
198
199 /// Creates a new `Capsules3D` where each capsule extends between the given pairs of points.
200 //
201 // TODO(andreas): This should not take an std::vector.
202 //
203 static Capsules3D from_endpoints_and_radii(
204 const std::vector<datatypes::Vec3D>& start_points,
205 const std::vector<datatypes::Vec3D>& end_points,
206 const std::vector<float>& radii
207 );
208 */
209
210 // END of extensions from capsules3d_ext.cpp, start of generated code:
211
212 public:
213 Capsules3D() = default;
214 Capsules3D(Capsules3D&& other) = default;
215 Capsules3D(const Capsules3D& other) = default;
216 Capsules3D& operator=(const Capsules3D& other) = default;
217 Capsules3D& operator=(Capsules3D&& other) = default;
218
219 /// Update only some specific fields of a `Capsules3D`.
221 return Capsules3D();
222 }
223
224 /// Clear all the fields of a `Capsules3D`.
226
227 /// Lengths of the capsules, defined as the distance between the centers of the endcaps.
229 lengths = ComponentBatch::from_loggable(_lengths, Descriptor_lengths).value_or_throw();
230 return std::move(*this);
231 }
232
233 /// Radii of the capsules.
235 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
236 return std::move(*this);
237 }
238
239 /// Optional translations of the capsules.
240 ///
241 /// If not specified, one end of each capsule will be at (0, 0, 0).
244 ) && {
246 .value_or_throw();
247 return std::move(*this);
248 }
249
250 /// Rotations via axis + angle.
251 ///
252 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
255 ) && {
257 _rotation_axis_angles,
259 )
260 .value_or_throw();
261 return std::move(*this);
262 }
263
264 /// Rotations via quaternion.
265 ///
266 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
269 ) && {
271 .value_or_throw();
272 return std::move(*this);
273 }
274
275 /// Optional colors for the capsules.
276 ///
277 /// Alpha channel is used for transparency for solid fill-mode.
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 cylinder 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 cylinders 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 capsules, which will be located at their centers.
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::Capsules3D> {
372 /// Serialize all set component batches.
373 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Capsules3D& archetype
374 );
375 };
376} // 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 capsules; cylinders with hemispherical caps.
Definition capsules3d.hpp:79
std::optional< ComponentBatch > class_ids
Optional class ID for the ellipsoids.
Definition capsules3d.hpp:124
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition capsules3d.hpp:154
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition capsules3d.hpp:119
static constexpr auto Descriptor_line_radii
ComponentDescriptor for the line_radii field.
Definition capsules3d.hpp:158
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:301
Capsules3D with_translations(const Collection< rerun::components::PoseTranslation3D > &_translations) &&
Optional translations of the capsules.
Definition capsules3d.hpp:242
Capsules3D with_fill_mode(const rerun::components::FillMode &_fill_mode) &&
Optionally choose whether the cylinders are drawn with lines or solid.
Definition capsules3d.hpp:291
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition capsules3d.hpp:168
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:190
static constexpr auto Descriptor_fill_mode
ComponentDescriptor for the fill_mode field.
Definition capsules3d.hpp:163
Capsules3D with_rotation_axis_angles(const Collection< rerun::components::PoseRotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition capsules3d.hpp:253
static Capsules3D clear_fields()
Clear all the fields of a Capsules3D.
std::optional< ComponentBatch > translations
Optional translations of the capsules.
Definition capsules3d.hpp:89
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition capsules3d.hpp:172
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition capsules3d.hpp:177
std::optional< ComponentBatch > lengths
Lengths of the capsules, defined as the distance between the centers of the endcaps.
Definition capsules3d.hpp:81
Capsules3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the capsules.
Definition capsules3d.hpp:278
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition capsules3d.hpp:144
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
static constexpr auto Descriptor_translations
ComponentDescriptor for the translations field.
Definition capsules3d.hpp:139
std::optional< ComponentBatch > colors
Optional colors for the capsules.
Definition capsules3d.hpp:104
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:228
Capsules3D with_quaternions(const Collection< rerun::components::PoseRotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition capsules3d.hpp:267
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition capsules3d.hpp:128
Capsules3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class ID for the ellipsoids.
Definition capsules3d.hpp:339
Capsules3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition capsules3d.hpp:318
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition capsules3d.hpp:99
Capsules3D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Radii of the capsules.
Definition capsules3d.hpp:234
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition capsules3d.hpp:94
std::optional< ComponentBatch > fill_mode
Optionally choose whether the cylinders are drawn with lines or solid.
Definition capsules3d.hpp:110
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:309
std::optional< ComponentBatch > radii
Radii of the capsules.
Definition capsules3d.hpp:84
std::optional< ComponentBatch > line_radii
Optional radii for the lines used when the cylinder is rendered as a wireframe.
Definition capsules3d.hpp:107
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition capsules3d.hpp:135
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition capsules3d.hpp:149
std::optional< ComponentBatch > labels
Optional text labels for the capsules, which will be located at their centers.
Definition capsules3d.hpp:113
static constexpr auto Descriptor_lengths
ComponentDescriptor for the lengths field.
Definition capsules3d.hpp:131
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:284
static Capsules3D update_fields()
Update only some specific fields of a Capsules3D.
Definition capsules3d.hpp:220
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:328
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18