Rerun C++ SDK
Loading...
Searching...
No Matches
points2d.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/points2d.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/draw_order.hpp"
11#include "../components/instance_key.hpp"
12#include "../components/keypoint_id.hpp"
13#include "../components/position2d.hpp"
14#include "../components/radius.hpp"
15#include "../components/text.hpp"
16#include "../data_cell.hpp"
17#include "../indicator_component.hpp"
18#include "../result.hpp"
19
20#include <cstdint>
21#include <optional>
22#include <utility>
23#include <vector>
24
25namespace rerun::archetypes {
26 /// **Archetype**: A 2D point cloud with positions and optional colors, radii, labels, etc.
27 ///
28 /// ## Example
29 ///
30 /// ### Randomly distributed 2D points with varying color and radius
31 /// ![image](https://static.rerun.io/point2d_random/8e8ac75373677bd72bd3f56a15e44fcab309a168/full.png)
32 ///
33 /// ```cpp
34 /// #include <rerun.hpp>
35 ///
36 /// #include <algorithm>
37 /// #include <random>
38 /// #include <vector>
39 ///
40 /// int main() {
41 /// const auto rec = rerun::RecordingStream("rerun_example_points2d_simple");
42 /// rec.spawn().exit_on_failure();
43 ///
44 /// std::default_random_engine gen;
45 /// std::uniform_real_distribution<float> dist_pos(-5.0f, 5.0f);
46 /// std::uniform_real_distribution<float> dist_radius(0.1f, 1.0f);
47 /// // On MSVC uint8_t distributions are not supported.
48 /// std::uniform_int_distribution<int> dist_color(0, 255);
49 ///
50 /// std::vector<rerun::Position2D> points2d(10);
51 /// std::generate(points2d.begin(), points2d.end(), [&] {
52 /// return rerun::Position2D(dist_pos(gen), dist_pos(gen));
53 /// });
54 /// std::vector<rerun::Color> colors(10);
55 /// std::generate(colors.begin(), colors.end(), [&] {
56 /// return rerun::Color(
57 /// static_cast<uint8_t>(dist_color(gen)),
58 /// static_cast<uint8_t>(dist_color(gen)),
59 /// static_cast<uint8_t>(dist_color(gen))
60 /// );
61 /// });
62 /// std::vector<rerun::Radius> radii(10);
63 /// std::generate(radii.begin(), radii.end(), [&] { return dist_radius(gen); });
64 ///
65 /// rec.log("random", rerun::Points2D(points2d).with_colors(colors).with_radii(radii));
66 ///
67 /// // Log an extra rect to set the view bounds
68 /// rec.log("bounds", rerun::Boxes2D::from_half_sizes({{2.0f, 1.5f}}));
69 /// }
70 /// ```
71 struct Points2D {
72 /// All the 2D positions at which the point cloud shows points.
74
75 /// Optional radii for the points, effectively turning them into circles.
76 std::optional<Collection<rerun::components::Radius>> radii;
77
78 /// Optional colors for the points.
79 std::optional<Collection<rerun::components::Color>> colors;
80
81 /// Optional text labels for the points.
82 std::optional<Collection<rerun::components::Text>> labels;
83
84 /// An optional floating point value that specifies the 2D drawing order.
85 ///
86 /// Objects with higher values are drawn on top of those with lower values.
87 std::optional<rerun::components::DrawOrder> draw_order;
88
89 /// Optional class Ids for the points.
90 ///
91 /// The class ID provides colors and labels if not specified explicitly.
92 std::optional<Collection<rerun::components::ClassId>> class_ids;
93
94 /// Optional keypoint IDs for the points, identifying them within a class.
95 ///
96 /// If keypoint IDs are passed in but no class IDs were specified, the class ID will
97 /// default to 0.
98 /// This is useful to identify points within a single classification (which is identified
99 /// with `class_id`).
100 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
101 /// detected skeleton.
102 std::optional<Collection<rerun::components::KeypointId>> keypoint_ids;
103
104 /// Unique identifiers for each individual point in the batch.
105 std::optional<Collection<rerun::components::InstanceKey>> instance_keys;
106
107 public:
108 static constexpr const char IndicatorComponentName[] = "rerun.components.Points2DIndicator";
109
110 /// Indicator component, used to identify the archetype when converting to a list of components.
112
113 public:
114 Points2D() = default;
115 Points2D(Points2D&& other) = default;
116
118 : positions(std::move(_positions)) {}
119
120 /// Optional radii for the points, effectively turning them into circles.
122 radii = std::move(_radii);
123 // See: https://github.com/rerun-io/rerun/issues/4027
124 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
125 }
126
127 /// Optional colors for the points.
129 colors = std::move(_colors);
130 // See: https://github.com/rerun-io/rerun/issues/4027
131 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
132 }
133
134 /// Optional text labels for the points.
136 labels = std::move(_labels);
137 // See: https://github.com/rerun-io/rerun/issues/4027
138 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
139 }
140
141 /// An optional floating point value that specifies the 2D drawing order.
142 ///
143 /// Objects with higher values are drawn on top of those with lower values.
145 draw_order = std::move(_draw_order);
146 // See: https://github.com/rerun-io/rerun/issues/4027
147 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
148 }
149
150 /// Optional class Ids for the points.
151 ///
152 /// The class ID provides colors and labels if not specified explicitly.
154 class_ids = std::move(_class_ids);
155 // See: https://github.com/rerun-io/rerun/issues/4027
156 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
157 }
158
159 /// Optional keypoint IDs for the points, identifying them within a class.
160 ///
161 /// If keypoint IDs are passed in but no class IDs were specified, the class ID will
162 /// default to 0.
163 /// This is useful to identify points within a single classification (which is identified
164 /// with `class_id`).
165 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
166 /// detected skeleton.
168 keypoint_ids = std::move(_keypoint_ids);
169 // See: https://github.com/rerun-io/rerun/issues/4027
170 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
171 }
172
173 /// Unique identifiers for each individual point in the batch.
175 instance_keys = std::move(_instance_keys);
176 // See: https://github.com/rerun-io/rerun/issues/4027
177 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
178 }
179
180 /// Returns the number of primary instances of this archetype.
181 size_t num_instances() const {
182 return positions.size();
183 }
184 };
185
186} // namespace rerun::archetypes
187
188namespace rerun {
189 /// \private
190 template <typename T>
191 struct AsComponents;
192
193 /// \private
194 template <>
195 struct AsComponents<archetypes::Points2D> {
196 /// Serialize all set component batches.
197 static Result<std::vector<DataCell>> serialize(const archetypes::Points2D& archetype);
198 };
199} // 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 2D point cloud with positions and optional colors, radii, labels, etc.
Definition points2d.hpp:71
Points2D with_instance_keys(Collection< rerun::components::InstanceKey > _instance_keys) &&
Unique identifiers for each individual point in the batch.
Definition points2d.hpp:174
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the points, effectively turning them into circles.
Definition points2d.hpp:76
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the points.
Definition points2d.hpp:79
Points2D with_keypoint_ids(Collection< rerun::components::KeypointId > _keypoint_ids) &&
Optional keypoint IDs for the points, identifying them within a class.
Definition points2d.hpp:167
Collection< rerun::components::Position2D > positions
All the 2D positions at which the point cloud shows points.
Definition points2d.hpp:73
Points2D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional class Ids for the points.
Definition points2d.hpp:153
Points2D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the points.
Definition points2d.hpp:135
std::optional< Collection< rerun::components::InstanceKey > > instance_keys
Unique identifiers for each individual point in the batch.
Definition points2d.hpp:105
std::optional< Collection< rerun::components::KeypointId > > keypoint_ids
Optional keypoint IDs for the points, identifying them within a class.
Definition points2d.hpp:102
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional class Ids for the points.
Definition points2d.hpp:92
size_t num_instances() const
Returns the number of primary instances of this archetype.
Definition points2d.hpp:181
Points2D with_draw_order(rerun::components::DrawOrder _draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition points2d.hpp:144
std::optional< rerun::components::DrawOrder > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition points2d.hpp:87
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the points.
Definition points2d.hpp:82
Points2D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the points, effectively turning them into circles.
Definition points2d.hpp:121
Points2D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the points.
Definition points2d.hpp:128
Component: Draw order used for the display order of 2D elements.
Definition draw_order.hpp:30
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:23