Rerun C++ SDK
Loading...
Searching...
No Matches
boxes3d.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/re_types/definitions/rerun/archetypes/boxes3d.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../components/class_id.hpp"
9#include "../components/color.hpp"
10#include "../components/half_sizes3d.hpp"
11#include "../components/instance_key.hpp"
12#include "../components/position3d.hpp"
13#include "../components/radius.hpp"
14#include "../components/rotation3d.hpp"
15#include "../components/text.hpp"
16#include "../data_cell.hpp"
17#include "../indicator_component.hpp"
18#include "../result.hpp"
19
20#include <cstdint>
21#include <optional>
22#include <utility>
23#include <vector>
24
25namespace rerun::archetypes {
26 /// **Archetype**: 3D boxes with half-extents and optional center, rotations, rotations, colors etc.
27 ///
28 /// ## Example
29 ///
30 /// ### Batch of 3D boxes
31 /// ![image](https://static.rerun.io/box3d_batch/6d3e453c3a0201ae42bbae9de941198513535f1d/full.png)
32 ///
33 /// ```cpp
34 /// #include <rerun.hpp>
35 ///
36 /// int main() {
37 /// const auto rec = rerun::RecordingStream("rerun_example_box3d_batch");
38 /// rec.spawn().exit_on_failure();
39 ///
40 /// rec.log(
41 /// "batch",
42 /// rerun::Boxes3D::from_centers_and_half_sizes(
43 /// {{2.0f, 0.0f, 0.0f}, {-2.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 2.0f}},
44 /// {{2.0f, 2.0f, 1.0f}, {1.0f, 1.0f, 0.5f}, {2.0f, 0.5f, 1.0f}}
45 /// )
46 /// .with_rotations({
47 /// rerun::Quaternion::IDENTITY,
48 /// // 45 degrees around Z
49 /// rerun::Quaternion::from_xyzw(0.0f, 0.0f, 0.382683f, 0.923880f),
50 /// rerun::RotationAxisAngle({0.0f, 1.0f, 0.0f}, rerun::Angle::degrees(30.0f)),
51 /// })
52 /// .with_radii({0.025f})
53 /// .with_colors({
54 /// rerun::Rgba32(255, 0, 0),
55 /// rerun::Rgba32(0, 255, 0),
56 /// rerun::Rgba32(0, 0, 255),
57 /// })
58 /// .with_labels({"red", "green", "blue"})
59 /// );
60 /// }
61 /// ```
62 struct Boxes3D {
63 /// All half-extents that make up the batch of boxes.
65
66 /// Optional center positions of the boxes.
67 std::optional<Collection<rerun::components::Position3D>> centers;
68
69 std::optional<Collection<rerun::components::Rotation3D>> rotations;
70
71 /// Optional colors for the boxes.
72 std::optional<Collection<rerun::components::Color>> colors;
73
74 /// Optional radii for the lines that make up the boxes.
75 std::optional<Collection<rerun::components::Radius>> radii;
76
77 /// Optional text labels for the boxes.
78 std::optional<Collection<rerun::components::Text>> labels;
79
80 /// Optional `ClassId`s for the boxes.
81 ///
82 /// The class ID provides colors and labels if not specified explicitly.
83 std::optional<Collection<rerun::components::ClassId>> class_ids;
84
85 /// Unique identifiers for each individual boxes in the batch.
86 std::optional<Collection<rerun::components::InstanceKey>> instance_keys;
87
88 public:
89 static constexpr const char IndicatorComponentName[] = "rerun.components.Boxes3DIndicator";
90
91 /// Indicator component, used to identify the archetype when converting to a list of components.
93
94 public:
95 // Extensions to generated type defined in 'boxes3d_ext.cpp'
96
97 /// Creates new `Boxes3D` with `half_sizes` centered around the local origin.
99 Boxes3D boxes;
100 boxes.half_sizes = std::move(half_sizes);
101 return boxes;
102 }
103
104 /// Creates new `Boxes3D` with `centers` and `half_sizes`.
108 ) {
109 Boxes3D boxes;
110 boxes.half_sizes = std::move(half_sizes);
111 boxes.centers = std::move(centers);
112 return boxes;
113 }
114
115 /// Creates new `Boxes3D` with `half_sizes` created from (full) sizes.
116 ///
117 /// TODO(#3285): Does *not* preserve data as-is and instead creates half-sizes from the
118 /// input data.
119 /// TODO(#3794): This should not take an std::vector.
120 static Boxes3D from_sizes(const std::vector<datatypes::Vec3D>& sizes);
121
122 /// Creates new `Boxes3D` with `centers` and `half_sizes` created from centers and (full)
123 /// sizes.
124 ///
125 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
126 /// from the input data.
127 /// TODO(#3794): This should not take an std::vector.
129 Collection<components::Position3D> centers, const std::vector<datatypes::Vec3D>& sizes
130 ) {
131 Boxes3D boxes = from_sizes(std::move(sizes));
132 boxes.centers = std::move(centers);
133 return boxes;
134 }
135
136 /// Creates new `Boxes3D` with `half_sizes` and `centers` created from minimums and (full)
137 /// sizes.
138 ///
139 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
140 /// from the input data.
141 /// TODO(#3794): This should not take an std::vector.
143 const std::vector<datatypes::Vec3D>& mins, const std::vector<datatypes::Vec3D>& sizes
144 );
145
146 public:
147 Boxes3D() = default;
148 Boxes3D(Boxes3D&& other) = default;
149
150 /// Optional center positions of the boxes.
152 centers = std::move(_centers);
153 // See: https://github.com/rerun-io/rerun/issues/4027
154 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
155 }
156
157 Boxes3D with_rotations(Collection<rerun::components::Rotation3D> _rotations) && {
158 rotations = std::move(_rotations);
159 // See: https://github.com/rerun-io/rerun/issues/4027
160 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
161 }
162
163 /// Optional colors for the boxes.
165 colors = std::move(_colors);
166 // See: https://github.com/rerun-io/rerun/issues/4027
167 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
168 }
169
170 /// Optional radii for the lines that make up the boxes.
172 radii = std::move(_radii);
173 // See: https://github.com/rerun-io/rerun/issues/4027
174 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
175 }
176
177 /// Optional text labels for the boxes.
179 labels = std::move(_labels);
180 // See: https://github.com/rerun-io/rerun/issues/4027
181 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
182 }
183
184 /// Optional `ClassId`s for the boxes.
185 ///
186 /// The class ID provides colors and labels if not specified explicitly.
188 class_ids = std::move(_class_ids);
189 // See: https://github.com/rerun-io/rerun/issues/4027
190 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
191 }
192
193 /// Unique identifiers for each individual boxes in the batch.
195 instance_keys = std::move(_instance_keys);
196 // See: https://github.com/rerun-io/rerun/issues/4027
197 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
198 }
199
200 /// Returns the number of primary instances of this archetype.
201 size_t num_instances() const {
202 return half_sizes.size();
203 }
204 };
205
206} // namespace rerun::archetypes
207
208namespace rerun {
209 /// \private
210 template <typename T>
211 struct AsComponents;
212
213 /// \private
214 template <>
215 struct AsComponents<archetypes::Boxes3D> {
216 /// Serialize all set component batches.
217 static Result<std::vector<DataCell>> serialize(const archetypes::Boxes3D& archetype);
218 };
219} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:47
size_t size() const
Returns the number of instances in this collection.
Definition collection.hpp:254
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:66
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Archetype: 3D boxes with half-extents and optional center, rotations, rotations, colors etc.
Definition boxes3d.hpp:62
size_t num_instances() const
Returns the number of primary instances of this archetype.
Definition boxes3d.hpp:201
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional ClassIds for the boxes.
Definition boxes3d.hpp:83
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the boxes.
Definition boxes3d.hpp:78
Boxes3D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the boxes.
Definition boxes3d.hpp:164
static Boxes3D from_sizes(const std::vector< datatypes::Vec3D > &sizes)
Creates new Boxes3D with half_sizes created from (full) sizes.
Boxes3D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the boxes.
Definition boxes3d.hpp:178
std::optional< Collection< rerun::components::InstanceKey > > instance_keys
Unique identifiers for each individual boxes in the batch.
Definition boxes3d.hpp:86
Boxes3D with_instance_keys(Collection< rerun::components::InstanceKey > _instance_keys) &&
Unique identifiers for each individual boxes in the batch.
Definition boxes3d.hpp:194
static Boxes3D from_centers_and_sizes(Collection< components::Position3D > centers, const std::vector< datatypes::Vec3D > &sizes)
Creates new Boxes3D with centers and half_sizes created from centers and (full) sizes.
Definition boxes3d.hpp:128
Collection< rerun::components::HalfSizes3D > half_sizes
All half-extents that make up the batch of boxes.
Definition boxes3d.hpp:64
static Boxes3D from_half_sizes(Collection< components::HalfSizes3D > half_sizes)
Creates new Boxes3D with half_sizes centered around the local origin.
Definition boxes3d.hpp:98
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the lines that make up the boxes.
Definition boxes3d.hpp:75
static Boxes3D from_centers_and_half_sizes(Collection< components::Position3D > centers, Collection< components::HalfSizes3D > half_sizes)
Creates new Boxes3D with centers and half_sizes.
Definition boxes3d.hpp:105
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the boxes.
Definition boxes3d.hpp:72
Boxes3D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional ClassIds for the boxes.
Definition boxes3d.hpp:187
Boxes3D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the lines that make up the boxes.
Definition boxes3d.hpp:171
Boxes3D with_centers(Collection< rerun::components::Position3D > _centers) &&
Optional center positions of the boxes.
Definition boxes3d.hpp:151
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.
std::optional< Collection< rerun::components::Position3D > > centers
Optional center positions of the boxes.
Definition boxes3d.hpp:67
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:23