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 "../indicator_component.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() {
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() {
73 /// const auto rec = 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 /// Optional choice of whether the text labels should be shown by default.
120 std::optional<ComponentBatch> show_labels;
121
122 /// Optional `components::ClassId`s for the lines.
123 ///
124 /// The `components::ClassId` provides colors and labels if not specified explicitly.
125 std::optional<ComponentBatch> class_ids;
126
127 public:
128 static constexpr const char IndicatorComponentName[] =
129 "rerun.components.LineStrips3DIndicator";
130
131 /// Indicator component, used to identify the archetype when converting to a list of components.
133 /// The name of the archetype as used in `ComponentDescriptor`s.
134 static constexpr const char ArchetypeName[] = "rerun.archetypes.LineStrips3D";
135
136 /// `ComponentDescriptor` for the `strips` field.
137 static constexpr auto Descriptor_strips = ComponentDescriptor(
138 ArchetypeName, "strips",
140 );
141 /// `ComponentDescriptor` for the `radii` field.
142 static constexpr auto Descriptor_radii = ComponentDescriptor(
144 );
145 /// `ComponentDescriptor` for the `colors` field.
146 static constexpr auto Descriptor_colors = ComponentDescriptor(
148 );
149 /// `ComponentDescriptor` for the `labels` field.
150 static constexpr auto Descriptor_labels = ComponentDescriptor(
152 );
153 /// `ComponentDescriptor` for the `show_labels` field.
155 ArchetypeName, "show_labels",
157 );
158 /// `ComponentDescriptor` for the `class_ids` field.
160 ArchetypeName, "class_ids",
162 );
163
164 public:
165 LineStrips3D() = default;
166 LineStrips3D(LineStrips3D&& other) = default;
167 LineStrips3D(const LineStrips3D& other) = default;
168 LineStrips3D& operator=(const LineStrips3D& other) = default;
169 LineStrips3D& operator=(LineStrips3D&& other) = default;
170
172 : strips(ComponentBatch::from_loggable(std::move(_strips), Descriptor_strips)
173 .value_or_throw()) {}
174
175 /// Update only some specific fields of a `LineStrips3D`.
177 return LineStrips3D();
178 }
179
180 /// Clear all the fields of a `LineStrips3D`.
182
183 /// All the actual 3D line strips that make up the batch.
185 strips = ComponentBatch::from_loggable(_strips, Descriptor_strips).value_or_throw();
186 return std::move(*this);
187 }
188
189 /// Optional radii for the line strips.
191 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
192 return std::move(*this);
193 }
194
195 /// Optional colors for the line strips.
197 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
198 return std::move(*this);
199 }
200
201 /// Optional text labels for the line strips.
202 ///
203 /// If there's a single label present, it will be placed at the center of the entity.
204 /// Otherwise, each instance will have its own label.
206 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
207 return std::move(*this);
208 }
209
210 /// Optional choice of whether the text labels should be shown by default.
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=rerun::Loggable< T >::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:14
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:125
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:159
static LineStrips3D update_fields()
Update only some specific fields of a LineStrips3D.
Definition line_strips3d.hpp:176
LineStrips3D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Optional choice of whether the text labels should be shown by default.
Definition line_strips3d.hpp:211
std::optional< ComponentBatch > show_labels
Optional choice of whether the text labels should be shown by default.
Definition line_strips3d.hpp:120
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition line_strips3d.hpp:146
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:137
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:196
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition line_strips3d.hpp:134
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition line_strips3d.hpp:150
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:154
LineStrips3D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the line strips.
Definition line_strips3d.hpp:205
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition line_strips3d.hpp:142
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:184
LineStrips3D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the line strips.
Definition line_strips3d.hpp:190
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:19