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