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 "../compiler_utils.hpp"
8#include "../component_batch.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.
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<Collection<rerun::components::PoseTranslation3D>> 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<Collection<rerun::components::PoseRotationAxisAngle>> 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<Collection<rerun::components::PoseRotationQuat>> quaternions;
89
90 /// Optional colors for the boxes.
91 std::optional<Collection<rerun::components::Color>> colors;
92
93 /// Optional radii for the lines that make up the boxes.
94 std::optional<Collection<rerun::components::Radius>> radii;
95
96 /// Optionally choose whether the boxes are drawn with lines or solid.
97 std::optional<rerun::components::FillMode> 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<Collection<rerun::components::Text>> labels;
104
105 /// Optional choice of whether the text labels should be shown by default.
106 std::optional<rerun::components::ShowLabels> 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<Collection<rerun::components::ClassId>> 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
119 public: // START of extensions from boxes3d_ext.cpp:
120 /// Creates new `Boxes3D` with `half_sizes` centered around the local origin.
122 Boxes3D boxes;
123 boxes.half_sizes = std::move(half_sizes);
124 return boxes;
125 }
126
127 /// Creates new `Boxes3D` with `centers` and `half_sizes`.
131 ) {
132 Boxes3D boxes;
133 boxes.half_sizes = std::move(half_sizes);
134 boxes.centers = std::move(centers);
135 return boxes;
136 }
137
138 /// Creates new `Boxes3D` with `half_sizes` created from (full) sizes.
139 ///
140 /// TODO(#3285): Does *not* preserve data as-is and instead creates half-sizes from the
141 /// input data.
142 /// TODO(andreas): This should not take an std::vector.
143 static Boxes3D from_sizes(const std::vector<datatypes::Vec3D>& sizes);
144
145 /// Creates new `Boxes3D` with `centers` and `half_sizes` created from centers and (full)
146 /// sizes.
147 ///
148 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
149 /// from the input data.
150 /// TODO(andreas): This should not take an std::vector.
153 const std::vector<datatypes::Vec3D>& sizes
154 ) {
155 Boxes3D boxes = from_sizes(std::move(sizes));
156 boxes.centers = std::move(centers);
157 return boxes;
158 }
159
160 /// Creates new `Boxes3D` with `half_sizes` and `centers` created from minimums and (full)
161 /// sizes.
162 ///
163 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
164 /// from the input data.
165 /// TODO(andreas): This should not take an std::vector.
167 const std::vector<datatypes::Vec3D>& mins, const std::vector<datatypes::Vec3D>& sizes
168 );
169
170 // END of extensions from boxes3d_ext.cpp, start of generated code:
171
172 public:
173 Boxes3D() = default;
174 Boxes3D(Boxes3D&& other) = default;
175
176 /// Optional center positions of the boxes.
177 ///
178 /// If not specified, the centers will be at (0, 0, 0).
179 /// Note that this uses a `components::PoseTranslation3D` which is also used by `archetypes::InstancePoses3D`.
181 centers = std::move(_centers);
182 // See: https://github.com/rerun-io/rerun/issues/4027
183 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
184 }
185
186 /// Rotations via axis + angle.
187 ///
188 /// If no rotation is specified, the axes of the boxes align with the axes of the local coordinate system.
189 /// Note that this uses a `components::PoseRotationAxisAngle` which is also used by `archetypes::InstancePoses3D`.
192 ) && {
193 rotation_axis_angles = std::move(_rotation_axis_angles);
194 // See: https://github.com/rerun-io/rerun/issues/4027
195 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
196 }
197
198 /// Rotations via quaternion.
199 ///
200 /// If no rotation is specified, the axes of the boxes align with the axes of the local coordinate system.
201 /// Note that this uses a `components::PoseRotationQuat` which is also used by `archetypes::InstancePoses3D`.
203 quaternions = std::move(_quaternions);
204 // See: https://github.com/rerun-io/rerun/issues/4027
205 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
206 }
207
208 /// Optional colors for the boxes.
210 colors = std::move(_colors);
211 // See: https://github.com/rerun-io/rerun/issues/4027
212 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
213 }
214
215 /// Optional radii for the lines that make up the boxes.
217 radii = std::move(_radii);
218 // See: https://github.com/rerun-io/rerun/issues/4027
219 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
220 }
221
222 /// Optionally choose whether the boxes are drawn with lines or solid.
224 fill_mode = std::move(_fill_mode);
225 // See: https://github.com/rerun-io/rerun/issues/4027
226 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
227 }
228
229 /// Optional text labels for the boxes.
230 ///
231 /// If there's a single label present, it will be placed at the center of the entity.
232 /// Otherwise, each instance will have its own label.
234 labels = std::move(_labels);
235 // See: https://github.com/rerun-io/rerun/issues/4027
236 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
237 }
238
239 /// Optional choice of whether the text labels should be shown by default.
241 show_labels = std::move(_show_labels);
242 // See: https://github.com/rerun-io/rerun/issues/4027
243 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
244 }
245
246 /// Optional `components::ClassId`s for the boxes.
247 ///
248 /// The `components::ClassId` provides colors and labels if not specified explicitly.
250 class_ids = std::move(_class_ids);
251 // See: https://github.com/rerun-io/rerun/issues/4027
252 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
253 }
254 };
255
256} // namespace rerun::archetypes
257
258namespace rerun {
259 /// \private
260 template <typename T>
261 struct AsComponents;
262
263 /// \private
264 template <>
265 struct AsComponents<archetypes::Boxes3D> {
266 /// Serialize all set component batches.
267 static Result<std::vector<ComponentBatch>> serialize(const archetypes::Boxes3D& archetype);
268 };
269} // 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:77
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
Archetype: 3D boxes with half-extents and optional center, rotations, colors etc.
Definition boxes3d.hpp:68
std::optional< rerun::components::ShowLabels > show_labels
Optional choice of whether the text labels should be shown by default.
Definition boxes3d.hpp:106
std::optional< Collection< rerun::components::PoseRotationAxisAngle > > rotation_axis_angles
Rotations via axis + angle.
Definition boxes3d.hpp:82
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional components::ClassIds for the boxes.
Definition boxes3d.hpp:111
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the boxes.
Definition boxes3d.hpp:103
Boxes3D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the boxes.
Definition boxes3d.hpp:209
static Boxes3D from_sizes(const std::vector< datatypes::Vec3D > &sizes)
Creates new Boxes3D with half_sizes created from (full) sizes.
Boxes3D with_fill_mode(rerun::components::FillMode _fill_mode) &&
Optionally choose whether the boxes are drawn with lines or solid.
Definition boxes3d.hpp:223
static Boxes3D from_half_sizes(Collection< components::HalfSize3D > half_sizes)
Creates new Boxes3D with half_sizes centered around the local origin.
Definition boxes3d.hpp:121
std::optional< Collection< rerun::components::PoseRotationQuat > > quaternions
Rotations via quaternion.
Definition boxes3d.hpp:88
Boxes3D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the boxes.
Definition boxes3d.hpp:233
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:128
Boxes3D with_show_labels(rerun::components::ShowLabels _show_labels) &&
Optional choice of whether the text labels should be shown by default.
Definition boxes3d.hpp:240
Collection< rerun::components::HalfSize3D > half_sizes
All half-extents that make up the batch of boxes.
Definition boxes3d.hpp:70
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:151
Boxes3D with_quaternions(Collection< rerun::components::PoseRotationQuat > _quaternions) &&
Rotations via quaternion.
Definition boxes3d.hpp:202
Boxes3D with_centers(Collection< rerun::components::PoseTranslation3D > _centers) &&
Optional center positions of the boxes.
Definition boxes3d.hpp:180
Boxes3D with_rotation_axis_angles(Collection< rerun::components::PoseRotationAxisAngle > _rotation_axis_angles) &&
Rotations via axis + angle.
Definition boxes3d.hpp:190
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the lines that make up the boxes.
Definition boxes3d.hpp:94
std::optional< rerun::components::FillMode > fill_mode
Optionally choose whether the boxes are drawn with lines or solid.
Definition boxes3d.hpp:97
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the boxes.
Definition boxes3d.hpp:91
Boxes3D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional components::ClassIds for the boxes.
Definition boxes3d.hpp:249
Boxes3D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the lines that make up the boxes.
Definition boxes3d.hpp:216
std::optional< Collection< rerun::components::PoseTranslation3D > > centers
Optional center positions of the boxes.
Definition boxes3d.hpp:76
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.
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