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/length.hpp"
12#include "../components/pose_rotation_axis_angle.hpp"
13#include "../components/pose_rotation_quat.hpp"
14#include "../components/pose_translation3d.hpp"
15#include "../components/radius.hpp"
16#include "../components/show_labels.hpp"
17#include "../components/text.hpp"
18#include "../indicator_component.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 /// ## Example
35 ///
36 /// ### Batch of capsules
37 /// ![image](https://static.rerun.io/capsule3d_batch/6e6a4acafcf528359372147d7247f85d84434101/full.png)
38 ///
39 /// ```cpp
40 /// #include <rerun.hpp>
41 ///
42 /// int main() {
43 /// const auto rec = rerun::RecordingStream("rerun_example_capsule3d_batch");
44 /// rec.spawn().exit_on_failure();
45 ///
46 /// rec.log(
47 /// "capsules",
48 /// rerun::Capsules3D::from_lengths_and_radii(
49 /// {0.0f, 2.0f, 4.0f, 6.0f, 8.0f},
50 /// {1.0f, 0.5f, 0.5f, 0.5f, 1.0f}
51 /// )
52 /// .with_colors({
53 /// rerun::Rgba32(255, 0, 0),
54 /// rerun::Rgba32(188, 188, 0),
55 /// rerun::Rgba32(0, 255, 0),
56 /// rerun::Rgba32(0, 188, 188),
57 /// rerun::Rgba32(0, 0, 255),
58 /// })
59 /// .with_translations({
60 /// {0.0f, 0.0f, 0.0f},
61 /// {2.0f, 0.0f, 0.0f},
62 /// {4.0f, 0.0f, 0.0f},
63 /// {6.0f, 0.0f, 0.0f},
64 /// {8.0f, 0.0f, 0.0f},
65 /// })
66 /// .with_rotation_axis_angles({
67 /// rerun::RotationAxisAngle(),
68 /// rerun::RotationAxisAngle({1.0f, 0.0f, 0.0f}, rerun::Angle::degrees(-22.5)),
69 /// rerun::RotationAxisAngle({1.0f, 0.0f, 0.0f}, rerun::Angle::degrees(-45.0)),
70 /// rerun::RotationAxisAngle({1.0f, 0.0f, 0.0f}, rerun::Angle::degrees(-67.5)),
71 /// rerun::RotationAxisAngle({1.0f, 0.0f, 0.0f}, rerun::Angle::degrees(-90.0)),
72 /// })
73 /// );
74 /// }
75 /// ```
76 struct Capsules3D {
77 /// Lengths of the capsules, defined as the distance between the centers of the endcaps.
78 std::optional<ComponentBatch> lengths;
79
80 /// Radii of the capsules.
81 std::optional<ComponentBatch> radii;
82
83 /// Optional translations of the capsules.
84 ///
85 /// If not specified, one end of each capsule will be at (0, 0, 0).
86 /// Note that this uses a `components::PoseTranslation3D` which is also used by `archetypes::InstancePoses3D`.
87 std::optional<ComponentBatch> translations;
88
89 /// Rotations via axis + angle.
90 ///
91 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
92 /// Note that this uses a `components::PoseRotationAxisAngle` which is also used by `archetypes::InstancePoses3D`.
93 std::optional<ComponentBatch> rotation_axis_angles;
94
95 /// Rotations via quaternion.
96 ///
97 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
98 /// Note that this uses a `components::PoseRotationQuat` which is also used by `archetypes::InstancePoses3D`.
99 std::optional<ComponentBatch> quaternions;
100
101 /// Optional colors for the capsules.
102 std::optional<ComponentBatch> colors;
103
104 /// Optional text labels for the capsules, which will be located at their centers.
105 std::optional<ComponentBatch> labels;
106
107 /// Optional choice of whether the text labels should be shown by default.
108 std::optional<ComponentBatch> show_labels;
109
110 /// Optional class ID for the ellipsoids.
111 ///
112 /// The class ID provides colors and labels if not specified explicitly.
113 std::optional<ComponentBatch> class_ids;
114
115 public:
116 static constexpr const char IndicatorComponentName[] =
117 "rerun.components.Capsules3DIndicator";
118
119 /// Indicator component, used to identify the archetype when converting to a list of components.
121 /// The name of the archetype as used in `ComponentDescriptor`s.
122 static constexpr const char ArchetypeName[] = "rerun.archetypes.Capsules3D";
123
124 /// `ComponentDescriptor` for the `lengths` field.
127 );
128 /// `ComponentDescriptor` for the `radii` field.
129 static constexpr auto Descriptor_radii = ComponentDescriptor(
131 );
132 /// `ComponentDescriptor` for the `translations` field.
134 ArchetypeName, "translations",
136 );
137 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
139 ArchetypeName, "rotation_axis_angles",
141 );
142 /// `ComponentDescriptor` for the `quaternions` field.
144 ArchetypeName, "quaternions",
146 );
147 /// `ComponentDescriptor` for the `colors` field.
148 static constexpr auto Descriptor_colors = ComponentDescriptor(
150 );
151 /// `ComponentDescriptor` for the `labels` field.
152 static constexpr auto Descriptor_labels = ComponentDescriptor(
154 );
155 /// `ComponentDescriptor` for the `show_labels` field.
157 ArchetypeName, "show_labels",
159 );
160 /// `ComponentDescriptor` for the `class_ids` field.
162 ArchetypeName, "class_ids",
164 );
165
166 public: // START of extensions from capsules3d_ext.cpp:
167 /// Creates a new `Capsules3D` with the given axis-aligned lengths and radii.
168 ///
169 /// For multiple capsules, you should generally follow this with
170 /// `Capsules3D::with_translations()` and one of the rotation methods, in order to move them
171 /// apart from each other.
172 //
173 // TODO(andreas): This should not take an std::vector.
175 const std::vector<float>& lengths, const std::vector<float>& radii
176 ) {
177 return Capsules3D().with_lengths(std::move(lengths)).with_radii(std::move(radii));
178 }
179
180 /* TODO(kpreid): This should exist for parity with Rust, but actually implementing this
181 needs a bit of quaternion math.
182
183 /// Creates a new `Capsules3D` where each capsule extends between the given pairs of points.
184 //
185 // TODO(andreas): This should not take an std::vector.
186 //
187 static Capsules3D from_endpoints_and_radii(
188 const std::vector<datatypes::Vec3D>& start_points,
189 const std::vector<datatypes::Vec3D>& end_points,
190 const std::vector<float>& radii
191 );
192 */
193
194 // END of extensions from capsules3d_ext.cpp, start of generated code:
195
196 public:
197 Capsules3D() = default;
198 Capsules3D(Capsules3D&& other) = default;
199 Capsules3D(const Capsules3D& other) = default;
200 Capsules3D& operator=(const Capsules3D& other) = default;
201 Capsules3D& operator=(Capsules3D&& other) = default;
202
203 /// Update only some specific fields of a `Capsules3D`.
205 return Capsules3D();
206 }
207
208 /// Clear all the fields of a `Capsules3D`.
210
211 /// Lengths of the capsules, defined as the distance between the centers of the endcaps.
213 lengths = ComponentBatch::from_loggable(_lengths, Descriptor_lengths).value_or_throw();
214 return std::move(*this);
215 }
216
217 /// Radii of the capsules.
219 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
220 return std::move(*this);
221 }
222
223 /// Optional translations of the capsules.
224 ///
225 /// If not specified, one end of each capsule will be at (0, 0, 0).
226 /// Note that this uses a `components::PoseTranslation3D` which is also used by `archetypes::InstancePoses3D`.
229 ) && {
231 .value_or_throw();
232 return std::move(*this);
233 }
234
235 /// Rotations via axis + angle.
236 ///
237 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
238 /// Note that this uses a `components::PoseRotationAxisAngle` which is also used by `archetypes::InstancePoses3D`.
241 ) && {
243 _rotation_axis_angles,
245 )
246 .value_or_throw();
247 return std::move(*this);
248 }
249
250 /// Rotations via quaternion.
251 ///
252 /// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
253 /// Note that this uses a `components::PoseRotationQuat` which is also used by `archetypes::InstancePoses3D`.
256 ) && {
258 .value_or_throw();
259 return std::move(*this);
260 }
261
262 /// Optional colors for the capsules.
264 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
265 return std::move(*this);
266 }
267
268 /// Optional text labels for the capsules, which will be located at their centers.
270 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
271 return std::move(*this);
272 }
273
274 /// Optional choice of whether the text labels should be shown by default.
277 .value_or_throw();
278 return std::move(*this);
279 }
280
281 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
282 ///
283 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
284 /// be used when logging a single row's worth of data.
287 ) && {
289 .value_or_throw();
290 return std::move(*this);
291 }
292
293 /// Optional class ID for the ellipsoids.
294 ///
295 /// The class ID provides colors and labels if not specified explicitly.
297 class_ids =
298 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
299 return std::move(*this);
300 }
301
302 /// Partitions the component data into multiple sub-batches.
303 ///
304 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
305 /// instead, via `ComponentBatch::partitioned`.
306 ///
307 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
308 ///
309 /// The specified `lengths` must sum to the total length of the component batch.
311
312 /// Partitions the component data into unit-length sub-batches.
313 ///
314 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
315 /// where `n` is automatically guessed.
317 };
318
319} // namespace rerun::archetypes
320
321namespace rerun {
322 /// \private
323 template <typename T>
324 struct AsComponents;
325
326 /// \private
327 template <>
328 struct AsComponents<archetypes::Capsules3D> {
329 /// Serialize all set component batches.
330 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Capsules3D& archetype
331 );
332 };
333} // 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
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=rerun::Loggable< T >::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 capsules; cylinders with hemispherical caps.
Definition capsules3d.hpp:76
std::optional< ComponentBatch > class_ids
Optional class ID for the ellipsoids.
Definition capsules3d.hpp:113
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition capsules3d.hpp:148
std::optional< ComponentBatch > show_labels
Optional choice of whether the text labels should be shown by default.
Definition capsules3d.hpp:108
Capsules3D with_translations(const Collection< rerun::components::PoseTranslation3D > &_translations) &&
Optional translations of the capsules.
Definition capsules3d.hpp:227
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition capsules3d.hpp:152
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:174
Capsules3D with_rotation_axis_angles(const Collection< rerun::components::PoseRotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition capsules3d.hpp:239
static Capsules3D clear_fields()
Clear all the fields of a Capsules3D.
std::optional< ComponentBatch > translations
Optional translations of the capsules.
Definition capsules3d.hpp:87
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition capsules3d.hpp:156
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition capsules3d.hpp:161
std::optional< ComponentBatch > lengths
Lengths of the capsules, defined as the distance between the centers of the endcaps.
Definition capsules3d.hpp:78
Capsules3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the capsules.
Definition capsules3d.hpp:263
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:138
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:133
std::optional< ComponentBatch > colors
Optional colors for the capsules.
Definition capsules3d.hpp:102
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:212
Capsules3D with_quaternions(const Collection< rerun::components::PoseRotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition capsules3d.hpp:254
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition capsules3d.hpp:122
Capsules3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class ID for the ellipsoids.
Definition capsules3d.hpp:296
Capsules3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Optional choice of whether the text labels should be shown by default.
Definition capsules3d.hpp:275
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:218
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition capsules3d.hpp:93
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:269
std::optional< ComponentBatch > radii
Radii of the capsules.
Definition capsules3d.hpp:81
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition capsules3d.hpp:129
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition capsules3d.hpp:143
std::optional< ComponentBatch > labels
Optional text labels for the capsules, which will be located at their centers.
Definition capsules3d.hpp:105
static constexpr auto Descriptor_lengths
ComponentDescriptor for the lengths field.
Definition capsules3d.hpp:125
static Capsules3D update_fields()
Update only some specific fields of a Capsules3D.
Definition capsules3d.hpp:204
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:285
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