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