Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::archetypes::Points3D Struct Reference

Archetype: A 3D point cloud with positions and optional colors, radii, labels, etc. More...

#include <rerun/archetypes/points3d.hpp>

Public Types

using IndicatorComponent = rerun::components::IndicatorComponent< IndicatorComponentName >
 Indicator component, used to identify the archetype when converting to a list of components.
 

Public Member Functions

 Points3D (Points3D &&other)=default
 
 Points3D (Collection< rerun::components::Position3D > _positions)
 
Points3D with_radii (Collection< rerun::components::Radius > _radii) &&
 Optional radii for the points, effectively turning them into circles.
 
Points3D with_colors (Collection< rerun::components::Color > _colors) &&
 Optional colors for the points.
 
Points3D with_labels (Collection< rerun::components::Text > _labels) &&
 Optional text labels for the points.
 
Points3D with_show_labels (rerun::components::ShowLabels _show_labels) &&
 Optional choice of whether the text labels should be shown by default.
 
Points3D with_class_ids (Collection< rerun::components::ClassId > _class_ids) &&
 Optional class Ids for the points.
 
Points3D with_keypoint_ids (Collection< rerun::components::KeypointId > _keypoint_ids) &&
 Optional keypoint IDs for the points, identifying them within a class.
 

Public Attributes

Collection< rerun::components::Position3Dpositions
 All the 3D positions at which the point cloud shows points.
 
std::optional< Collection< rerun::components::Radius > > radii
 Optional radii for the points, effectively turning them into circles.
 
std::optional< Collection< rerun::components::Color > > colors
 Optional colors for the points.
 
std::optional< Collection< rerun::components::Text > > labels
 Optional text labels for the points.
 
std::optional< rerun::components::ShowLabelsshow_labels
 Optional choice of whether the text labels should be shown by default.
 
std::optional< Collection< rerun::components::ClassId > > class_ids
 Optional class Ids for the points.
 
std::optional< Collection< rerun::components::KeypointId > > keypoint_ids
 Optional keypoint IDs for the points, identifying them within a class.
 

Static Public Attributes

static constexpr const char IndicatorComponentName [] = "rerun.components.Points3DIndicator"
 

Detailed Description

Archetype: A 3D point cloud with positions and optional colors, radii, labels, etc.

Examples

Randomly distributed 3D points with varying color and radius

image

#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));
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:60
Archetype: A 3D point cloud with positions and optional colors, radii, labels, etc.
Definition points3d.hpp:156
Points3D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the points, effectively turning them into circles.
Definition points3d.hpp:204
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the points, effectively turning them into circles.
Definition points3d.hpp:161
Points3D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the points.
Definition points3d.hpp:211
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the points.
Definition points3d.hpp:164

Log points with radii given in UI points

image

#include <rerun.hpp>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_points3d_ui_radius");
rec.spawn().exit_on_failure();
// Two blue points with scene unit radii of 0.1 and 0.3.
rec.log(
"scene_units",
rerun::Points3D({{0.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f}})
// By default, radii are interpreted as world-space units.
.with_radii({0.1f, 0.3f})
);
// Two red points with ui point radii of 40 and 60.
// UI points are independent of zooming in Views, but are sensitive to the application UI scaling.
// For 100% ui scaling, UI points are equal to pixels.
rec.log(
"ui_points",
rerun::Points3D({{0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 1.0f}})
// rerun::Radius::ui_points produces radii that the viewer interprets as given in ui points.
})
);
}
Component: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition color.hpp:18
static Radius ui_points(float radius_in_ui_points)
Creates a new radius in ui points.
Definition radius.hpp:36

Send several point clouds with varying point count over time in a single call

image

#include <array>
#include <rerun.hpp>
#include <vector>
using namespace std::chrono_literals;
int main() {
const auto rec = rerun::RecordingStream("rerun_example_send_columns_arrays");
rec.spawn().exit_on_failure();
// Prepare a point cloud that evolves over time 5 timesteps, changing the number of points in the process.
std::vector<std::array<float, 3>> positions = {
// clang-format off
{1.0, 0.0, 1.0}, {0.5, 0.5, 2.0},
{1.5, -0.5, 1.5}, {1.0, 1.0, 2.5}, {-0.5, 1.5, 1.0}, {-1.5, 0.0, 2.0},
{2.0, 0.0, 2.0}, {1.5, -1.5, 3.0}, {0.0, -2.0, 2.5}, {1.0, -1.0, 3.5},
{-2.0, 0.0, 2.0}, {-1.5, 1.5, 3.0}, {-1.0, 1.0, 3.5},
{1.0, -1.0, 1.0}, {2.0, -2.0, 2.0}, {3.0, -1.0, 3.0}, {2.0, 0.0, 4.0},
// clang-format on
};
// At each time stamp, all points in the cloud share the same but changing color.
std::vector<uint32_t> colors = {0xFF0000FF, 0x00FF00FF, 0x0000FFFF, 0xFFFF00FF, 0x00FFFFFF};
// Log at seconds 10-14
auto times = rerun::Collection{10s, 11s, 12s, 13s, 14s};
auto time_column = rerun::TimeColumn::from_times("time", std::move(times));
// Interpret raw positions and color data as rerun components and partition them.
auto indicator_batch = rerun::ComponentColumn::from_indicators<rerun::Points3D>(5);
{2, 4, 4, 3, 4}
);
);
rec.send_columns(
"points",
time_column,
{
indicator_batch.value_or_throw(),
position_batch.value_or_throw(),
color_batch.value_or_throw(),
}
);
}
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
static Result< ComponentColumn > from_loggable(const Collection< T > &components)
Creates a new component column from a collection of component instances where each run has a length o...
Definition component_column.hpp:60
static Result< ComponentColumn > from_loggable_with_lengths(const Collection< T > &components, const Collection< uint32_t > &lengths)
Creates a new component column from a collection of component instances.
Definition component_column.hpp:37
static TimeColumn from_times(std::string timeline_name, const Collection< std::chrono::duration< TRep, TPeriod > > &chrono_times, SortingStatus sorting_status=SortingStatus::Unknown)
Creates a time column from an array of arbitrary std::chrono durations.
Definition time_column.hpp:115
Collection< rerun::components::Position3D > positions
All the 3D positions at which the point cloud shows points.
Definition points3d.hpp:158

Member Function Documentation

◆ with_labels()

Points3D rerun::archetypes::Points3D::with_labels ( Collection< rerun::components::Text _labels) &&
inline

Optional text labels for the points.

If there's a single label present, it will be placed at the center of the entity. Otherwise, each instance will have its own label.

◆ with_class_ids()

Points3D rerun::archetypes::Points3D::with_class_ids ( Collection< rerun::components::ClassId _class_ids) &&
inline

Optional class Ids for the points.

The components::ClassId provides colors and labels if not specified explicitly.

◆ with_keypoint_ids()

Points3D rerun::archetypes::Points3D::with_keypoint_ids ( Collection< rerun::components::KeypointId _keypoint_ids) &&
inline

Optional keypoint IDs for the points, identifying them within a class.

If keypoint IDs are passed in but no components::ClassIds were specified, the components::ClassId 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.

Member Data Documentation

◆ labels

std::optional<Collection<rerun::components::Text> > rerun::archetypes::Points3D::labels

Optional text labels for the points.

If there's a single label present, it will be placed at the center of the entity. Otherwise, each instance will have its own label.

◆ class_ids

std::optional<Collection<rerun::components::ClassId> > rerun::archetypes::Points3D::class_ids

Optional class Ids for the points.

The components::ClassId provides colors and labels if not specified explicitly.

◆ keypoint_ids

std::optional<Collection<rerun::components::KeypointId> > rerun::archetypes::Points3D::keypoint_ids

Optional keypoint IDs for the points, identifying them within a class.

If keypoint IDs are passed in but no components::ClassIds were specified, the components::ClassId 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.


The documentation for this struct was generated from the following file: