Rerun C++ SDK
Loading...
Searching...
No Matches
points3d.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/points3d.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/keypoint_id.hpp"
11#include "../components/position3d.hpp"
12#include "../components/radius.hpp"
13#include "../components/text.hpp"
14#include "../data_cell.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**: A 3D point cloud with positions and optional colors, radii, labels, etc.
25 ///
26 /// ## Examples
27 ///
28 /// ### Randomly distributed 3D points with varying color and radius
29 /// ![image](https://static.rerun.io/point3d_random/7e94e1806d2c381943748abbb3bedb68d564de24/full.png)
30 ///
31 /// ```cpp
32 /// #include <rerun.hpp>
33 ///
34 /// #include <algorithm>
35 /// #include <random>
36 /// #include <vector>
37 ///
38 /// int main() {
39 /// const auto rec = rerun::RecordingStream("rerun_example_points3d_random");
40 /// rec.spawn().exit_on_failure();
41 ///
42 /// std::default_random_engine gen;
43 /// std::uniform_real_distribution<float> dist_pos(-5.0f, 5.0f);
44 /// std::uniform_real_distribution<float> dist_radius(0.1f, 1.0f);
45 /// // On MSVC uint8_t distributions are not supported.
46 /// std::uniform_int_distribution<int> dist_color(0, 255);
47 ///
48 /// std::vector<rerun::Position3D> points3d(10);
49 /// std::generate(points3d.begin(), points3d.end(), [&] {
50 /// return rerun::Position3D(dist_pos(gen), dist_pos(gen), dist_pos(gen));
51 /// });
52 /// std::vector<rerun::Color> colors(10);
53 /// std::generate(colors.begin(), colors.end(), [&] {
54 /// return rerun::Color(
55 /// static_cast<uint8_t>(dist_color(gen)),
56 /// static_cast<uint8_t>(dist_color(gen)),
57 /// static_cast<uint8_t>(dist_color(gen))
58 /// );
59 /// });
60 /// std::vector<rerun::Radius> radii(10);
61 /// std::generate(radii.begin(), radii.end(), [&] { return dist_radius(gen); });
62 ///
63 /// rec.log("random", rerun::Points3D(points3d).with_colors(colors).with_radii(radii));
64 /// }
65 /// ```
66 ///
67 /// ### Log points with radii given in UI points
68 /// ![image](https://static.rerun.io/point3d_ui_radius/e051a65b4317438bcaea8d0eee016ac9460b5336/full.png)
69 ///
70 /// ```cpp
71 /// #include <rerun.hpp>
72 ///
73 /// int main() {
74 /// const auto rec = rerun::RecordingStream("rerun_example_points3d_ui_radius");
75 /// rec.spawn().exit_on_failure();
76 ///
77 /// // Two blue points with scene unit radii of 0.1 and 0.3.
78 /// rec.log(
79 /// "scene_units",
80 /// rerun::Points3D({{0.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f}})
81 /// // By default, radii are interpreted as world-space units.
82 /// .with_radii({0.1f, 0.3f})
83 /// .with_colors(rerun::Color(0, 0, 255))
84 /// );
85 ///
86 /// // Two red points with ui point radii of 40 and 60.
87 /// // UI points are independent of zooming in Views, but are sensitive to the application UI scaling.
88 /// // For 100% ui scaling, UI points are equal to pixels.
89 /// rec.log(
90 /// "ui_points",
91 /// rerun::Points3D({{0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 1.0f}})
92 /// // rerun::Radius::ui_points produces radii that the viewer interprets as given in ui points.
93 /// .with_radii({
94 /// rerun::Radius::ui_points(40.0f),
95 /// rerun::Radius::ui_points(60.0f),
96 /// })
97 /// .with_colors(rerun::Color(255, 0, 0))
98 /// );
99 /// }
100 /// ```
101 struct Points3D {
102 /// All the 3D positions at which the point cloud shows points.
104
105 /// Optional radii for the points, effectively turning them into circles.
106 std::optional<Collection<rerun::components::Radius>> radii;
107
108 /// Optional colors for the points.
109 std::optional<Collection<rerun::components::Color>> colors;
110
111 /// Optional text labels for the points.
112 ///
113 /// If there's a single label present, it will be placed at the center of the entity.
114 /// Otherwise, each instance will have its own label.
115 std::optional<Collection<rerun::components::Text>> labels;
116
117 /// Optional class Ids for the points.
118 ///
119 /// The class ID provides colors and labels if not specified explicitly.
120 std::optional<Collection<rerun::components::ClassId>> class_ids;
121
122 /// Optional keypoint IDs for the points, identifying them within a class.
123 ///
124 /// If keypoint IDs are passed in but no class IDs were specified, the class ID will
125 /// default to 0.
126 /// This is useful to identify points within a single classification (which is identified
127 /// with `class_id`).
128 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
129 /// detected skeleton.
130 std::optional<Collection<rerun::components::KeypointId>> keypoint_ids;
131
132 public:
133 static constexpr const char IndicatorComponentName[] = "rerun.components.Points3DIndicator";
134
135 /// Indicator component, used to identify the archetype when converting to a list of components.
137
138 public:
139 Points3D() = default;
140 Points3D(Points3D&& other) = default;
141
143 : positions(std::move(_positions)) {}
144
145 /// Optional radii for the points, effectively turning them into circles.
147 radii = std::move(_radii);
148 // See: https://github.com/rerun-io/rerun/issues/4027
149 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
150 }
151
152 /// Optional colors for the points.
154 colors = std::move(_colors);
155 // See: https://github.com/rerun-io/rerun/issues/4027
156 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
157 }
158
159 /// Optional text labels for the points.
160 ///
161 /// If there's a single label present, it will be placed at the center of the entity.
162 /// Otherwise, each instance will have its own label.
164 labels = std::move(_labels);
165 // See: https://github.com/rerun-io/rerun/issues/4027
166 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
167 }
168
169 /// Optional class Ids for the points.
170 ///
171 /// The class ID provides colors and labels if not specified explicitly.
173 class_ids = std::move(_class_ids);
174 // See: https://github.com/rerun-io/rerun/issues/4027
175 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
176 }
177
178 /// Optional keypoint IDs for the points, identifying them within a class.
179 ///
180 /// If keypoint IDs are passed in but no class IDs were specified, the class ID will
181 /// default to 0.
182 /// This is useful to identify points within a single classification (which is identified
183 /// with `class_id`).
184 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
185 /// detected skeleton.
187 keypoint_ids = std::move(_keypoint_ids);
188 // See: https://github.com/rerun-io/rerun/issues/4027
189 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
190 }
191 };
192
193} // namespace rerun::archetypes
194
195namespace rerun {
196 /// \private
197 template <typename T>
198 struct AsComponents;
199
200 /// \private
201 template <>
202 struct AsComponents<archetypes::Points3D> {
203 /// Serialize all set component batches.
204 static Result<std::vector<DataCell>> serialize(const archetypes::Points3D& archetype);
205 };
206} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:46
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:72
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:21
Archetype: A 3D point cloud with positions and optional colors, radii, labels, etc.
Definition points3d.hpp:101
Points3D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the points, effectively turning them into circles.
Definition points3d.hpp:146
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the points.
Definition points3d.hpp:115
Points3D with_keypoint_ids(Collection< rerun::components::KeypointId > _keypoint_ids) &&
Optional keypoint IDs for the points, identifying them within a class.
Definition points3d.hpp:186
Points3D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the points.
Definition points3d.hpp:163
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the points, effectively turning them into circles.
Definition points3d.hpp:106
Points3D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the points.
Definition points3d.hpp:153
Collection< rerun::components::Position3D > positions
All the 3D positions at which the point cloud shows points.
Definition points3d.hpp:103
std::optional< Collection< rerun::components::KeypointId > > keypoint_ids
Optional keypoint IDs for the points, identifying them within a class.
Definition points3d.hpp:130
Points3D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional class Ids for the points.
Definition points3d.hpp:172
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the points.
Definition points3d.hpp:109
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional class Ids for the points.
Definition points3d.hpp:120
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:23