Rerun C++ SDK
Loading...
Searching...
No Matches
points3d.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/points3d.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/keypoint_id.hpp"
12#include "../components/position3d.hpp"
13#include "../components/radius.hpp"
14#include "../components/show_labels.hpp"
15#include "../components/text.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**: A 3D point cloud with positions and optional colors, radii, labels, etc.
26 ///
27 /// ## Examples
28 ///
29 /// ### Randomly distributed 3D points with varying color and radius
30 /// ![image](https://static.rerun.io/point3d_random/7e94e1806d2c381943748abbb3bedb68d564de24/full.png)
31 ///
32 /// ```cpp
33 /// #include <rerun.hpp>
34 ///
35 /// #include <algorithm>
36 /// #include <random>
37 /// #include <vector>
38 ///
39 /// int main() {
40 /// const auto rec = rerun::RecordingStream("rerun_example_points3d_random");
41 /// rec.spawn().exit_on_failure();
42 ///
43 /// std::default_random_engine gen;
44 /// std::uniform_real_distribution<float> dist_pos(-5.0f, 5.0f);
45 /// std::uniform_real_distribution<float> dist_radius(0.1f, 1.0f);
46 /// // On MSVC uint8_t distributions are not supported.
47 /// std::uniform_int_distribution<int> dist_color(0, 255);
48 ///
49 /// std::vector<rerun::Position3D> points3d(10);
50 /// std::generate(points3d.begin(), points3d.end(), [&] {
51 /// return rerun::Position3D(dist_pos(gen), dist_pos(gen), dist_pos(gen));
52 /// });
53 /// std::vector<rerun::Color> colors(10);
54 /// std::generate(colors.begin(), colors.end(), [&] {
55 /// return rerun::Color(
56 /// static_cast<uint8_t>(dist_color(gen)),
57 /// static_cast<uint8_t>(dist_color(gen)),
58 /// static_cast<uint8_t>(dist_color(gen))
59 /// );
60 /// });
61 /// std::vector<rerun::Radius> radii(10);
62 /// std::generate(radii.begin(), radii.end(), [&] { return dist_radius(gen); });
63 ///
64 /// rec.log("random", rerun::Points3D(points3d).with_colors(colors).with_radii(radii));
65 /// }
66 /// ```
67 ///
68 /// ### Log points with radii given in UI points
69 /// ![image](https://static.rerun.io/point3d_ui_radius/e051a65b4317438bcaea8d0eee016ac9460b5336/full.png)
70 ///
71 /// ```cpp
72 /// #include <rerun.hpp>
73 ///
74 /// int main() {
75 /// const auto rec = rerun::RecordingStream("rerun_example_points3d_ui_radius");
76 /// rec.spawn().exit_on_failure();
77 ///
78 /// // Two blue points with scene unit radii of 0.1 and 0.3.
79 /// rec.log(
80 /// "scene_units",
81 /// rerun::Points3D({{0.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f}})
82 /// // By default, radii are interpreted as world-space units.
83 /// .with_radii({0.1f, 0.3f})
84 /// .with_colors(rerun::Color(0, 0, 255))
85 /// );
86 ///
87 /// // Two red points with ui point radii of 40 and 60.
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 /// rec.log(
91 /// "ui_points",
92 /// rerun::Points3D({{0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 1.0f}})
93 /// // rerun::Radius::ui_points produces radii that the viewer interprets as given in ui points.
94 /// .with_radii({
95 /// rerun::Radius::ui_points(40.0f),
96 /// rerun::Radius::ui_points(60.0f),
97 /// })
98 /// .with_colors(rerun::Color(255, 0, 0))
99 /// );
100 /// }
101 /// ```
102 ///
103 /// ### Send several point clouds with varying point count over time in a single call
104 /// ![image](https://static.rerun.io/points3d_send_columns/633b524a2ee439b0e3afc3f894f4927ce938a3ec/full.png)
105 ///
106 /// ```cpp
107 /// #include <array>
108 /// #include <rerun.hpp>
109 /// #include <vector>
110 ///
111 /// using namespace std::chrono_literals;
112 ///
113 /// int main() {
114 /// const auto rec = rerun::RecordingStream("rerun_example_send_columns_arrays");
115 /// rec.spawn().exit_on_failure();
116 ///
117 /// // Prepare a point cloud that evolves over time 5 timesteps, changing the number of points in the process.
118 /// std::vector<std::array<float, 3>> positions = {
119 /// // clang-format off
120 /// {1.0, 0.0, 1.0}, {0.5, 0.5, 2.0},
121 /// {1.5, -0.5, 1.5}, {1.0, 1.0, 2.5}, {-0.5, 1.5, 1.0}, {-1.5, 0.0, 2.0},
122 /// {2.0, 0.0, 2.0}, {1.5, -1.5, 3.0}, {0.0, -2.0, 2.5}, {1.0, -1.0, 3.5},
123 /// {-2.0, 0.0, 2.0}, {-1.5, 1.5, 3.0}, {-1.0, 1.0, 3.5},
124 /// {1.0, -1.0, 1.0}, {2.0, -2.0, 2.0}, {3.0, -1.0, 3.0}, {2.0, 0.0, 4.0},
125 /// // clang-format on
126 /// };
127 ///
128 /// // At each time stamp, all points in the cloud share the same but changing color.
129 /// std::vector<uint32_t> colors = {0xFF0000FF, 0x00FF00FF, 0x0000FFFF, 0xFFFF00FF, 0x00FFFFFF};
130 ///
131 /// // Log at seconds 10-14
132 /// auto times = rerun::Collection{10s, 11s, 12s, 13s, 14s};
133 /// auto time_column = rerun::TimeColumn::from_times("time", std::move(times));
134 ///
135 /// // Interpret raw positions and color data as rerun components and partition them.
136 /// auto indicator_batch = rerun::ComponentColumn::from_indicators<rerun::Points3D>(5);
137 /// auto position_batch = rerun::ComponentColumn::from_loggable_with_lengths(
138 /// rerun::Collection<rerun::components::Position3D>(std::move(positions)),
139 /// {2, 4, 4, 3, 4}
140 /// );
141 /// auto color_batch = rerun::ComponentColumn::from_loggable(
142 /// rerun::Collection<rerun::components::Color>(std::move(colors))
143 /// );
144 ///
145 /// rec.send_columns(
146 /// "points",
147 /// time_column,
148 /// {
149 /// indicator_batch.value_or_throw(),
150 /// position_batch.value_or_throw(),
151 /// color_batch.value_or_throw(),
152 /// }
153 /// );
154 /// }
155 /// ```
156 struct Points3D {
157 /// All the 3D positions at which the point cloud shows points.
159
160 /// Optional radii for the points, effectively turning them into circles.
161 std::optional<Collection<rerun::components::Radius>> radii;
162
163 /// Optional colors for the points.
164 std::optional<Collection<rerun::components::Color>> colors;
165
166 /// Optional text labels for the points.
167 ///
168 /// If there's a single label present, it will be placed at the center of the entity.
169 /// Otherwise, each instance will have its own label.
170 std::optional<Collection<rerun::components::Text>> labels;
171
172 /// Optional choice of whether the text labels should be shown by default.
173 std::optional<rerun::components::ShowLabels> show_labels;
174
175 /// Optional class Ids for the points.
176 ///
177 /// The `components::ClassId` provides colors and labels if not specified explicitly.
178 std::optional<Collection<rerun::components::ClassId>> class_ids;
179
180 /// Optional keypoint IDs for the points, identifying them within a class.
181 ///
182 /// If keypoint IDs are passed in but no `components::ClassId`s were specified, the `components::ClassId` will
183 /// default to 0.
184 /// This is useful to identify points within a single classification (which is identified
185 /// with `class_id`).
186 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
187 /// detected skeleton.
188 std::optional<Collection<rerun::components::KeypointId>> keypoint_ids;
189
190 public:
191 static constexpr const char IndicatorComponentName[] = "rerun.components.Points3DIndicator";
192
193 /// Indicator component, used to identify the archetype when converting to a list of components.
195
196 public:
197 Points3D() = default;
198 Points3D(Points3D&& other) = default;
199
201 : positions(std::move(_positions)) {}
202
203 /// Optional radii for the points, effectively turning them into circles.
205 radii = std::move(_radii);
206 // See: https://github.com/rerun-io/rerun/issues/4027
207 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
208 }
209
210 /// Optional colors for the points.
212 colors = std::move(_colors);
213 // See: https://github.com/rerun-io/rerun/issues/4027
214 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
215 }
216
217 /// Optional text labels for the points.
218 ///
219 /// If there's a single label present, it will be placed at the center of the entity.
220 /// Otherwise, each instance will have its own label.
222 labels = std::move(_labels);
223 // See: https://github.com/rerun-io/rerun/issues/4027
224 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
225 }
226
227 /// Optional choice of whether the text labels should be shown by default.
229 show_labels = std::move(_show_labels);
230 // See: https://github.com/rerun-io/rerun/issues/4027
231 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
232 }
233
234 /// Optional class Ids for the points.
235 ///
236 /// The `components::ClassId` provides colors and labels if not specified explicitly.
238 class_ids = std::move(_class_ids);
239 // See: https://github.com/rerun-io/rerun/issues/4027
240 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
241 }
242
243 /// Optional keypoint IDs for the points, identifying them within a class.
244 ///
245 /// If keypoint IDs are passed in but no `components::ClassId`s were specified, the `components::ClassId` will
246 /// default to 0.
247 /// This is useful to identify points within a single classification (which is identified
248 /// with `class_id`).
249 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
250 /// detected skeleton.
252 keypoint_ids = std::move(_keypoint_ids);
253 // See: https://github.com/rerun-io/rerun/issues/4027
254 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
255 }
256 };
257
258} // namespace rerun::archetypes
259
260namespace rerun {
261 /// \private
262 template <typename T>
263 struct AsComponents;
264
265 /// \private
266 template <>
267 struct AsComponents<archetypes::Points3D> {
268 /// Serialize all set component batches.
269 static Result<std::vector<ComponentBatch>> serialize(const archetypes::Points3D& archetype);
270 };
271} // 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:77
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Archetype: A 3D point cloud with positions and optional colors, radii, labels, etc.
Definition points3d.hpp:156
Points3D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the points, effectively turning them into circles.
Definition points3d.hpp:204
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the points.
Definition points3d.hpp:170
Points3D with_keypoint_ids(Collection< rerun::components::KeypointId > _keypoint_ids) &&
Optional keypoint IDs for the points, identifying them within a class.
Definition points3d.hpp:251
Points3D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the points.
Definition points3d.hpp:221
Points3D with_show_labels(rerun::components::ShowLabels _show_labels) &&
Optional choice of whether the text labels should be shown by default.
Definition points3d.hpp:228
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the points, effectively turning them into circles.
Definition points3d.hpp:161
Points3D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the points.
Definition points3d.hpp:211
std::optional< rerun::components::ShowLabels > show_labels
Optional choice of whether the text labels should be shown by default.
Definition points3d.hpp:173
Collection< rerun::components::Position3D > positions
All the 3D positions at which the point cloud shows points.
Definition points3d.hpp:158
std::optional< Collection< rerun::components::KeypointId > > keypoint_ids
Optional keypoint IDs for the points, identifying them within a class.
Definition points3d.hpp:188
Points3D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional class Ids for the points.
Definition points3d.hpp:237
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the points.
Definition points3d.hpp:164
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional class Ids for the points.
Definition points3d.hpp:178
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