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