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_sdk_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(int argc, char* argv[]) {
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(int argc, char* argv[]) {
72 /// const auto rec =
73 /// rerun::RecordingStream("rerun_example_line_strip3d_ui_radius");
74 /// rec.spawn().exit_on_failure();
75 ///
76 /// // A blue line with a scene unit radii of 0.01.
77 /// rerun::LineStrip3D linestrip_blue(
78 /// {{0.f, 0.f, 0.f}, {0.f, 0.f, 1.f}, {1.f, 0.f, 0.f}, {1.f, 0.f, 1.f}}
79 /// );
80 /// rec.log(
81 /// "scene_unit_line",
82 /// rerun::LineStrips3D(linestrip_blue)
83 /// // By default, radii are interpreted as world-space units.
84 /// .with_radii(0.01f)
85 /// .with_colors(rerun::Color(0, 0, 255))
86 /// );
87 ///
88 /// // A red line with a ui point radii of 5.
89 /// // UI points are independent of zooming in Views, but are sensitive to the application UI scaling.
90 /// // For 100 % ui scaling, UI points are equal to pixels.
91 /// rerun::LineStrip3D linestrip_red(
92 /// {{3.f, 0.f, 0.f}, {3.f, 0.f, 1.f}, {4.f, 0.f, 0.f}, {4.f, 0.f, 1.f}}
93 /// );
94 /// rec.log(
95 /// "ui_points_line",
96 /// rerun::LineStrips3D(linestrip_red)
97 /// // By default, radii are interpreted as world-space units.
98 /// .with_radii(rerun::Radius::ui_points(5.0f))
99 /// .with_colors(rerun::Color(255, 0, 0))
100 /// );
101 /// }
102 /// ```
104 /// All the actual 3D line strips that make up the batch.
105 std::optional<ComponentBatch> strips;
106
107 /// Optional radii for the line strips.
108 std::optional<ComponentBatch> radii;
109
110 /// Optional colors for the line strips.
111 std::optional<ComponentBatch> colors;
112
113 /// Optional text labels for the line strips.
114 ///
115 /// If there's a single label present, it will be placed at the center of the entity.
116 /// Otherwise, each instance will have its own label.
117 std::optional<ComponentBatch> labels;
118
119 /// Whether the text labels should be shown.
120 ///
121 /// If not set, labels will automatically appear when there is exactly one label for this entity
122 /// or the number of instances on this entity is under a certain threshold.
123 std::optional<ComponentBatch> show_labels;
124
125 /// Optional `components::ClassId`s for the lines.
126 ///
127 /// The `components::ClassId` provides colors and labels if not specified explicitly.
128 std::optional<ComponentBatch> class_ids;
129
130 public:
131 /// The name of the archetype as used in `ComponentDescriptor`s.
132 static constexpr const char ArchetypeName[] = "rerun.archetypes.LineStrips3D";
133
134 /// `ComponentDescriptor` for the `strips` field.
135 static constexpr auto Descriptor_strips = ComponentDescriptor(
136 ArchetypeName, "LineStrips3D:strips",
138 );
139 /// `ComponentDescriptor` for the `radii` field.
140 static constexpr auto Descriptor_radii = ComponentDescriptor(
142 );
143 /// `ComponentDescriptor` for the `colors` field.
144 static constexpr auto Descriptor_colors = ComponentDescriptor(
146 );
147 /// `ComponentDescriptor` for the `labels` field.
148 static constexpr auto Descriptor_labels = ComponentDescriptor(
150 );
151 /// `ComponentDescriptor` for the `show_labels` field.
153 ArchetypeName, "LineStrips3D:show_labels",
155 );
156 /// `ComponentDescriptor` for the `class_ids` field.
158 ArchetypeName, "LineStrips3D:class_ids",
160 );
161
162 public:
163 LineStrips3D() = default;
164 LineStrips3D(LineStrips3D&& other) = default;
165 LineStrips3D(const LineStrips3D& other) = default;
166 LineStrips3D& operator=(const LineStrips3D& other) = default;
167 LineStrips3D& operator=(LineStrips3D&& other) = default;
168
170 : strips(ComponentBatch::from_loggable(std::move(_strips), Descriptor_strips)
171 .value_or_throw()) {}
172
173 /// Update only some specific fields of a `LineStrips3D`.
175 return LineStrips3D();
176 }
177
178 /// Clear all the fields of a `LineStrips3D`.
180
181 /// All the actual 3D line strips that make up the batch.
183 strips = ComponentBatch::from_loggable(_strips, Descriptor_strips).value_or_throw();
184 return std::move(*this);
185 }
186
187 /// Optional radii for the line strips.
189 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
190 return std::move(*this);
191 }
192
193 /// Optional colors for the line strips.
195 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
196 return std::move(*this);
197 }
198
199 /// Optional text labels for the line strips.
200 ///
201 /// If there's a single label present, it will be placed at the center of the entity.
202 /// Otherwise, each instance will have its own label.
204 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
205 return std::move(*this);
206 }
207
208 /// Whether the text labels should be shown.
209 ///
210 /// If not set, labels will automatically appear when there is exactly one label for this entity
211 /// or the number of instances on this entity is under a certain threshold.
214 .value_or_throw();
215 return std::move(*this);
216 }
217
218 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
219 ///
220 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
221 /// be used when logging a single row's worth of data.
224 ) && {
226 .value_or_throw();
227 return std::move(*this);
228 }
229
230 /// Optional `components::ClassId`s for the lines.
231 ///
232 /// The `components::ClassId` provides colors and labels if not specified explicitly.
234 class_ids =
235 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
236 return std::move(*this);
237 }
238
239 /// Partitions the component data into multiple sub-batches.
240 ///
241 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
242 /// instead, via `ComponentBatch::partitioned`.
243 ///
244 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
245 ///
246 /// The specified `lengths` must sum to the total length of the component batch.
248
249 /// Partitions the component data into unit-length sub-batches.
250 ///
251 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
252 /// where `n` is automatically guessed.
254 };
255
256} // namespace rerun::archetypes
257
258namespace rerun {
259 /// \private
260 template <typename T>
261 struct AsComponents;
262
263 /// \private
264 template <>
265 struct AsComponents<archetypes::LineStrips3D> {
266 /// Serialize all set component batches.
267 static Result<Collection<ComponentBatch>> as_batches(
268 const archetypes::LineStrips3D& archetype
269 );
270 };
271} // 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
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:103
std::optional< ComponentBatch > class_ids
Optional components::ClassIds for the lines.
Definition line_strips3d.hpp:128
std::optional< ComponentBatch > labels
Optional text labels for the line strips.
Definition line_strips3d.hpp:117
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition line_strips3d.hpp:157
static LineStrips3D update_fields()
Update only some specific fields of a LineStrips3D.
Definition line_strips3d.hpp:174
LineStrips3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition line_strips3d.hpp:212
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition line_strips3d.hpp:123
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition line_strips3d.hpp:144
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:222
static constexpr auto Descriptor_strips
ComponentDescriptor for the strips field.
Definition line_strips3d.hpp:135
std::optional< ComponentBatch > radii
Optional radii for the line strips.
Definition line_strips3d.hpp:108
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:194
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition line_strips3d.hpp:132
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition line_strips3d.hpp:148
std::optional< ComponentBatch > colors
Optional colors for the line strips.
Definition line_strips3d.hpp:111
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:105
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition line_strips3d.hpp:152
LineStrips3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the line strips.
Definition line_strips3d.hpp:203
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition line_strips3d.hpp:140
LineStrips3D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional components::ClassIds for the lines.
Definition line_strips3d.hpp:233
LineStrips3D with_strips(const Collection< rerun::components::LineStrip3D > &_strips) &&
All the actual 3D line strips that make up the batch.
Definition line_strips3d.hpp:182
LineStrips3D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the line strips.
Definition line_strips3d.hpp:188
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18