Rerun C++ SDK
Loading...
Searching...
No Matches
line_strips3d.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/archetypes/line_strips3d.def.rs".
3
4#pragma once
5
6#include "../archetype_utils.hpp"
7#include "../collection.hpp"
8#include "../component_batch.hpp"
9#include "../component_column.hpp"
10#include "../components/class_id.hpp"
11#include "../components/color.hpp"
12#include "../components/line_strip3d.hpp"
13#include "../components/radius.hpp"
14#include "../components/show_labels.hpp"
15#include "../components/text.hpp"
16#include "../result.hpp"
17
18#include <cstdint>
19#include <optional>
20#include <utility>
21#include <vector>
22
23namespace rerun::archetypes {
24 /// **Archetype**: 3D line strips with positions and optional colors, radii, labels, etc.
25 ///
26 /// ## Examples
27 ///
28 /// ### Many strips
29 /// ![image](https://static.rerun.io/line_strip3d_batch/15e8ff18a6c95a3191acb0eae6eb04adea3b4874/full.png)
30 ///
31 /// ```cpp
32 /// #include <rerun.hpp>
33 ///
34 /// #include <vector>
35 ///
36 /// int main(int argc, char* argv[]) {
37 /// const auto rec = rerun::RecordingStream("rerun_example_line_strip3d_batch");
38 /// rec.spawn().exit_on_failure();
39 ///
40 /// rerun::Collection<rerun::Vec3D> strip1 = {
41 /// {0.f, 0.f, 2.f},
42 /// {1.f, 0.f, 2.f},
43 /// {1.f, 1.f, 2.f},
44 /// {0.f, 1.f, 2.f},
45 /// };
46 /// rerun::Collection<rerun::Vec3D> strip2 = {
47 /// {0.f, 0.f, 0.f},
48 /// {0.f, 0.f, 1.f},
49 /// {1.f, 0.f, 0.f},
50 /// {1.f, 0.f, 1.f},
51 /// {1.f, 1.f, 0.f},
52 /// {1.f, 1.f, 1.f},
53 /// {0.f, 1.f, 0.f},
54 /// {0.f, 1.f, 1.f},
55 /// };
56 /// rec.log(
57 /// "strips",
58 /// rerun::LineStrips3D({strip1, strip2})
59 /// .with_colors({0xFF0000FF, 0x00FF00FF})
60 /// .with_radii({0.025f, 0.005f})
61 /// .with_labels({"one strip here", "and one strip there"})
62 /// );
63 /// }
64 /// ```
65 ///
66 /// ### Lines with scene & UI radius each
67 /// ![image](https://static.rerun.io/line_strip3d_ui_radius/36b98f47e45747b5a3601511ff39b8d74c61d120/full.png)
68 ///
69 /// ```cpp
70 /// #include <rerun.hpp>
71 ///
72 /// int main(int argc, char* argv[]) {
73 /// const auto rec =
74 /// rerun::RecordingStream("rerun_example_line_strip3d_ui_radius");
75 /// rec.spawn().exit_on_failure();
76 ///
77 /// // A blue line with a scene unit radii of 0.01.
78 /// rerun::LineStrip3D linestrip_blue(
79 /// {{0.f, 0.f, 0.f}, {0.f, 0.f, 1.f}, {1.f, 0.f, 0.f}, {1.f, 0.f, 1.f}}
80 /// );
81 /// rec.log(
82 /// "scene_unit_line",
83 /// rerun::LineStrips3D(linestrip_blue)
84 /// // By default, radii are interpreted as world-space units.
85 /// .with_radii(0.01f)
86 /// .with_colors(rerun::Color(0, 0, 255))
87 /// );
88 ///
89 /// // A red line with a ui point radii of 5.
90 /// // UI points are independent of zooming in Views, but are sensitive to the application UI scaling.
91 /// // For 100 % ui scaling, UI points are equal to pixels.
92 /// rerun::LineStrip3D linestrip_red(
93 /// {{3.f, 0.f, 0.f}, {3.f, 0.f, 1.f}, {4.f, 0.f, 0.f}, {4.f, 0.f, 1.f}}
94 /// );
95 /// rec.log(
96 /// "ui_points_line",
97 /// rerun::LineStrips3D(linestrip_red)
98 /// // By default, radii are interpreted as world-space units.
99 /// .with_radii(rerun::Radius::ui_points(5.0f))
100 /// .with_colors(rerun::Color(255, 0, 0))
101 /// );
102 /// }
103 /// ```
105 /// All the actual 3D line strips that make up the batch.
106 std::optional<ComponentBatch> strips;
107
108 /// Optional radii for the line strips.
109 std::optional<ComponentBatch> radii;
110
111 /// Optional colors for the line strips.
112 ///
113 /// The alpha channel is ignored.
114 std::optional<ComponentBatch> colors;
115
116 /// Optional text labels for the line strips.
117 ///
118 /// If there's a single label present, it will be placed at the center of the entity.
119 /// Otherwise, each instance will have its own label.
120 std::optional<ComponentBatch> labels;
121
122 /// Whether the text labels should be shown.
123 ///
124 /// If not set, labels will automatically appear when there is exactly one label for this entity
125 /// or the number of instances on this entity is under a certain threshold.
126 std::optional<ComponentBatch> show_labels;
127
128 /// Optional `components::ClassId`s for the lines.
129 ///
130 /// The `components::ClassId` provides colors and labels if not specified explicitly.
131 std::optional<ComponentBatch> class_ids;
132
133 public:
134 /// The name of the archetype as used in `ComponentDescriptor`s.
135 static constexpr const char ArchetypeName[] = "rerun.archetypes.LineStrips3D";
136
137 /// `ComponentDescriptor` for the `strips` field.
138 static constexpr auto Descriptor_strips = ComponentDescriptor(
139 ArchetypeName, "LineStrips3D:strips",
141 );
142 /// `ComponentDescriptor` for the `radii` field.
143 static constexpr auto Descriptor_radii = ComponentDescriptor(
145 );
146 /// `ComponentDescriptor` for the `colors` field.
147 static constexpr auto Descriptor_colors = ComponentDescriptor(
149 );
150 /// `ComponentDescriptor` for the `labels` field.
151 static constexpr auto Descriptor_labels = ComponentDescriptor(
153 );
154 /// `ComponentDescriptor` for the `show_labels` field.
156 ArchetypeName, "LineStrips3D:show_labels",
158 );
159 /// `ComponentDescriptor` for the `class_ids` field.
161 ArchetypeName, "LineStrips3D:class_ids",
163 );
164
165 public:
166 LineStrips3D() = default;
167 LineStrips3D(LineStrips3D&& other) = default;
168 LineStrips3D(const LineStrips3D& other) = default;
169 LineStrips3D& operator=(const LineStrips3D& other) = default;
170 LineStrips3D& operator=(LineStrips3D&& other) = default;
171
173 : strips(ComponentBatch::from_loggable(std::move(_strips), Descriptor_strips)
174 .value_or_throw()) {}
175
176 /// Update only some specific fields of a `LineStrips3D`.
178 return LineStrips3D();
179 }
180
181 /// Clear all the fields of a `LineStrips3D`.
183
184 /// All the actual 3D line strips that make up the batch.
186 strips = ComponentBatch::from_loggable(_strips, Descriptor_strips).value_or_throw();
187 return std::move(*this);
188 }
189
190 /// Optional radii for the line strips.
192 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
193 return std::move(*this);
194 }
195
196 /// Optional colors for the line strips.
197 ///
198 /// The alpha channel is ignored.
200 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
201 return std::move(*this);
202 }
203
204 /// Optional text labels for the line strips.
205 ///
206 /// If there's a single label present, it will be placed at the center of the entity.
207 /// Otherwise, each instance will have its own label.
209 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
210 return std::move(*this);
211 }
212
213 /// Whether the text labels should be shown.
214 ///
215 /// If not set, labels will automatically appear when there is exactly one label for this entity
216 /// or the number of instances on this entity is under a certain threshold.
219 .value_or_throw();
220 return std::move(*this);
221 }
222
223 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
224 ///
225 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
226 /// be used when logging a single row's worth of data.
229 ) && {
231 .value_or_throw();
232 return std::move(*this);
233 }
234
235 /// Optional `components::ClassId`s for the lines.
236 ///
237 /// The `components::ClassId` provides colors and labels if not specified explicitly.
239 class_ids =
240 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
241 return std::move(*this);
242 }
243
244 /// Partitions the component data into multiple sub-batches.
245 ///
246 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
247 /// instead, via `ComponentBatch::partitioned`.
248 ///
249 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
250 ///
251 /// The specified `lengths` must sum to the total length of the component batch.
253 return detail::partition_batches(
255 lengths_
256 )
257 .value_or_throw();
258 }
259
260 /// Partitions the component data into unit-length sub-batches.
261 ///
262 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
263 /// where `n` is automatically guessed.
265 return detail::partition_batches_of_unit_length(
267 )
268 .value_or_throw();
269 }
270 };
271
272} // namespace rerun::archetypes
273
274namespace rerun {
275 /// \private
276 template <typename T>
277 struct AsComponents;
278
279 /// \private
280 template <>
281 struct AsComponents<archetypes::LineStrips3D> {
282 /// Serialize all set component batches.
283 static Result<Collection<ComponentBatch>> as_batches(
284 const archetypes::LineStrips3D& archetype
285 ) {
286 return detail::collect_batches(
287 {&archetype.strips,
288 &archetype.radii,
289 &archetype.colors,
290 &archetype.labels,
291 &archetype.show_labels,
292 &archetype.class_ids}
293 );
294 }
295 };
296} // 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:90
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
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: 3D line strips with positions and optional colors, radii, labels, etc.
Definition line_strips3d.hpp:104
std::optional< ComponentBatch > class_ids
Optional components::ClassIds for the lines.
Definition line_strips3d.hpp:131
std::optional< ComponentBatch > labels
Optional text labels for the line strips.
Definition line_strips3d.hpp:120
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition line_strips3d.hpp:160
static LineStrips3D update_fields()
Update only some specific fields of a LineStrips3D.
Definition line_strips3d.hpp:177
LineStrips3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition line_strips3d.hpp:217
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition line_strips3d.hpp:126
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition line_strips3d.hpp:147
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition line_strips3d.hpp:252
LineStrips3D 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 line_strips3d.hpp:227
static constexpr auto Descriptor_strips
ComponentDescriptor for the strips field.
Definition line_strips3d.hpp:138
std::optional< ComponentBatch > radii
Optional radii for the line strips.
Definition line_strips3d.hpp:109
static LineStrips3D clear_fields()
Clear all the fields of a LineStrips3D.
LineStrips3D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the line strips.
Definition line_strips3d.hpp:199
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition line_strips3d.hpp:135
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition line_strips3d.hpp:151
std::optional< ComponentBatch > colors
Optional colors for the line strips.
Definition line_strips3d.hpp:114
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition line_strips3d.hpp:264
std::optional< ComponentBatch > strips
All the actual 3D line strips that make up the batch.
Definition line_strips3d.hpp:106
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition line_strips3d.hpp:155
LineStrips3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the line strips.
Definition line_strips3d.hpp:208
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition line_strips3d.hpp:143
LineStrips3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional components::ClassIds for the lines.
Definition line_strips3d.hpp:238
LineStrips3D with_strips(const Collection< rerun::components::LineStrip3D > &_strips) &&
All the actual 3D line strips that make up the batch.
Definition line_strips3d.hpp:185
LineStrips3D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the line strips.
Definition line_strips3d.hpp:191
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18