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