/
points3d.hpp
165 lines (144 loc) · 6.71 KB
/
points3d.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
// Based on "crates/re_types/definitions/rerun/archetypes/points3d.fbs".
#pragma once
#include "../collection.hpp"
#include "../compiler_utils.hpp"
#include "../components/class_id.hpp"
#include "../components/color.hpp"
#include "../components/keypoint_id.hpp"
#include "../components/position3d.hpp"
#include "../components/radius.hpp"
#include "../components/text.hpp"
#include "../data_cell.hpp"
#include "../indicator_component.hpp"
#include "../result.hpp"
#include <cstdint>
#include <optional>
#include <utility>
#include <vector>
namespace rerun::archetypes {
/// **Archetype**: A 3D point cloud with positions and optional colors, radii, labels, etc.
///
/// ## Example
///
/// ### Randomly distributed 3D points with varying color and radius
/// ![image](https://static.rerun.io/point3d_random/7e94e1806d2c381943748abbb3bedb68d564de24/full.png)
///
/// ```cpp
/// #include <rerun.hpp>
///
/// #include <algorithm>
/// #include <random>
/// #include <vector>
///
/// int main() {
/// const auto rec = rerun::RecordingStream("rerun_example_points3d_random");
/// rec.spawn().exit_on_failure();
///
/// std::default_random_engine gen;
/// std::uniform_real_distribution<float> dist_pos(-5.0f, 5.0f);
/// std::uniform_real_distribution<float> dist_radius(0.1f, 1.0f);
/// // On MSVC uint8_t distributions are not supported.
/// std::uniform_int_distribution<int> dist_color(0, 255);
///
/// std::vector<rerun::Position3D> points3d(10);
/// std::generate(points3d.begin(), points3d.end(), [&] {
/// return rerun::Position3D(dist_pos(gen), dist_pos(gen), dist_pos(gen));
/// });
/// std::vector<rerun::Color> colors(10);
/// std::generate(colors.begin(), colors.end(), [&] {
/// return rerun::Color(
/// static_cast<uint8_t>(dist_color(gen)),
/// static_cast<uint8_t>(dist_color(gen)),
/// static_cast<uint8_t>(dist_color(gen))
/// );
/// });
/// std::vector<rerun::Radius> radii(10);
/// std::generate(radii.begin(), radii.end(), [&] { return dist_radius(gen); });
///
/// rec.log("random", rerun::Points3D(points3d).with_colors(colors).with_radii(radii));
/// }
/// ```
struct Points3D {
/// All the 3D positions at which the point cloud shows points.
Collection<rerun::components::Position3D> positions;
/// Optional radii for the points, effectively turning them into circles.
std::optional<Collection<rerun::components::Radius>> radii;
/// Optional colors for the points.
std::optional<Collection<rerun::components::Color>> colors;
/// Optional text labels for the points.
std::optional<Collection<rerun::components::Text>> labels;
/// Optional class Ids for the points.
///
/// The class ID provides colors and labels if not specified explicitly.
std::optional<Collection<rerun::components::ClassId>> class_ids;
/// Optional keypoint IDs for the points, identifying them within a class.
///
/// If keypoint IDs are passed in but no class IDs were specified, the class ID will
/// default to 0.
/// This is useful to identify points within a single classification (which is identified
/// with `class_id`).
/// E.g. the classification might be 'Person' and the keypoints refer to joints on a
/// detected skeleton.
std::optional<Collection<rerun::components::KeypointId>> keypoint_ids;
public:
static constexpr const char IndicatorComponentName[] = "rerun.components.Points3DIndicator";
/// Indicator component, used to identify the archetype when converting to a list of components.
using IndicatorComponent = rerun::components::IndicatorComponent<IndicatorComponentName>;
public:
Points3D() = default;
Points3D(Points3D&& other) = default;
explicit Points3D(Collection<rerun::components::Position3D> _positions)
: positions(std::move(_positions)) {}
/// Optional radii for the points, effectively turning them into circles.
Points3D with_radii(Collection<rerun::components::Radius> _radii) && {
radii = std::move(_radii);
// See: https://github.com/rerun-io/rerun/issues/4027
RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
}
/// Optional colors for the points.
Points3D with_colors(Collection<rerun::components::Color> _colors) && {
colors = std::move(_colors);
// See: https://github.com/rerun-io/rerun/issues/4027
RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
}
/// Optional text labels for the points.
Points3D with_labels(Collection<rerun::components::Text> _labels) && {
labels = std::move(_labels);
// See: https://github.com/rerun-io/rerun/issues/4027
RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
}
/// Optional class Ids for the points.
///
/// The class ID provides colors and labels if not specified explicitly.
Points3D with_class_ids(Collection<rerun::components::ClassId> _class_ids) && {
class_ids = std::move(_class_ids);
// See: https://github.com/rerun-io/rerun/issues/4027
RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
}
/// Optional keypoint IDs for the points, identifying them within a class.
///
/// If keypoint IDs are passed in but no class IDs were specified, the class ID will
/// default to 0.
/// This is useful to identify points within a single classification (which is identified
/// with `class_id`).
/// E.g. the classification might be 'Person' and the keypoints refer to joints on a
/// detected skeleton.
Points3D with_keypoint_ids(Collection<rerun::components::KeypointId> _keypoint_ids) && {
keypoint_ids = std::move(_keypoint_ids);
// See: https://github.com/rerun-io/rerun/issues/4027
RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
}
};
} // namespace rerun::archetypes
namespace rerun {
/// \private
template <typename T>
struct AsComponents;
/// \private
template <>
struct AsComponents<archetypes::Points3D> {
/// Serialize all set component batches.
static Result<std::vector<DataCell>> serialize(const archetypes::Points3D& archetype);
};
} // namespace rerun