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 /// ## Example
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 struct Points3D {
67 /// All the 3D positions at which the point cloud shows points.
69
70 /// Optional radii for the points, effectively turning them into circles.
71 std::optional<Collection<rerun::components::Radius>> radii;
72
73 /// Optional colors for the points.
74 std::optional<Collection<rerun::components::Color>> colors;
75
76 /// Optional text labels for the points.
77 std::optional<Collection<rerun::components::Text>> labels;
78
79 /// Optional class Ids for the points.
80 ///
81 /// The class ID provides colors and labels if not specified explicitly.
82 std::optional<Collection<rerun::components::ClassId>> class_ids;
83
84 /// Optional keypoint IDs for the points, identifying them within a class.
85 ///
86 /// If keypoint IDs are passed in but no class IDs were specified, the class ID will
87 /// default to 0.
88 /// This is useful to identify points within a single classification (which is identified
89 /// with `class_id`).
90 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
91 /// detected skeleton.
92 std::optional<Collection<rerun::components::KeypointId>> keypoint_ids;
93
94 public:
95 static constexpr const char IndicatorComponentName[] = "rerun.components.Points3DIndicator";
96
97 /// Indicator component, used to identify the archetype when converting to a list of components.
99
100 public:
101 Points3D() = default;
102 Points3D(Points3D&& other) = default;
103
105 : positions(std::move(_positions)) {}
106
107 /// Optional radii for the points, effectively turning them into circles.
109 radii = std::move(_radii);
110 // See: https://github.com/rerun-io/rerun/issues/4027
111 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
112 }
113
114 /// Optional colors for the points.
116 colors = std::move(_colors);
117 // See: https://github.com/rerun-io/rerun/issues/4027
118 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
119 }
120
121 /// Optional text labels for the points.
123 labels = std::move(_labels);
124 // See: https://github.com/rerun-io/rerun/issues/4027
125 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
126 }
127
128 /// Optional class Ids for the points.
129 ///
130 /// The class ID provides colors and labels if not specified explicitly.
132 class_ids = std::move(_class_ids);
133 // See: https://github.com/rerun-io/rerun/issues/4027
134 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
135 }
136
137 /// Optional keypoint IDs for the points, identifying them within a class.
138 ///
139 /// If keypoint IDs are passed in but no class IDs were specified, the class ID will
140 /// default to 0.
141 /// This is useful to identify points within a single classification (which is identified
142 /// with `class_id`).
143 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
144 /// detected skeleton.
146 keypoint_ids = std::move(_keypoint_ids);
147 // See: https://github.com/rerun-io/rerun/issues/4027
148 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
149 }
150 };
151
152} // namespace rerun::archetypes
153
154namespace rerun {
155 /// \private
156 template <typename T>
157 struct AsComponents;
158
159 /// \private
160 template <>
161 struct AsComponents<archetypes::Points3D> {
162 /// Serialize all set component batches.
163 static Result<std::vector<DataCell>> serialize(const archetypes::Points3D& archetype);
164 };
165} // 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:66
Points3D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the points, effectively turning them into circles.
Definition points3d.hpp:108
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the points.
Definition points3d.hpp:77
Points3D with_keypoint_ids(Collection< rerun::components::KeypointId > _keypoint_ids) &&
Optional keypoint IDs for the points, identifying them within a class.
Definition points3d.hpp:145
Points3D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the points.
Definition points3d.hpp:122
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the points, effectively turning them into circles.
Definition points3d.hpp:71
Points3D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the points.
Definition points3d.hpp:115
Collection< rerun::components::Position3D > positions
All the 3D positions at which the point cloud shows points.
Definition points3d.hpp:68
std::optional< Collection< rerun::components::KeypointId > > keypoint_ids
Optional keypoint IDs for the points, identifying them within a class.
Definition points3d.hpp:92
Points3D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional class Ids for the points.
Definition points3d.hpp:131
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the points.
Definition points3d.hpp:74
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional class Ids for the points.
Definition points3d.hpp:82
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:23