Rerun C++ SDK
Loading...
Searching...
No Matches
arrows3d.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/re_types/definitions/rerun/archetypes/arrows3d.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../components/class_id.hpp"
9#include "../components/color.hpp"
10#include "../components/instance_key.hpp"
11#include "../components/position3d.hpp"
12#include "../components/radius.hpp"
13#include "../components/text.hpp"
14#include "../components/vector3d.hpp"
15#include "../data_cell.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 std::optional<Collection<rerun::components::Text>> labels;
85
86 /// Optional class Ids for the points.
87 ///
88 /// The class ID provides colors and labels if not specified explicitly.
89 std::optional<Collection<rerun::components::ClassId>> class_ids;
90
91 /// Unique identifiers for each individual point in the batch.
92 std::optional<Collection<rerun::components::InstanceKey>> instance_keys;
93
94 public:
95 static constexpr const char IndicatorComponentName[] = "rerun.components.Arrows3DIndicator";
96
97 /// Indicator component, used to identify the archetype when converting to a list of components.
99
100 public:
101 // Extensions to generated type defined in 'arrows3d_ext.cpp'
102
103 /// Creates new 3D arrows pointing in the given directions, with a base at the origin (0, 0,
104 /// 0).
106 Arrows3D arrows;
107 arrows.vectors = std::move(vectors_);
108 return arrows;
109 }
110
111 public:
112 Arrows3D() = default;
113 Arrows3D(Arrows3D&& other) = default;
114
115 /// All the origin (base) positions for each arrow in the batch.
116 ///
117 /// If no origins are set, (0, 0, 0) is used as the origin for each arrow.
119 origins = std::move(_origins);
120 // See: https://github.com/rerun-io/rerun/issues/4027
121 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
122 }
123
124 /// Optional radii for the arrows.
125 ///
126 /// The shaft is rendered as a line with `radius = 0.5 * radius`.
127 /// The tip is rendered with `height = 2.0 * radius` and `radius = 1.0 * radius`.
129 radii = std::move(_radii);
130 // See: https://github.com/rerun-io/rerun/issues/4027
131 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
132 }
133
134 /// Optional colors for the points.
136 colors = std::move(_colors);
137 // See: https://github.com/rerun-io/rerun/issues/4027
138 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
139 }
140
141 /// Optional text labels for the arrows.
143 labels = std::move(_labels);
144 // See: https://github.com/rerun-io/rerun/issues/4027
145 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
146 }
147
148 /// Optional class Ids for the points.
149 ///
150 /// The class ID provides colors and labels if not specified explicitly.
152 class_ids = std::move(_class_ids);
153 // See: https://github.com/rerun-io/rerun/issues/4027
154 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
155 }
156
157 /// Unique identifiers for each individual point in the batch.
159 instance_keys = std::move(_instance_keys);
160 // See: https://github.com/rerun-io/rerun/issues/4027
161 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
162 }
163
164 /// Returns the number of primary instances of this archetype.
165 size_t num_instances() const {
166 return vectors.size();
167 }
168 };
169
170} // namespace rerun::archetypes
171
172namespace rerun {
173 /// \private
174 template <typename T>
175 struct AsComponents;
176
177 /// \private
178 template <>
179 struct AsComponents<archetypes::Arrows3D> {
180 /// Serialize all set component batches.
181 static Result<std::vector<DataCell>> serialize(const archetypes::Arrows3D& archetype);
182 };
183} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:47
size_t size() const
Returns the number of instances in this collection.
Definition collection.hpp:254
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:66
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Archetype: 3D arrows with optional colors, radii, labels, etc.
Definition arrows3d.hpp:65
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional class Ids for the points.
Definition arrows3d.hpp:89
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:84
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the points.
Definition arrows3d.hpp:81
Arrows3D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the arrows.
Definition arrows3d.hpp:128
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:105
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:118
std::optional< Collection< rerun::components::InstanceKey > > instance_keys
Unique identifiers for each individual point in the batch.
Definition arrows3d.hpp:92
size_t num_instances() const
Returns the number of primary instances of this archetype.
Definition arrows3d.hpp:165
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:151
Arrows3D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the points.
Definition arrows3d.hpp:135
Arrows3D with_instance_keys(Collection< rerun::components::InstanceKey > _instance_keys) &&
Unique identifiers for each individual point in the batch.
Definition arrows3d.hpp:158
Arrows3D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the arrows.
Definition arrows3d.hpp:142
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:23