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 "../indicator_component.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() {
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 std::optional<ComponentBatch> colors;
88
89 /// Optional radii for the lines that make up the boxes.
90 std::optional<ComponentBatch> radii;
91
92 /// Optionally choose whether the boxes are drawn with lines or solid.
93 std::optional<ComponentBatch> fill_mode;
94
95 /// Optional text labels for the boxes.
96 ///
97 /// If there's a single label present, it will be placed at the center of the entity.
98 /// Otherwise, each instance will have its own label.
99 std::optional<ComponentBatch> labels;
100
101 /// Whether the text labels should be shown.
102 ///
103 /// If not set, labels will automatically appear when there is exactly one label for this entity
104 /// or the number of instances on this entity is under a certain threshold.
105 std::optional<ComponentBatch> show_labels;
106
107 /// Optional `components::ClassId`s for the boxes.
108 ///
109 /// The `components::ClassId` provides colors and labels if not specified explicitly.
110 std::optional<ComponentBatch> class_ids;
111
112 public:
113 static constexpr const char IndicatorComponentName[] = "rerun.components.Boxes3DIndicator";
114
115 /// Indicator component, used to identify the archetype when converting to a list of components.
117 /// The name of the archetype as used in `ComponentDescriptor`s.
118 static constexpr const char ArchetypeName[] = "rerun.archetypes.Boxes3D";
119
120 /// `ComponentDescriptor` for the `half_sizes` field.
122 ArchetypeName, "half_sizes",
124 );
125 /// `ComponentDescriptor` for the `centers` field.
127 ArchetypeName, "centers",
129 );
130 /// `ComponentDescriptor` for the `rotation_axis_angles` field.
132 ArchetypeName, "rotation_axis_angles",
134 );
135 /// `ComponentDescriptor` for the `quaternions` field.
137 ArchetypeName, "quaternions",
139 );
140 /// `ComponentDescriptor` for the `colors` field.
141 static constexpr auto Descriptor_colors = ComponentDescriptor(
143 );
144 /// `ComponentDescriptor` for the `radii` field.
145 static constexpr auto Descriptor_radii = ComponentDescriptor(
147 );
148 /// `ComponentDescriptor` for the `fill_mode` field.
150 ArchetypeName, "fill_mode",
152 );
153 /// `ComponentDescriptor` for the `labels` field.
154 static constexpr auto Descriptor_labels = ComponentDescriptor(
156 );
157 /// `ComponentDescriptor` for the `show_labels` field.
159 ArchetypeName, "show_labels",
161 );
162 /// `ComponentDescriptor` for the `class_ids` field.
164 ArchetypeName, "class_ids",
166 );
167
168 public: // START of extensions from boxes3d_ext.cpp:
169 /// Creates new `Boxes3D` with `half_sizes` centered around the local origin.
171 return Boxes3D().with_half_sizes(std::move(half_sizes));
172 }
173
174 /// Creates new `Boxes3D` with `centers` and `half_sizes`.
178 ) {
179 return Boxes3D()
180 .with_half_sizes(std::move(half_sizes))
181 .with_centers(std::move(centers));
182 }
183
184 /// Creates new `Boxes3D` with `half_sizes` created from (full) sizes.
185 ///
186 /// TODO(#3285): Does *not* preserve data as-is and instead creates half-sizes from the
187 /// input data.
188 /// TODO(andreas): This should not take an std::vector.
189 static Boxes3D from_sizes(const std::vector<datatypes::Vec3D>& sizes);
190
191 /// Creates new `Boxes3D` with `centers` and `half_sizes` created from centers and (full)
192 /// sizes.
193 ///
194 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
195 /// from the input data.
196 /// TODO(andreas): This should not take an std::vector.
199 const std::vector<datatypes::Vec3D>& sizes
200 ) {
201 return from_sizes(std::move(sizes)).with_centers(std::move(centers));
202 }
203
204 /// Creates new `Boxes3D` with `half_sizes` and `centers` created from minimums and (full)
205 /// sizes.
206 ///
207 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
208 /// from the input data.
209 /// TODO(andreas): This should not take an std::vector.
211 const std::vector<datatypes::Vec3D>& mins, const std::vector<datatypes::Vec3D>& sizes
212 );
213
214 // END of extensions from boxes3d_ext.cpp, start of generated code:
215
216 public:
217 Boxes3D() = default;
218 Boxes3D(Boxes3D&& other) = default;
219 Boxes3D(const Boxes3D& other) = default;
220 Boxes3D& operator=(const Boxes3D& other) = default;
221 Boxes3D& operator=(Boxes3D&& other) = default;
222
223 /// Update only some specific fields of a `Boxes3D`.
225 return Boxes3D();
226 }
227
228 /// Clear all the fields of a `Boxes3D`.
230
231 /// All half-extents that make up the batch of boxes.
233 half_sizes =
234 ComponentBatch::from_loggable(_half_sizes, Descriptor_half_sizes).value_or_throw();
235 return std::move(*this);
236 }
237
238 /// Optional center positions of the boxes.
239 ///
240 /// If not specified, the centers will be at (0, 0, 0).
242 centers = ComponentBatch::from_loggable(_centers, Descriptor_centers).value_or_throw();
243 return std::move(*this);
244 }
245
246 /// Rotations via axis + angle.
247 ///
248 /// If no rotation is specified, the axes of the boxes align with the axes of the local coordinate system.
251 ) && {
253 _rotation_axis_angles,
255 )
256 .value_or_throw();
257 return std::move(*this);
258 }
259
260 /// Rotations via quaternion.
261 ///
262 /// If no rotation is specified, the axes of the boxes align with the axes of the local coordinate system.
264 ) && {
266 .value_or_throw();
267 return std::move(*this);
268 }
269
270 /// Optional colors for the boxes.
272 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
273 return std::move(*this);
274 }
275
276 /// Optional radii for the lines that make up the boxes.
278 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
279 return std::move(*this);
280 }
281
282 /// Optionally choose whether the boxes are drawn with lines or solid.
284 fill_mode =
285 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
286 return std::move(*this);
287 }
288
289 /// This method makes it possible to pack multiple `fill_mode` in a single component batch.
290 ///
291 /// This only makes sense when used in conjunction with `columns`. `with_fill_mode` should
292 /// be used when logging a single row's worth of data.
294 fill_mode =
295 ComponentBatch::from_loggable(_fill_mode, Descriptor_fill_mode).value_or_throw();
296 return std::move(*this);
297 }
298
299 /// Optional text labels for the boxes.
300 ///
301 /// If there's a single label present, it will be placed at the center of the entity.
302 /// Otherwise, each instance will have its own label.
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.
323 ) && {
325 .value_or_throw();
326 return std::move(*this);
327 }
328
329 /// Optional `components::ClassId`s for the boxes.
330 ///
331 /// The `components::ClassId` provides colors and labels if not specified explicitly.
333 class_ids =
334 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
335 return std::move(*this);
336 }
337
338 /// Partitions the component data into multiple sub-batches.
339 ///
340 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
341 /// instead, via `ComponentBatch::partitioned`.
342 ///
343 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
344 ///
345 /// The specified `lengths` must sum to the total length of the component batch.
347
348 /// Partitions the component data into unit-length sub-batches.
349 ///
350 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
351 /// where `n` is automatically guessed.
353 };
354
355} // namespace rerun::archetypes
356
357namespace rerun {
358 /// \private
359 template <typename T>
360 struct AsComponents;
361
362 /// \private
363 template <>
364 struct AsComponents<archetypes::Boxes3D> {
365 /// Serialize all set component batches.
366 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Boxes3D& archetype);
367 };
368} // 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:25
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:14
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:163
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition boxes3d.hpp:145
Boxes3D with_centers(const Collection< rerun::components::PoseTranslation3D > &_centers) &&
Optional center positions of the boxes.
Definition boxes3d.hpp:241
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:293
Boxes3D with_quaternions(const Collection< rerun::components::PoseRotationQuat > &_quaternions) &&
Rotations via quaternion.
Definition boxes3d.hpp:263
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition boxes3d.hpp:141
std::optional< ComponentBatch > labels
Optional text labels for the boxes.
Definition boxes3d.hpp:99
static Boxes3D from_half_sizes(Collection< components::HalfSize3D > half_sizes)
Creates new Boxes3D with half_sizes centered around the local origin.
Definition boxes3d.hpp:170
Boxes3D with_rotation_axis_angles(const Collection< rerun::components::PoseRotationAxisAngle > &_rotation_axis_angles) &&
Rotations via axis + angle.
Definition boxes3d.hpp:249
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:149
static constexpr auto Descriptor_half_sizes
ComponentDescriptor for the half_sizes field.
Definition boxes3d.hpp:121
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition boxes3d.hpp:118
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:175
Boxes3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the boxes.
Definition boxes3d.hpp:271
Boxes3D with_half_sizes(const Collection< rerun::components::HalfSize3D > &_half_sizes) &&
All half-extents that make up the batch of boxes.
Definition boxes3d.hpp:232
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:197
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition boxes3d.hpp:105
static constexpr auto Descriptor_quaternions
ComponentDescriptor for the quaternions field.
Definition boxes3d.hpp:136
std::optional< ComponentBatch > centers
Optional center positions of the boxes.
Definition boxes3d.hpp:74
std::optional< ComponentBatch > fill_mode
Optionally choose whether the boxes are drawn with lines or solid.
Definition boxes3d.hpp:93
Boxes3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition boxes3d.hpp:312
Boxes3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional components::ClassIds for the boxes.
Definition boxes3d.hpp:332
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:322
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:158
std::optional< ComponentBatch > class_ids
Optional components::ClassIds for the boxes.
Definition boxes3d.hpp:110
std::optional< ComponentBatch > rotation_axis_angles
Rotations via axis + angle.
Definition boxes3d.hpp:79
Boxes3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the boxes.
Definition boxes3d.hpp:303
std::optional< ComponentBatch > colors
Optional colors for the boxes.
Definition boxes3d.hpp:87
Boxes3D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the lines that make up the boxes.
Definition boxes3d.hpp:277
static Boxes3D update_fields()
Update only some specific fields of a Boxes3D.
Definition boxes3d.hpp:224
static Boxes3D clear_fields()
Clear all the fields of a Boxes3D.
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition boxes3d.hpp:154
Boxes3D with_fill_mode(const rerun::components::FillMode &_fill_mode) &&
Optionally choose whether the boxes are drawn with lines or solid.
Definition boxes3d.hpp:283
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:126
std::optional< ComponentBatch > radii
Optional radii for the lines that make up the boxes.
Definition boxes3d.hpp:90
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:131
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