Rerun C++ SDK
Loading...
Searching...
No Matches
arrows3d.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/arrows3d.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../component_batch.hpp"
9#include "../components/class_id.hpp"
10#include "../components/color.hpp"
11#include "../components/position3d.hpp"
12#include "../components/radius.hpp"
13#include "../components/show_labels.hpp"
14#include "../components/text.hpp"
15#include "../components/vector3d.hpp"
16#include "../indicator_component.hpp"
17#include "../result.hpp"
18
19#include <cstdint>
20#include <optional>
21#include <utility>
22#include <vector>
23
24namespace rerun::archetypes {
25 /// **Archetype**: 3D arrows with optional colors, radii, labels, etc.
26 ///
27 /// ## Example
28 ///
29 /// ### Simple batch of 3D arrows
30 /// ![image](https://static.rerun.io/arrow3d_simple/55e2f794a520bbf7527d7b828b0264732146c5d0/full.png)
31 ///
32 /// ```cpp
33 /// #include <rerun.hpp>
34 ///
35 /// #include <cmath>
36 /// #include <vector>
37 ///
38 /// constexpr float TAU = 6.28318530717958647692528676655900577f;
39 ///
40 /// int main() {
41 /// const auto rec = rerun::RecordingStream("rerun_example_arrow3d");
42 /// rec.spawn().exit_on_failure();
43 ///
44 /// std::vector<rerun::Position3D> origins;
45 /// std::vector<rerun::Vector3D> vectors;
46 /// std::vector<rerun::Color> colors;
47 ///
48 /// for (int i = 0; i <100; ++i) {
49 /// origins.push_back({0, 0, 0});
50 ///
51 /// float angle = TAU * static_cast<float>(i) * 0.01f;
52 /// float length = log2f(static_cast<float>(i + 1));
53 /// vectors.push_back({length * sinf(angle), 0.0, length * cosf(angle)});
54 ///
55 /// uint8_t c = static_cast<uint8_t>(round(angle / TAU * 255.0f));
56 /// colors.push_back({static_cast<uint8_t>(255 - c), c, 128, 128});
57 /// }
58 ///
59 /// rec.log(
60 /// "arrows",
61 /// rerun::Arrows3D::from_vectors(vectors).with_origins(origins).with_colors(colors)
62 /// );
63 /// }
64 /// ```
65 struct Arrows3D {
66 /// All the vectors for each arrow in the batch.
68
69 /// All the origin (base) positions for each arrow in the batch.
70 ///
71 /// If no origins are set, (0, 0, 0) is used as the origin for each arrow.
72 std::optional<Collection<rerun::components::Position3D>> origins;
73
74 /// Optional radii for the arrows.
75 ///
76 /// The shaft is rendered as a line with `radius = 0.5 * radius`.
77 /// The tip is rendered with `height = 2.0 * radius` and `radius = 1.0 * radius`.
78 std::optional<Collection<rerun::components::Radius>> radii;
79
80 /// Optional colors for the points.
81 std::optional<Collection<rerun::components::Color>> colors;
82
83 /// Optional text labels for the arrows.
84 ///
85 /// If there's a single label present, it will be placed at the center of the entity.
86 /// Otherwise, each instance will have its own label.
87 std::optional<Collection<rerun::components::Text>> labels;
88
89 /// Optional choice of whether the text labels should be shown by default.
90 std::optional<rerun::components::ShowLabels> show_labels;
91
92 /// Optional class Ids for the points.
93 ///
94 /// The `components::ClassId` provides colors and labels if not specified explicitly.
95 std::optional<Collection<rerun::components::ClassId>> class_ids;
96
97 public:
98 static constexpr const char IndicatorComponentName[] = "rerun.components.Arrows3DIndicator";
99
100 /// Indicator component, used to identify the archetype when converting to a list of components.
102
103 public: // START of extensions from arrows3d_ext.cpp:
104 /// Creates new 3D arrows pointing in the given directions, with a base at the origin (0, 0,
105 /// 0).
107 Arrows3D arrows;
108 arrows.vectors = std::move(vectors_);
109 return arrows;
110 }
111
112 // END of extensions from arrows3d_ext.cpp, start of generated code:
113
114 public:
115 Arrows3D() = default;
116 Arrows3D(Arrows3D&& other) = default;
117
118 /// All the origin (base) positions for each arrow in the batch.
119 ///
120 /// If no origins are set, (0, 0, 0) is used as the origin for each arrow.
122 origins = std::move(_origins);
123 // See: https://github.com/rerun-io/rerun/issues/4027
124 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
125 }
126
127 /// Optional radii for the arrows.
128 ///
129 /// The shaft is rendered as a line with `radius = 0.5 * radius`.
130 /// The tip is rendered with `height = 2.0 * radius` and `radius = 1.0 * radius`.
132 radii = std::move(_radii);
133 // See: https://github.com/rerun-io/rerun/issues/4027
134 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
135 }
136
137 /// Optional colors for the points.
139 colors = std::move(_colors);
140 // See: https://github.com/rerun-io/rerun/issues/4027
141 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
142 }
143
144 /// Optional text labels for the arrows.
145 ///
146 /// If there's a single label present, it will be placed at the center of the entity.
147 /// Otherwise, each instance will have its own label.
149 labels = std::move(_labels);
150 // See: https://github.com/rerun-io/rerun/issues/4027
151 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
152 }
153
154 /// Optional choice of whether the text labels should be shown by default.
156 show_labels = std::move(_show_labels);
157 // See: https://github.com/rerun-io/rerun/issues/4027
158 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
159 }
160
161 /// Optional class Ids for the points.
162 ///
163 /// The `components::ClassId` provides colors and labels if not specified explicitly.
165 class_ids = std::move(_class_ids);
166 // See: https://github.com/rerun-io/rerun/issues/4027
167 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
168 }
169 };
170
171} // namespace rerun::archetypes
172
173namespace rerun {
174 /// \private
175 template <typename T>
176 struct AsComponents;
177
178 /// \private
179 template <>
180 struct AsComponents<archetypes::Arrows3D> {
181 /// Serialize all set component batches.
182 static Result<std::vector<ComponentBatch>> serialize(const archetypes::Arrows3D& archetype);
183 };
184} // 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:73
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
Archetype: 3D arrows with optional colors, radii, labels, etc.
Definition arrows3d.hpp:65
Arrows3D with_show_labels(rerun::components::ShowLabels _show_labels) &&
Optional choice of whether the text labels should be shown by default.
Definition arrows3d.hpp:155
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional class Ids for the points.
Definition arrows3d.hpp:95
Collection< rerun::components::Vector3D > vectors
All the vectors for each arrow in the batch.
Definition arrows3d.hpp:67
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the arrows.
Definition arrows3d.hpp:87
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the points.
Definition arrows3d.hpp:81
std::optional< rerun::components::ShowLabels > show_labels
Optional choice of whether the text labels should be shown by default.
Definition arrows3d.hpp:90
Arrows3D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the arrows.
Definition arrows3d.hpp:131
static Arrows3D from_vectors(Collection< components::Vector3D > vectors_)
Creates new 3D arrows pointing in the given directions, with a base at the origin (0,...
Definition arrows3d.hpp:106
std::optional< Collection< rerun::components::Position3D > > origins
All the origin (base) positions for each arrow in the batch.
Definition arrows3d.hpp:72
Arrows3D with_origins(Collection< rerun::components::Position3D > _origins) &&
All the origin (base) positions for each arrow in the batch.
Definition arrows3d.hpp:121
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the arrows.
Definition arrows3d.hpp:78
Arrows3D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional class Ids for the points.
Definition arrows3d.hpp:164
Arrows3D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the points.
Definition arrows3d.hpp:138
Arrows3D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the arrows.
Definition arrows3d.hpp:148
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:30
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18