Rerun C++ SDK
Loading...
Searching...
No Matches
voxel_grid_map.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_sdk_types/definitions/rerun/archetypes/voxel_grid_map.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/color.hpp"
10#include "../components/colormap.hpp"
11#include "../components/opacity.hpp"
12#include "../components/rotation_axis_angle.hpp"
13#include "../components/rotation_quat.hpp"
14#include "../components/translation3d.hpp"
15#include "../components/value_range.hpp"
16#include "../components/voxel_index.hpp"
17#include "../components/voxel_size.hpp"
18#include "../components/voxel_value.hpp"
19#include "../result.hpp"
20
21#include <cstdint>
22#include <optional>
23#include <utility>
24#include <vector>
25
26namespace rerun::archetypes {
27 /// **Archetype**: A sparse 3D voxel grid map with grid indices and voxel dimensions.
28 ///
29 /// This archetype is intended for 3D occupancy maps and other volumetric data
30 /// represented as a sparse grid of voxels with scene-unit dimensions along the local X/Y/Z axes.
31 ///
32 /// The minimum corner of the voxel with `[0, 0, 0]` index is located at the origin of the entity's coordinate frame
33 /// and can have an additional offset from there through the optional translation and rotation fields.
34 ///
35 /// A voxel center is at `(index + 0.5) * voxel_size` in local grid coordinates (i.e. relative to the minimum corner).
36 ///
37 /// ## Example
38 ///
39 /// ### Simple sparse voxel grid map
40 /// ```cpp
41 /// #include <rerun.hpp>
42 ///
43 /// #include <array>
44 /// #include <vector>
45 ///
46 /// int main(int argc, char* argv[]) {
47 /// const auto rec =
48 /// rerun::RecordingStream("rerun_example_voxel_grid_map_simple");
49 /// rec.spawn().exit_on_failure();
50 ///
51 /// const std::vector<rerun::components::VoxelIndex> voxel_indices = {
52 /// rerun::components::VoxelIndex(-1, 0, 0),
53 /// rerun::components::VoxelIndex(1, 0, 0),
54 /// rerun::components::VoxelIndex(1, 1, 0),
55 /// rerun::components::VoxelIndex(3, 0, 0),
56 /// rerun::components::VoxelIndex(3, 0, 1),
57 /// rerun::components::VoxelIndex(4, 0, 1),
58 /// };
59 /// const std::vector<rerun::components::VoxelValue> values = {
60 /// 0.0f,
61 /// 0.2f,
62 /// 0.4f,
63 /// 0.6f,
64 /// 0.8f,
65 /// 1.0f,
66 /// };
67 ///
68 /// rec.log(
69 /// "world/voxels",
70 /// rerun::archetypes::VoxelGridMap(
71 /// voxel_indices,
72 /// std::array<float, 3>{0.25f, 0.25f, 0.25f}
73 /// )
74 /// .with_values(values)
75 /// .with_value_range(
76 /// rerun::components::ValueRange(std::array<double, 2>{0.0, 1.0})
77 /// )
78 /// .with_colormap(rerun::components::Colormap::Turbo)
79 /// .with_translation({-0.5f, -0.5f, 0.0f})
80 /// );
81 /// }
82 /// ```
83 ///
84 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
85 ///
86 struct VoxelGridMap {
87 /// Indices of the voxels within the grid volume.
88 std::optional<ComponentBatch> voxel_indices;
89
90 /// The scene-unit dimensions of a single voxel cell.
91 ///
92 /// This defines the voxel size along the local grid X/Y/Z axes.
93 /// Each dimension must be finite and positive.
94 std::optional<ComponentBatch> voxel_size;
95
96 /// Optional scalar occupancy or value data for each voxel.
97 ///
98 /// If explicit colors are not provided, values are mapped through `colormap` and `value_range`.
99 std::optional<ComponentBatch> values;
100
101 /// Optional colors for each voxel.
102 ///
103 /// If set, these colors take precedence over color-mapped scalar values.
104 std::optional<ComponentBatch> colors;
105
106 /// Translation of the minimum corner of voxel `[0, 0, 0]`.
107 ///
108 /// Together with `components::RotationAxisAngle` or `components::RotationQuat`, this defines the pose of the
109 /// grid relative to the map's parent coordinate frame.
110 ///
111 /// If not set, the minimum corner is placed at the origin of the map's parent coordinate frame.
112 std::optional<ComponentBatch> translation;
113
114 /// Rotation of the grid via axis + angle.
115 ///
116 /// Together with `components::Translation3D`, this defines the pose of the grid relative to the
117 /// map's parent coordinate frame.
118 ///
119 /// Note: either this or `components::RotationQuat` can be set to specify the grid's rotation, but not both.
120 /// If both this and `components::RotationQuat` are set, this is ignored in favor of the quaternion.
121 std::optional<ComponentBatch> rotation_axis_angle;
122
123 /// Rotation of the grid via quaternion.
124 ///
125 /// Together with `components::Translation3D`, this defines the pose of the grid relative to the
126 /// map's parent coordinate frame.
127 std::optional<ComponentBatch> quaternion;
128
129 /// Opacity of the voxels after color or colormap application.
130 ///
131 /// Defaults to 1.0 (fully opaque).
132 std::optional<ComponentBatch> opacity;
133
134 /// Scalar value range for color-mapping.
135 ///
136 /// Defaults to `[0.0, 1.0]`.
137 std::optional<ComponentBatch> value_range;
138
139 /// Colormap to use when `values` are present and explicit `colors` are not provided.
140 ///
141 /// Defaults to Turbo.
142 std::optional<ComponentBatch> colormap;
143
144 public:
145 /// The name of the archetype as used in `ComponentDescriptor`s.
146 static constexpr const char ArchetypeName[] = "rerun.archetypes.VoxelGridMap";
147
148 /// `ComponentDescriptor` for the `voxel_indices` field.
150 ArchetypeName, "VoxelGridMap:voxel_indices",
152 );
153 /// `ComponentDescriptor` for the `voxel_size` field.
155 ArchetypeName, "VoxelGridMap:voxel_size",
157 );
158 /// `ComponentDescriptor` for the `values` field.
159 static constexpr auto Descriptor_values = ComponentDescriptor(
160 ArchetypeName, "VoxelGridMap:values",
162 );
163 /// `ComponentDescriptor` for the `colors` field.
164 static constexpr auto Descriptor_colors = ComponentDescriptor(
166 );
167 /// `ComponentDescriptor` for the `translation` field.
169 ArchetypeName, "VoxelGridMap:translation",
171 );
172 /// `ComponentDescriptor` for the `rotation_axis_angle` field.
174 ArchetypeName, "VoxelGridMap:rotation_axis_angle",
176 );
177 /// `ComponentDescriptor` for the `quaternion` field.
179 ArchetypeName, "VoxelGridMap:quaternion",
181 );
182 /// `ComponentDescriptor` for the `opacity` field.
184 ArchetypeName, "VoxelGridMap:opacity",
186 );
187 /// `ComponentDescriptor` for the `value_range` field.
189 ArchetypeName, "VoxelGridMap:value_range",
191 );
192 /// `ComponentDescriptor` for the `colormap` field.
194 ArchetypeName, "VoxelGridMap:colormap",
196 );
197
198 public:
199 VoxelGridMap() = default;
200 VoxelGridMap(VoxelGridMap&& other) = default;
201 VoxelGridMap(const VoxelGridMap& other) = default;
202 VoxelGridMap& operator=(const VoxelGridMap& other) = default;
203 VoxelGridMap& operator=(VoxelGridMap&& other) = default;
204
205 explicit VoxelGridMap(
208 )
210 ComponentBatch::from_loggable(std::move(_voxel_indices), Descriptor_voxel_indices)
211 .value_or_throw()
212 ),
214 ComponentBatch::from_loggable(std::move(_voxel_size), Descriptor_voxel_size)
215 .value_or_throw()
216 ) {}
217
218 /// Update only some specific fields of a `VoxelGridMap`.
220 return VoxelGridMap();
221 }
222
223 /// Clear all the fields of a `VoxelGridMap`.
225
226 /// Indices of the voxels within the grid volume.
229 ) && {
231 .value_or_throw();
232 return std::move(*this);
233 }
234
235 /// The scene-unit dimensions of a single voxel cell.
236 ///
237 /// This defines the voxel size along the local grid X/Y/Z axes.
238 /// Each dimension must be finite and positive.
240 voxel_size =
241 ComponentBatch::from_loggable(_voxel_size, Descriptor_voxel_size).value_or_throw();
242 return std::move(*this);
243 }
244
245 /// This method makes it possible to pack multiple `voxel_size` in a single component batch.
246 ///
247 /// This only makes sense when used in conjunction with `columns`. `with_voxel_size` should
248 /// be used when logging a single row's worth of data.
251 ) && {
252 voxel_size =
253 ComponentBatch::from_loggable(_voxel_size, Descriptor_voxel_size).value_or_throw();
254 return std::move(*this);
255 }
256
257 /// Optional scalar occupancy or value data for each voxel.
258 ///
259 /// If explicit colors are not provided, values are mapped through `colormap` and `value_range`.
261 values = ComponentBatch::from_loggable(_values, Descriptor_values).value_or_throw();
262 return std::move(*this);
263 }
264
265 /// Optional colors for each voxel.
266 ///
267 /// If set, these colors take precedence over color-mapped scalar values.
269 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
270 return std::move(*this);
271 }
272
273 /// Translation of the minimum corner of voxel `[0, 0, 0]`.
274 ///
275 /// Together with `components::RotationAxisAngle` or `components::RotationQuat`, this defines the pose of the
276 /// grid relative to the map's parent coordinate frame.
277 ///
278 /// If not set, the minimum corner is placed at the origin of the map's parent coordinate frame.
281 .value_or_throw();
282 return std::move(*this);
283 }
284
285 /// This method makes it possible to pack multiple `translation` in a single component batch.
286 ///
287 /// This only makes sense when used in conjunction with `columns`. `with_translation` should
288 /// be used when logging a single row's worth of data.
291 ) && {
293 .value_or_throw();
294 return std::move(*this);
295 }
296
297 /// Rotation of the grid via axis + angle.
298 ///
299 /// Together with `components::Translation3D`, this defines the pose of the grid relative to the
300 /// map's parent coordinate frame.
301 ///
302 /// Note: either this or `components::RotationQuat` can be set to specify the grid's rotation, but not both.
303 /// If both this and `components::RotationQuat` are set, this is ignored in favor of the quaternion.
305 const rerun::components::RotationAxisAngle& _rotation_axis_angle
306 ) && {
309 .value_or_throw();
310 return std::move(*this);
311 }
312
313 /// This method makes it possible to pack multiple `rotation_axis_angle` in a single component batch.
314 ///
315 /// This only makes sense when used in conjunction with `columns`. `with_rotation_axis_angle` should
316 /// be used when logging a single row's worth of data.
318 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angle
319 ) && {
322 .value_or_throw();
323 return std::move(*this);
324 }
325
326 /// Rotation of the grid via quaternion.
327 ///
328 /// Together with `components::Translation3D`, this defines the pose of the grid relative to the
329 /// map's parent coordinate frame.
331 quaternion =
332 ComponentBatch::from_loggable(_quaternion, Descriptor_quaternion).value_or_throw();
333 return std::move(*this);
334 }
335
336 /// This method makes it possible to pack multiple `quaternion` in a single component batch.
337 ///
338 /// This only makes sense when used in conjunction with `columns`. `with_quaternion` should
339 /// be used when logging a single row's worth of data.
342 ) && {
343 quaternion =
344 ComponentBatch::from_loggable(_quaternion, Descriptor_quaternion).value_or_throw();
345 return std::move(*this);
346 }
347
348 /// Opacity of the voxels after color or colormap application.
349 ///
350 /// Defaults to 1.0 (fully opaque).
352 opacity = ComponentBatch::from_loggable(_opacity, Descriptor_opacity).value_or_throw();
353 return std::move(*this);
354 }
355
356 /// This method makes it possible to pack multiple `opacity` in a single component batch.
357 ///
358 /// This only makes sense when used in conjunction with `columns`. `with_opacity` should
359 /// be used when logging a single row's worth of data.
361 opacity = ComponentBatch::from_loggable(_opacity, Descriptor_opacity).value_or_throw();
362 return std::move(*this);
363 }
364
365 /// Scalar value range for color-mapping.
366 ///
367 /// Defaults to `[0.0, 1.0]`.
370 .value_or_throw();
371 return std::move(*this);
372 }
373
374 /// This method makes it possible to pack multiple `value_range` in a single component batch.
375 ///
376 /// This only makes sense when used in conjunction with `columns`. `with_value_range` should
377 /// be used when logging a single row's worth of data.
380 ) && {
382 .value_or_throw();
383 return std::move(*this);
384 }
385
386 /// Colormap to use when `values` are present and explicit `colors` are not provided.
387 ///
388 /// Defaults to Turbo.
390 colormap =
391 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
392 return std::move(*this);
393 }
394
395 /// This method makes it possible to pack multiple `colormap` in a single component batch.
396 ///
397 /// This only makes sense when used in conjunction with `columns`. `with_colormap` should
398 /// be used when logging a single row's worth of data.
400 ) && {
401 colormap =
402 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
403 return std::move(*this);
404 }
405
406 /// Partitions the component data into multiple sub-batches.
407 ///
408 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
409 /// instead, via `ComponentBatch::partitioned`.
410 ///
411 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
412 ///
413 /// The specified `lengths` must sum to the total length of the component batch.
415
416 /// Partitions the component data into unit-length sub-batches.
417 ///
418 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
419 /// where `n` is automatically guessed.
421 };
422
423} // namespace rerun::archetypes
424
425namespace rerun {
426 /// \private
427 template <typename T>
428 struct AsComponents;
429
430 /// \private
431 template <>
432 struct AsComponents<archetypes::VoxelGridMap> {
433 /// Serialize all set component batches.
434 static Result<Collection<ComponentBatch>> as_batches(
435 const archetypes::VoxelGridMap& archetype
436 );
437 };
438} // 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:87
Colormap
Component: Colormap for mapping scalar values within a given range to a color.
Definition colormap.hpp:28
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
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: A sparse 3D voxel grid map with grid indices and voxel dimensions.
Definition voxel_grid_map.hpp:86
static constexpr auto Descriptor_voxel_size
ComponentDescriptor for the voxel_size field.
Definition voxel_grid_map.hpp:154
VoxelGridMap with_many_colormap(const Collection< rerun::components::Colormap > &_colormap) &&
This method makes it possible to pack multiple colormap in a single component batch.
Definition voxel_grid_map.hpp:399
VoxelGridMap with_many_quaternion(const Collection< rerun::components::RotationQuat > &_quaternion) &&
This method makes it possible to pack multiple quaternion in a single component batch.
Definition voxel_grid_map.hpp:340
VoxelGridMap with_colormap(const rerun::components::Colormap &_colormap) &&
Colormap to use when values are present and explicit colors are not provided.
Definition voxel_grid_map.hpp:389
static constexpr auto Descriptor_translation
ComponentDescriptor for the translation field.
Definition voxel_grid_map.hpp:168
std::optional< ComponentBatch > translation
Translation of the minimum corner of voxel [0, 0, 0].
Definition voxel_grid_map.hpp:112
std::optional< ComponentBatch > value_range
Scalar value range for color-mapping.
Definition voxel_grid_map.hpp:137
std::optional< ComponentBatch > voxel_indices
Indices of the voxels within the grid volume.
Definition voxel_grid_map.hpp:88
VoxelGridMap with_many_rotation_axis_angle(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angle) &&
This method makes it possible to pack multiple rotation_axis_angle in a single component batch.
Definition voxel_grid_map.hpp:317
std::optional< ComponentBatch > voxel_size
The scene-unit dimensions of a single voxel cell.
Definition voxel_grid_map.hpp:94
VoxelGridMap with_translation(const rerun::components::Translation3D &_translation) &&
Translation of the minimum corner of voxel [0, 0, 0].
Definition voxel_grid_map.hpp:279
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition voxel_grid_map.hpp:146
VoxelGridMap with_quaternion(const rerun::components::RotationQuat &_quaternion) &&
Rotation of the grid via quaternion.
Definition voxel_grid_map.hpp:330
VoxelGridMap with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for each voxel.
Definition voxel_grid_map.hpp:268
static constexpr auto Descriptor_colormap
ComponentDescriptor for the colormap field.
Definition voxel_grid_map.hpp:193
static constexpr auto Descriptor_values
ComponentDescriptor for the values field.
Definition voxel_grid_map.hpp:159
std::optional< ComponentBatch > rotation_axis_angle
Rotation of the grid via axis + angle.
Definition voxel_grid_map.hpp:121
VoxelGridMap with_voxel_size(const rerun::components::VoxelSize &_voxel_size) &&
The scene-unit dimensions of a single voxel cell.
Definition voxel_grid_map.hpp:239
static constexpr auto Descriptor_quaternion
ComponentDescriptor for the quaternion field.
Definition voxel_grid_map.hpp:178
VoxelGridMap with_values(const Collection< rerun::components::VoxelValue > &_values) &&
Optional scalar occupancy or value data for each voxel.
Definition voxel_grid_map.hpp:260
VoxelGridMap with_rotation_axis_angle(const rerun::components::RotationAxisAngle &_rotation_axis_angle) &&
Rotation of the grid via axis + angle.
Definition voxel_grid_map.hpp:304
VoxelGridMap with_many_translation(const Collection< rerun::components::Translation3D > &_translation) &&
This method makes it possible to pack multiple translation in a single component batch.
Definition voxel_grid_map.hpp:289
std::optional< ComponentBatch > colors
Optional colors for each voxel.
Definition voxel_grid_map.hpp:104
static constexpr auto Descriptor_value_range
ComponentDescriptor for the value_range field.
Definition voxel_grid_map.hpp:188
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
std::optional< ComponentBatch > quaternion
Rotation of the grid via quaternion.
Definition voxel_grid_map.hpp:127
static constexpr auto Descriptor_opacity
ComponentDescriptor for the opacity field.
Definition voxel_grid_map.hpp:183
VoxelGridMap with_many_value_range(const Collection< rerun::components::ValueRange > &_value_range) &&
This method makes it possible to pack multiple value_range in a single component batch.
Definition voxel_grid_map.hpp:378
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
VoxelGridMap with_many_opacity(const Collection< rerun::components::Opacity > &_opacity) &&
This method makes it possible to pack multiple opacity in a single component batch.
Definition voxel_grid_map.hpp:360
std::optional< ComponentBatch > values
Optional scalar occupancy or value data for each voxel.
Definition voxel_grid_map.hpp:99
std::optional< ComponentBatch > opacity
Opacity of the voxels after color or colormap application.
Definition voxel_grid_map.hpp:132
VoxelGridMap with_many_voxel_size(const Collection< rerun::components::VoxelSize > &_voxel_size) &&
This method makes it possible to pack multiple voxel_size in a single component batch.
Definition voxel_grid_map.hpp:249
static constexpr auto Descriptor_rotation_axis_angle
ComponentDescriptor for the rotation_axis_angle field.
Definition voxel_grid_map.hpp:173
std::optional< ComponentBatch > colormap
Colormap to use when values are present and explicit colors are not provided.
Definition voxel_grid_map.hpp:142
VoxelGridMap with_voxel_indices(const Collection< rerun::components::VoxelIndex > &_voxel_indices) &&
Indices of the voxels within the grid volume.
Definition voxel_grid_map.hpp:227
static constexpr auto Descriptor_voxel_indices
ComponentDescriptor for the voxel_indices field.
Definition voxel_grid_map.hpp:149
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition voxel_grid_map.hpp:164
static VoxelGridMap update_fields()
Update only some specific fields of a VoxelGridMap.
Definition voxel_grid_map.hpp:219
VoxelGridMap with_opacity(const rerun::components::Opacity &_opacity) &&
Opacity of the voxels after color or colormap application.
Definition voxel_grid_map.hpp:351
VoxelGridMap with_value_range(const rerun::components::ValueRange &_value_range) &&
Scalar value range for color-mapping.
Definition voxel_grid_map.hpp:368
static VoxelGridMap clear_fields()
Clear all the fields of a VoxelGridMap.
Component: Degree of transparency ranging from 0.0 (fully transparent) to 1.0 (fully opaque).
Definition opacity.hpp:17
Component: 3D rotation represented by a rotation around a given axis.
Definition rotation_axis_angle.hpp:17
Component: A 3D rotation expressed as a quaternion.
Definition rotation_quat.hpp:18
Component: A translation vector in 3D space.
Definition translation3d.hpp:15
Component: Range of expected or valid values, specifying a lower and upper bound.
Definition value_range.hpp:18
Component: The scene-unit dimensions of one voxel in a sparse 3D voxel grid.
Definition voxel_size.hpp:18