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