Rerun C++ SDK
Loading...
Searching...
No Matches
boxes3d.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/boxes3d.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/half_size3d.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 boxes with half-extents and optional center, rotations, colors etc.
29 ///
30 /// If there's more instance poses than half sizes, the last box's orientation will be repeated for the remaining poses.
31 /// Orienting and placing boxes forms a separate transform that is applied prior to `archetypes::InstancePoses3D` and `archetypes::Transform3D`.
32 ///
33 /// ## Example
34 ///
35 /// ### Batch of 3D boxes
36 /// ![image](https://static.rerun.io/box3d_batch/5aac5b5d29c9f2ecd572c93f6970fcec17f4984b/full.png)
37 ///
38 /// ```cpp
39 /// #include <rerun.hpp>
40 ///
41 /// int main(int argc, char* argv[]) {
42 /// const auto rec = rerun::RecordingStream("rerun_example_box3d_batch");
43 /// rec.spawn().exit_on_failure();
44 ///
45 /// rec.log(
46 /// "batch",
47 /// rerun::Boxes3D::from_centers_and_half_sizes(
48 /// {{2.0f, 0.0f, 0.0f}, {-2.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 2.0f}},
49 /// {{2.0f, 2.0f, 1.0f}, {1.0f, 1.0f, 0.5f}, {2.0f, 0.5f, 1.0f}}
50 /// )
51 /// .with_quaternions({
52 /// rerun::Quaternion::IDENTITY,
53 /// // 45 degrees around Z
54 /// rerun::Quaternion::from_xyzw(0.0f, 0.0f, 0.382683f, 0.923880f),
55 /// })
56 /// .with_radii({0.025f})
57 /// .with_colors({
58 /// rerun::Rgba32(255, 0, 0),
59 /// rerun::Rgba32(0, 255, 0),
60 /// rerun::Rgba32(0, 0, 255),
61 /// })
62 /// .with_fill_mode(rerun::FillMode::Solid)
63 /// .with_labels({"red", "green", "blue"})
64 /// );
65 /// }
66 /// ```
67 struct Boxes3D {
68 /// All half-extents that make up the batch of boxes.
69 std::optional<ComponentBatch> half_sizes;
70
71 /// Optional center positions of the boxes.
72 ///
73 /// If not specified, the centers will be at (0, 0, 0).
74 std::optional<ComponentBatch> centers;
75
76 /// Rotations via axis + angle.
77 ///
78 /// If no rotation is specified, the axes of the boxes align with the axes of the local coordinate system.
79 std::optional<ComponentBatch> rotation_axis_angles;
80
81 /// Rotations via quaternion.
82 ///
83 /// If no rotation is specified, the axes of the boxes align with the axes of the local coordinate system.
84 std::optional<ComponentBatch> quaternions;
85
86 /// Optional colors for the boxes.
87 ///
88 /// Alpha channel is used for transparency for solid fill-mode.
89 std::optional<ComponentBatch> colors;
90
91 /// Optional radii for the lines that make up the boxes.
92 std::optional<ComponentBatch> radii;
93
94 /// Optionally choose whether the boxes are drawn with lines or solid.
95 std::optional<ComponentBatch> fill_mode;
96
97 /// Optional text labels for the boxes.
98 ///
99 /// If there's a single label present, it will be placed at the center of the entity.
100 /// Otherwise, each instance will have its own label.
101 std::optional<ComponentBatch> labels;
102
103 /// Whether the text labels should be shown.
104 ///
105 /// If not set, labels will automatically appear when there is exactly one label for this entity
106 /// or the number of instances on this entity is under a certain threshold.
107 std::optional<ComponentBatch> show_labels;
108
109 /// Optional `components::ClassId`s for the boxes.
110 ///
111 /// The `components::ClassId` provides colors and labels if not specified explicitly.
112 std::optional<ComponentBatch> class_ids;
113
114 public:
115 /// The name of the archetype as used in `ComponentDescriptor`s.
116 static constexpr const char ArchetypeName[] = "rerun.archetypes.Boxes3D";
117
118 /// `ComponentDescriptor` for the `half_sizes` field.
120 ArchetypeName, "Boxes3D:half_sizes",
122 );
123 /// `ComponentDescriptor` for the `centers` field.
125 ArchetypeName, "Boxes3D:centers",
127 );
128 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
130 ArchetypeName, "Boxes3D:rotation_axis_angles",
132 );
133 /// `ComponentDescriptor` for the `quaternions` field.
135 ArchetypeName, "Boxes3D:quaternions",
137 );
138 /// `ComponentDescriptor` for the `colors` field.
139 static constexpr auto Descriptor_colors = ComponentDescriptor(
141 );
142 /// `ComponentDescriptor` for the `radii` field.
143 static constexpr auto Descriptor_radii = ComponentDescriptor(
145 );
146 /// `ComponentDescriptor` for the `fill_mode` field.
149 );
150 /// `ComponentDescriptor` for the `labels` field.
151 static constexpr auto Descriptor_labels = ComponentDescriptor(
153 );
154 /// `ComponentDescriptor` for the `show_labels` field.
156 ArchetypeName, "Boxes3D:show_labels",
158 );
159 /// `ComponentDescriptor` for the `class_ids` field.
162 );
163
164 public: // START of extensions from boxes3d_ext.cpp:
165 /// Creates new `Boxes3D` with `half_sizes` centered around the local origin.
167 return Boxes3D().with_half_sizes(std::move(half_sizes));
168 }
169
170 /// Creates new `Boxes3D` with `centers` and `half_sizes`.
174 ) {
175 return Boxes3D()
176 .with_half_sizes(std::move(half_sizes))
177 .with_centers(std::move(centers));
178 }
179
180 /// Creates new `Boxes3D` with `half_sizes` created from (full) sizes.
181 ///
182 /// TODO(#3285): Does *not* preserve data as-is and instead creates half-sizes from the
183 /// input data.
184 /// TODO(andreas): This should not take an std::vector.
185 static Boxes3D from_sizes(const std::vector<encodings::Vec3D>& sizes);
186
187 /// Creates new `Boxes3D` with `centers` and `half_sizes` created from centers and (full)
188 /// sizes.
189 ///
190 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
191 /// from the input data.
192 /// TODO(andreas): This should not take an std::vector.
195 const std::vector<encodings::Vec3D>& sizes
196 ) {
197 return from_sizes(std::move(sizes)).with_centers(std::move(centers));
198 }
199
200 /// Creates new `Boxes3D` with `half_sizes` and `centers` created from minimums and (full)
201 /// sizes.
202 ///
203 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
204 /// from the input data.
205 /// TODO(andreas): This should not take an std::vector.
207 const std::vector<encodings::Vec3D>& mins, const std::vector<encodings::Vec3D>& sizes
208 );
209
210 // END of extensions from boxes3d_ext.cpp, start of generated code:
211
212 public:
213 Boxes3D() = default;
214 Boxes3D(Boxes3D&& other) = default;
215 Boxes3D(const Boxes3D& other) = default;
216 Boxes3D& operator=(const Boxes3D& other) = default;
217 Boxes3D& operator=(Boxes3D&& other) = default;
218
219 /// Update only some specific fields of a `Boxes3D`.
221 return Boxes3D();
222 }
223
224 /// Clear all the fields of a `Boxes3D`.
226
227 /// All half-extents that make up the batch of boxes.
229 half_sizes =
230 ComponentBatch::from_loggable(_half_sizes, Descriptor_half_sizes).value_or_throw();
231 return std::move(*this);
232 }
233
234 /// Optional center positions of the boxes.
235 ///
236 /// If not specified, the centers will be at (0, 0, 0).
238 centers = ComponentBatch::from_loggable(_centers, Descriptor_centers).value_or_throw();
239 return std::move(*this);
240 }
241
242 /// Rotations via axis + angle.
243 ///
244 /// If no rotation is specified, the axes of the boxes align with the axes of the local coordinate system.
246 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angles
247 ) && {
249 _rotation_axis_angles,
251 )
252 .value_or_throw();
253 return std::move(*this);
254 }
255
256 /// Rotations via quaternion.
257 ///
258 /// If no rotation is specified, the axes of the boxes align with the axes of the local coordinate system.
260 ) && {
262 .value_or_throw();
263 return std::move(*this);
264 }
265
266 /// Optional colors for the boxes.
267 ///
268 /// Alpha channel is used for transparency for solid fill-mode.
270 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
271 return std::move(*this);
272 }
273
274 /// Optional radii for the lines that make up the boxes.
276 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
277 return std::move(*this);
278 }
279
280 /// Optionally choose whether the boxes are drawn with lines or solid.
282 fill_mode =
283 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
284 return std::move(*this);
285 }
286
287 /// This method makes it possible to pack multiple `fill_mode` in a single component batch.
288 ///
289 /// This only makes sense when used in conjunction with `columns`. `with_fill_mode` should
290 /// be used when logging a single row's worth of data.
292 fill_mode =
293 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
294 return std::move(*this);
295 }
296
297 /// Optional text labels for the boxes.
298 ///
299 /// If there's a single label present, it will be placed at the center of the entity.
300 /// Otherwise, each instance will have its own label.
302 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
303 return std::move(*this);
304 }
305
306 /// Whether the text labels should be shown.
307 ///
308 /// If not set, labels will automatically appear when there is exactly one label for this entity
309 /// or the number of instances on this entity is under a certain threshold.
312 .value_or_throw();
313 return std::move(*this);
314 }
315
316 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
317 ///
318 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
319 /// be used when logging a single row's worth of data.
321 ) && {
323 .value_or_throw();
324 return std::move(*this);
325 }
326
327 /// Optional `components::ClassId`s for the boxes.
328 ///
329 /// The `components::ClassId` provides colors and labels if not specified explicitly.
331 class_ids =
332 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
333 return std::move(*this);
334 }
335
336 /// Partitions the component data into multiple sub-batches.
337 ///
338 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
339 /// instead, via `ComponentBatch::partitioned`.
340 ///
341 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
342 ///
343 /// The specified `lengths` must sum to the total length of the component batch.
345 return detail::partition_batches(
346 {&half_sizes,
347 &centers,
350 &colors,
351 &radii,
352 &fill_mode,
353 &labels,
355 &class_ids},
356 lengths_
357 )
358 .value_or_throw();
359 }
360
361 /// Partitions the component data into unit-length sub-batches.
362 ///
363 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
364 /// where `n` is automatically guessed.
366 return detail::partition_batches_of_unit_length({&half_sizes,
367 &centers,
370 &colors,
371 &radii,
372 &fill_mode,
373 &labels,
375 &class_ids})
376 .value_or_throw();
377 }
378 };
379
380} // namespace rerun::archetypes
381
382namespace rerun {
383 /// \private
384 template <typename T>
385 struct AsComponents;
386
387 /// \private
388 template <>
389 struct AsComponents<archetypes::Boxes3D> {
390 /// Serialize all set component batches.
391 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Boxes3D& archetype) {
392 return detail::collect_batches(
393 {&archetype.half_sizes,
394 &archetype.centers,
395 &archetype.rotation_axis_angles,
396 &archetype.quaternions,
397 &archetype.colors,
398 &archetype.radii,
399 &archetype.fill_mode,
400 &archetype.labels,
401 &archetype.show_labels,
402 &archetype.class_ids}
403 );
404 }
405 };
406} // 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 boxes with half-extents and optional center, rotations, colors etc.
Definition boxes3d.hpp:67
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition boxes3d.hpp:160
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition boxes3d.hpp:143
static Boxes3D from_centers_and_sizes(Collection< components::Translation3D > centers, const std::vector< encodings::Vec3D > &sizes)
Creates new Boxes3D with centers and half_sizes created from centers and (full) sizes.
Definition boxes3d.hpp:193
Boxes3D 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 boxes3d.hpp:291
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition boxes3d.hpp:139
Boxes3D with_centers(const Collection< rerun::components::Translation3D > &_centers) &&
Optional center positions of the boxes.
Definition boxes3d.hpp:237
std::optional< ComponentBatch > labels
Optional text labels for the boxes.
Definition boxes3d.hpp:101
static Boxes3D from_half_sizes(Collection< components::HalfSize3D > half_sizes)
Creates new Boxes3D with half_sizes centered around the local origin.
Definition boxes3d.hpp:166
std::optional< ComponentBatch > half_sizes
All half-extents that make up the batch of boxes.
Definition boxes3d.hpp:69
static constexpr auto Descriptor_fill_mode
ComponentDescriptor for the fill_mode field.
Definition boxes3d.hpp:147
static constexpr auto Descriptor_half_sizes
ComponentDescriptor for the half_sizes field.
Definition boxes3d.hpp:119
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition boxes3d.hpp:116
Boxes3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the boxes.
Definition boxes3d.hpp:269
Boxes3D with_half_sizes(const Collection< rerun::components::HalfSize3D > &_half_sizes) &&
All half-extents that make up the batch of boxes.
Definition boxes3d.hpp:228
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition boxes3d.hpp:107
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition boxes3d.hpp:134
std::optional< ComponentBatch > centers
Optional center positions of the boxes.
Definition boxes3d.hpp:74
static Boxes3D from_centers_and_half_sizes(Collection< components::Translation3D > centers, Collection< components::HalfSize3D > half_sizes)
Creates new Boxes3D with centers and half_sizes.
Definition boxes3d.hpp:171
static Boxes3D from_sizes(const std::vector< encodings::Vec3D > &sizes)
Creates new Boxes3D with half_sizes created from (full) sizes.
std::optional< ComponentBatch > fill_mode
Optionally choose whether the boxes are drawn with lines or solid.
Definition boxes3d.hpp:95
Boxes3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition boxes3d.hpp:310
Boxes3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional components::ClassIds for the boxes.
Definition boxes3d.hpp:330
Boxes3D 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 boxes3d.hpp:320
std::optional< ComponentBatch > quaternions
Rotations via quaternion.
Definition boxes3d.hpp:84
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition boxes3d.hpp:155
static Boxes3D from_mins_and_sizes(const std::vector< encodings::Vec3D > &mins, const std::vector< encodings::Vec3D > &sizes)
Creates new Boxes3D with half_sizes and centers created from minimums and (full) sizes.
std::optional< ComponentBatch > class_ids
Optional components::ClassIds for the boxes.
Definition boxes3d.hpp:112
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition boxes3d.hpp:79
Boxes3D with_quaternions(const Collection< rerun::components::RotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition boxes3d.hpp:259
Boxes3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the boxes.
Definition boxes3d.hpp:301
std::optional< ComponentBatch > colors
Optional colors for the boxes.
Definition boxes3d.hpp:89
Boxes3D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the lines that make up the boxes.
Definition boxes3d.hpp:275
static Boxes3D update_fields()
Update only some specific fields of a Boxes3D.
Definition boxes3d.hpp:220
static Boxes3D clear_fields()
Clear all the fields of a Boxes3D.
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition boxes3d.hpp:151
Boxes3D with_fill_mode(const rerun::components::FillMode &_fill_mode) &&
Optionally choose whether the boxes are drawn with lines or solid.
Definition boxes3d.hpp:281
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition boxes3d.hpp:365
static constexpr auto Descriptor_centers
ComponentDescriptor for the centers field.
Definition boxes3d.hpp:124
Boxes3D with_rotation_axis_angles(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition boxes3d.hpp:245
std::optional< ComponentBatch > radii
Optional radii for the lines that make up the boxes.
Definition boxes3d.hpp:92
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition boxes3d.hpp:344
static constexpr auto Descriptor_rotation_axis_angles
ComponentDescriptor for the rotation_axis_angles field.
Definition boxes3d.hpp:129
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18