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_sdk_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/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 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(int argc, char* argv[]) {
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(
71 /// {1.0f, 0.0f, 0.0f},
72 /// rerun::Angle::degrees(0.0)
73 /// ),
74 /// rerun::RotationAxisAngle(
75 /// {1.0f, 0.0f, 0.0f},
76 /// rerun::Angle::degrees(-22.5)
77 /// ),
78 /// rerun::RotationAxisAngle(
79 /// {1.0f, 0.0f, 0.0f},
80 /// rerun::Angle::degrees(-45.0)
81 /// ),
82 /// rerun::RotationAxisAngle(
83 /// {1.0f, 0.0f, 0.0f},
84 /// rerun::Angle::degrees(-67.5)
85 /// ),
86 /// rerun::RotationAxisAngle(
87 /// {1.0f, 0.0f, 0.0f},
88 /// rerun::Angle::degrees(-90.0)
89 /// ),
90 /// })
91 /// );
92 /// }
93 /// ```
94 struct Capsules3D {
95 /// Lengths of the capsules, defined as the distance between the centers of the endcaps.
96 std::optional<ComponentBatch> lengths;
97
98 /// Radii of the capsules.
99 std::optional<ComponentBatch> radii;
100
101 /// Optional translations of the capsules.
102 ///
103 /// If not specified, one end of each capsule will be at (0, 0, 0).
104 std::optional<ComponentBatch> translations;
105
106 /// Rotations via axis + angle.
107 ///
108 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
109 std::optional<ComponentBatch> rotation_axis_angles;
110
111 /// Rotations via quaternion.
112 ///
113 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
114 std::optional<ComponentBatch> quaternions;
115
116 /// Optional colors for the capsules.
117 ///
118 /// Alpha channel is used for transparency for solid fill-mode.
119 std::optional<ComponentBatch> colors;
120
121 /// Optional radii for the lines used when the cylinder is rendered as a wireframe.
122 std::optional<ComponentBatch> line_radii;
123
124 /// Optionally choose whether the cylinders are drawn with lines or solid.
125 std::optional<ComponentBatch> fill_mode;
126
127 /// Optional text labels for the capsules, which will be located at their centers.
128 std::optional<ComponentBatch> labels;
129
130 /// Whether the text labels should be shown.
131 ///
132 /// If not set, labels will automatically appear when there is exactly one label for this entity
133 /// or the number of instances on this entity is under a certain threshold.
134 std::optional<ComponentBatch> show_labels;
135
136 /// Optional class ID for the ellipsoids.
137 ///
138 /// The class ID provides colors and labels if not specified explicitly.
139 std::optional<ComponentBatch> class_ids;
140
141 public:
142 /// The name of the archetype as used in `ComponentDescriptor`s.
143 static constexpr const char ArchetypeName[] = "rerun.archetypes.Capsules3D";
144
145 /// `ComponentDescriptor` for the `lengths` field.
148 );
149 /// `ComponentDescriptor` for the `radii` field.
150 static constexpr auto Descriptor_radii = ComponentDescriptor(
152 );
153 /// `ComponentDescriptor` for the `translations` field.
155 ArchetypeName, "Capsules3D:translations",
157 );
158 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
160 ArchetypeName, "Capsules3D:rotation_axis_angles",
162 );
163 /// `ComponentDescriptor` for the `quaternions` field.
165 ArchetypeName, "Capsules3D:quaternions",
167 );
168 /// `ComponentDescriptor` for the `colors` field.
169 static constexpr auto Descriptor_colors = ComponentDescriptor(
171 );
172 /// `ComponentDescriptor` for the `line_radii` field.
174 ArchetypeName, "Capsules3D:line_radii",
176 );
177 /// `ComponentDescriptor` for the `fill_mode` field.
179 ArchetypeName, "Capsules3D:fill_mode",
181 );
182 /// `ComponentDescriptor` for the `labels` field.
183 static constexpr auto Descriptor_labels = ComponentDescriptor(
185 );
186 /// `ComponentDescriptor` for the `show_labels` field.
188 ArchetypeName, "Capsules3D:show_labels",
190 );
191 /// `ComponentDescriptor` for the `class_ids` field.
193 ArchetypeName, "Capsules3D:class_ids",
195 );
196
197 public: // START of extensions from capsules3d_ext.cpp:
198 /// Creates a new `Capsules3D` with the given axis-aligned lengths and radii.
199 ///
200 /// For multiple capsules, you should generally follow this with
201 /// `Capsules3D::with_translations()` and one of the rotation methods, in order to move them
202 /// apart from each other.
203 //
204 // TODO(andreas): This should not take an std::vector.
206 const std::vector<float>& lengths, const std::vector<float>& radii
207 ) {
208 return Capsules3D().with_lengths(std::move(lengths)).with_radii(std::move(radii));
209 }
210
211 /* TODO(kpreid): This should exist for parity with Rust, but actually implementing this
212 needs a bit of quaternion math.
213
214 /// Creates a new `Capsules3D` where each capsule extends between the given pairs of points.
215 //
216 // TODO(andreas): This should not take an std::vector.
217 //
218 static Capsules3D from_endpoints_and_radii(
219 const std::vector<datatypes::Vec3D>& start_points,
220 const std::vector<datatypes::Vec3D>& end_points,
221 const std::vector<float>& radii
222 );
223 */
224
225 // END of extensions from capsules3d_ext.cpp, start of generated code:
226
227 public:
228 Capsules3D() = default;
229 Capsules3D(Capsules3D&& other) = default;
230 Capsules3D(const Capsules3D& other) = default;
231 Capsules3D& operator=(const Capsules3D& other) = default;
232 Capsules3D& operator=(Capsules3D&& other) = default;
233
234 /// Update only some specific fields of a `Capsules3D`.
236 return Capsules3D();
237 }
238
239 /// Clear all the fields of a `Capsules3D`.
241
242 /// Lengths of the capsules, defined as the distance between the centers of the endcaps.
244 lengths = ComponentBatch::from_loggable(_lengths, Descriptor_lengths).value_or_throw();
245 return std::move(*this);
246 }
247
248 /// Radii of the capsules.
250 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
251 return std::move(*this);
252 }
253
254 /// Optional translations of the capsules.
255 ///
256 /// If not specified, one end of each capsule will be at (0, 0, 0).
259 ) && {
261 .value_or_throw();
262 return std::move(*this);
263 }
264
265 /// Rotations via axis + angle.
266 ///
267 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
269 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angles
270 ) && {
272 _rotation_axis_angles,
274 )
275 .value_or_throw();
276 return std::move(*this);
277 }
278
279 /// Rotations via quaternion.
280 ///
281 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
283 ) && {
285 .value_or_throw();
286 return std::move(*this);
287 }
288
289 /// Optional colors for the capsules.
290 ///
291 /// Alpha channel is used for transparency for solid fill-mode.
293 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
294 return std::move(*this);
295 }
296
297 /// Optional radii for the lines used when the cylinder is rendered as a wireframe.
299 line_radii =
300 ComponentBatch::from_loggable(_line_radii, Descriptor_line_radii).value_or_throw();
301 return std::move(*this);
302 }
303
304 /// Optionally choose whether the cylinders are drawn with lines or solid.
306 fill_mode =
307 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
308 return std::move(*this);
309 }
310
311 /// This method makes it possible to pack multiple `fill_mode` in a single component batch.
312 ///
313 /// This only makes sense when used in conjunction with `columns`. `with_fill_mode` should
314 /// be used when logging a single row's worth of data.
316 ) && {
317 fill_mode =
318 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
319 return std::move(*this);
320 }
321
322 /// Optional text labels for the capsules, which will be located at their centers.
324 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
325 return std::move(*this);
326 }
327
328 /// Whether the text labels should be shown.
329 ///
330 /// If not set, labels will automatically appear when there is exactly one label for this entity
331 /// or the number of instances on this entity is under a certain threshold.
334 .value_or_throw();
335 return std::move(*this);
336 }
337
338 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
339 ///
340 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
341 /// be used when logging a single row's worth of data.
344 ) && {
346 .value_or_throw();
347 return std::move(*this);
348 }
349
350 /// Optional class ID for the ellipsoids.
351 ///
352 /// The class ID provides colors and labels if not specified explicitly.
354 class_ids =
355 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
356 return std::move(*this);
357 }
358
359 /// Partitions the component data into multiple sub-batches.
360 ///
361 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
362 /// instead, via `ComponentBatch::partitioned`.
363 ///
364 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
365 ///
366 /// The specified `lengths` must sum to the total length of the component batch.
368
369 /// Partitions the component data into unit-length sub-batches.
370 ///
371 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
372 /// where `n` is automatically guessed.
374 };
375
376} // namespace rerun::archetypes
377
378namespace rerun {
379 /// \private
380 template <typename T>
381 struct AsComponents;
382
383 /// \private
384 template <>
385 struct AsComponents<archetypes::Capsules3D> {
386 /// Serialize all set component batches.
387 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Capsules3D& archetype
388 );
389 };
390} // 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 capsules; cylinders with hemispherical caps.
Definition capsules3d.hpp:94
std::optional< ComponentBatch > class_ids
Optional class ID for the ellipsoids.
Definition capsules3d.hpp:139
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition capsules3d.hpp:169
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition capsules3d.hpp:134
Capsules3D with_translations(const Collection< rerun::components::Translation3D > &_translations) &&
Optional translations of the capsules.
Definition capsules3d.hpp:257
static constexpr auto Descriptor_line_radii
ComponentDescriptor for the line_radii field.
Definition capsules3d.hpp:173
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:315
Capsules3D with_fill_mode(const rerun::components::FillMode &_fill_mode) &&
Optionally choose whether the cylinders are drawn with lines or solid.
Definition capsules3d.hpp:305
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition capsules3d.hpp:183
Capsules3D with_rotation_axis_angles(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition capsules3d.hpp:268
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:205
static constexpr auto Descriptor_fill_mode
ComponentDescriptor for the fill_mode field.
Definition capsules3d.hpp:178
static Capsules3D clear_fields()
Clear all the fields of a Capsules3D.
std::optional< ComponentBatch > translations
Optional translations of the capsules.
Definition capsules3d.hpp:104
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition capsules3d.hpp:187
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition capsules3d.hpp:192
std::optional< ComponentBatch > lengths
Lengths of the capsules, defined as the distance between the centers of the endcaps.
Definition capsules3d.hpp:96
Capsules3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the capsules.
Definition capsules3d.hpp:292
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:159
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:154
std::optional< ComponentBatch > colors
Optional colors for the capsules.
Definition capsules3d.hpp:119
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:243
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition capsules3d.hpp:143
Capsules3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class ID for the ellipsoids.
Definition capsules3d.hpp:353
Capsules3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition capsules3d.hpp:332
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition capsules3d.hpp:114
Capsules3D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Radii of the capsules.
Definition capsules3d.hpp:249
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition capsules3d.hpp:109
std::optional< ComponentBatch > fill_mode
Optionally choose whether the cylinders are drawn with lines or solid.
Definition capsules3d.hpp:125
Capsules3D with_quaternions(const Collection< rerun::components::RotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition capsules3d.hpp:282
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:323
std::optional< ComponentBatch > radii
Radii of the capsules.
Definition capsules3d.hpp:99
std::optional< ComponentBatch > line_radii
Optional radii for the lines used when the cylinder is rendered as a wireframe.
Definition capsules3d.hpp:122
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition capsules3d.hpp:150
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition capsules3d.hpp:164
std::optional< ComponentBatch > labels
Optional text labels for the capsules, which will be located at their centers.
Definition capsules3d.hpp:128
static constexpr auto Descriptor_lengths
ComponentDescriptor for the lengths field.
Definition capsules3d.hpp:146
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:298
static Capsules3D update_fields()
Update only some specific fields of a Capsules3D.
Definition capsules3d.hpp:235
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:342
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18