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