Rerun C++ SDK
Loading...
Searching...
No Matches
tensor_slice_selection.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/build/re_type_definitions/rerun/blueprint/archetypes/tensor_slice_selection.def.rs".
3
4#pragma once
5
6#include "../../archetype_utils.hpp"
7#include "../../blueprint/components/tensor_dimension_index_slider.hpp"
8#include "../../collection.hpp"
9#include "../../component_batch.hpp"
10#include "../../component_column.hpp"
11#include "../../components/tensor_dimension_index_selection.hpp"
12#include "../../components/tensor_height_dimension.hpp"
13#include "../../components/tensor_width_dimension.hpp"
14#include "../../result.hpp"
15
16#include <cstdint>
17#include <optional>
18#include <utility>
19#include <vector>
20
21namespace rerun::blueprint::archetypes {
22 /// **Archetype**: Specifies a 2D slice of a tensor.
23 ///
24 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
25 ///
27 /// Which dimension to map to width.
28 ///
29 /// If not specified, the height will be determined automatically based on the name and index of the dimension.
30 std::optional<ComponentBatch> width;
31
32 /// Which dimension to map to height.
33 ///
34 /// If not specified, the height will be determined automatically based on the name and index of the dimension.
35 std::optional<ComponentBatch> height;
36
37 /// Selected indices for all other dimensions.
38 ///
39 /// If any of the here listed dimensions is equal to `width` or `height`, it will be ignored.
40 std::optional<ComponentBatch> indices;
41
42 /// Any dimension listed here will have a slider for the index.
43 ///
44 /// Edits to the sliders will directly manipulate dimensions on the `indices` list.
45 /// If any of the here listed dimensions is equal to `width` or `height`, it will be ignored.
46 /// If not specified, adds slides for any dimension in `indices`.
47 std::optional<ComponentBatch> slider;
48
49 public:
50 /// The name of the archetype as used in `ComponentDescriptor`s.
51 static constexpr const char ArchetypeName[] =
52 "rerun.blueprint.archetypes.TensorSliceSelection";
53
54 /// `ComponentDescriptor` for the `width` field.
55 static constexpr auto Descriptor_width = ComponentDescriptor(
56 ArchetypeName, "TensorSliceSelection:width",
58 );
59 /// `ComponentDescriptor` for the `height` field.
60 static constexpr auto Descriptor_height = ComponentDescriptor(
61 ArchetypeName, "TensorSliceSelection:height",
63 );
64 /// `ComponentDescriptor` for the `indices` field.
65 static constexpr auto Descriptor_indices = ComponentDescriptor(
66 ArchetypeName, "TensorSliceSelection:indices",
68 );
69 /// `ComponentDescriptor` for the `slider` field.
70 static constexpr auto Descriptor_slider = ComponentDescriptor(
71 ArchetypeName, "TensorSliceSelection:slider",
73 );
74
75 public:
76 TensorSliceSelection() = default;
78 TensorSliceSelection(const TensorSliceSelection& other) = default;
79 TensorSliceSelection& operator=(const TensorSliceSelection& other) = default;
80 TensorSliceSelection& operator=(TensorSliceSelection&& other) = default;
81
82 /// Update only some specific fields of a `TensorSliceSelection`.
84 return TensorSliceSelection();
85 }
86
87 /// Clear all the fields of a `TensorSliceSelection`.
89
90 /// Which dimension to map to width.
91 ///
92 /// If not specified, the height will be determined automatically based on the name and index of the dimension.
94 width = ComponentBatch::from_loggable(_width, Descriptor_width).value_or_throw();
95 return std::move(*this);
96 }
97
98 /// Which dimension to map to height.
99 ///
100 /// If not specified, the height will be determined automatically based on the name and index of the dimension.
102 ) && {
103 height = ComponentBatch::from_loggable(_height, Descriptor_height).value_or_throw();
104 return std::move(*this);
105 }
106
107 /// Selected indices for all other dimensions.
108 ///
109 /// If any of the here listed dimensions is equal to `width` or `height`, it will be ignored.
112 ) && {
113 indices = ComponentBatch::from_loggable(_indices, Descriptor_indices).value_or_throw();
114 return std::move(*this);
115 }
116
117 /// Any dimension listed here will have a slider for the index.
118 ///
119 /// Edits to the sliders will directly manipulate dimensions on the `indices` list.
120 /// If any of the here listed dimensions is equal to `width` or `height`, it will be ignored.
121 /// If not specified, adds slides for any dimension in `indices`.
124 ) && {
125 slider = ComponentBatch::from_loggable(_slider, Descriptor_slider).value_or_throw();
126 return std::move(*this);
127 }
128
129 /// Partitions the component data into multiple sub-batches.
130 ///
131 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
132 /// instead, via `ComponentBatch::partitioned`.
133 ///
134 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
135 ///
136 /// The specified `lengths` must sum to the total length of the component batch.
138 return detail::partition_batches({&width, &height, &indices, &slider}, lengths_)
139 .value_or_throw();
140 }
141
142 /// Partitions the component data into unit-length sub-batches.
143 ///
144 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
145 /// where `n` is automatically guessed.
147 return detail::partition_batches_of_unit_length({&width, &height, &indices, &slider})
148 .value_or_throw();
149 }
150 };
151
152} // namespace rerun::blueprint::archetypes
153
154namespace rerun {
155 /// \private
156 template <typename T>
157 struct AsComponents;
158
159 /// \private
160 template <>
161 struct AsComponents<blueprint::archetypes::TensorSliceSelection> {
162 /// Serialize all set component batches.
163 static Result<Collection<ComponentBatch>> as_batches(
165 ) {
166 return detail::collect_batches(
167 {&archetype.width, &archetype.height, &archetype.indices, &archetype.slider}
168 );
169 }
170 };
171} // 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 Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
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: Specifies a 2D slice of a tensor.
Definition tensor_slice_selection.hpp:26
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition tensor_slice_selection.hpp:51
std::optional< ComponentBatch > width
Which dimension to map to width.
Definition tensor_slice_selection.hpp:30
std::optional< ComponentBatch > indices
Selected indices for all other dimensions.
Definition tensor_slice_selection.hpp:40
static constexpr auto Descriptor_slider
ComponentDescriptor for the slider field.
Definition tensor_slice_selection.hpp:70
TensorSliceSelection with_height(const rerun::components::TensorHeightDimension &_height) &&
Which dimension to map to height.
Definition tensor_slice_selection.hpp:101
static constexpr auto Descriptor_indices
ComponentDescriptor for the indices field.
Definition tensor_slice_selection.hpp:65
TensorSliceSelection with_width(const rerun::components::TensorWidthDimension &_width) &&
Which dimension to map to width.
Definition tensor_slice_selection.hpp:93
TensorSliceSelection with_slider(const Collection< rerun::blueprint::components::TensorDimensionIndexSlider > &_slider) &&
Any dimension listed here will have a slider for the index.
Definition tensor_slice_selection.hpp:122
static constexpr auto Descriptor_width
ComponentDescriptor for the width field.
Definition tensor_slice_selection.hpp:55
TensorSliceSelection with_indices(const Collection< rerun::components::TensorDimensionIndexSelection > &_indices) &&
Selected indices for all other dimensions.
Definition tensor_slice_selection.hpp:110
static TensorSliceSelection update_fields()
Update only some specific fields of a TensorSliceSelection.
Definition tensor_slice_selection.hpp:83
static constexpr auto Descriptor_height
ComponentDescriptor for the height field.
Definition tensor_slice_selection.hpp:60
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition tensor_slice_selection.hpp:137
static TensorSliceSelection clear_fields()
Clear all the fields of a TensorSliceSelection.
std::optional< ComponentBatch > height
Which dimension to map to height.
Definition tensor_slice_selection.hpp:35
std::optional< ComponentBatch > slider
Any dimension listed here will have a slider for the index.
Definition tensor_slice_selection.hpp:47
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition tensor_slice_selection.hpp:146
Component: Specifies which dimension to use for height.
Definition tensor_height_dimension.hpp:14
Component: Specifies which dimension to use for width.
Definition tensor_width_dimension.hpp:14