Rerun C++ SDK
Loading...
Searching...
No Matches
force_link.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/build/re_type_definitions/rerun/blueprint/archetypes/force_link.def.rs".
3
4#pragma once
5
6#include "../../archetype_utils.hpp"
7#include "../../blueprint/components/enabled.hpp"
8#include "../../blueprint/components/force_distance.hpp"
9#include "../../blueprint/components/force_iterations.hpp"
10#include "../../collection.hpp"
11#include "../../component_batch.hpp"
12#include "../../component_column.hpp"
13#include "../../result.hpp"
14
15#include <cstdint>
16#include <optional>
17#include <utility>
18#include <vector>
19
20namespace rerun::blueprint::archetypes {
21 /// **Archetype**: Aims to achieve a target distance between two nodes that are connected by an edge.
22 ///
23 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
24 ///
25 struct ForceLink {
26 /// Whether the link force is enabled.
27 ///
28 /// The link force aims to achieve a target distance between two nodes that are connected by one ore more edges.
29 std::optional<ComponentBatch> enabled;
30
31 /// The target distance between two nodes.
32 std::optional<ComponentBatch> distance;
33
34 /// Specifies how often this force should be applied per iteration.
35 ///
36 /// Increasing this parameter can lead to better results at the cost of longer computation time.
37 std::optional<ComponentBatch> iterations;
38
39 public:
40 /// The name of the archetype as used in `ComponentDescriptor`s.
41 static constexpr const char ArchetypeName[] = "rerun.blueprint.archetypes.ForceLink";
42
43 /// `ComponentDescriptor` for the `enabled` field.
44 static constexpr auto Descriptor_enabled = ComponentDescriptor(
45 ArchetypeName, "ForceLink:enabled",
47 );
48 /// `ComponentDescriptor` for the `distance` field.
50 ArchetypeName, "ForceLink:distance",
52 );
53 /// `ComponentDescriptor` for the `iterations` field.
55 ArchetypeName, "ForceLink:iterations",
57 );
58
59 public:
60 ForceLink() = default;
61 ForceLink(ForceLink&& other) = default;
62 ForceLink(const ForceLink& other) = default;
63 ForceLink& operator=(const ForceLink& other) = default;
64 ForceLink& operator=(ForceLink&& other) = default;
65
66 /// Update only some specific fields of a `ForceLink`.
68 return ForceLink();
69 }
70
71 /// Clear all the fields of a `ForceLink`.
73
74 /// Whether the link force is enabled.
75 ///
76 /// The link force aims to achieve a target distance between two nodes that are connected by one ore more edges.
78 enabled = ComponentBatch::from_loggable(_enabled, Descriptor_enabled).value_or_throw();
79 return std::move(*this);
80 }
81
82 /// The target distance between two nodes.
84 distance =
85 ComponentBatch::from_loggable(_distance, Descriptor_distance).value_or_throw();
86 return std::move(*this);
87 }
88
89 /// Specifies how often this force should be applied per iteration.
90 ///
91 /// Increasing this parameter can lead to better results at the cost of longer computation time.
93 ) && {
95 ComponentBatch::from_loggable(_iterations, Descriptor_iterations).value_or_throw();
96 return std::move(*this);
97 }
98
99 /// Partitions the component data into multiple sub-batches.
100 ///
101 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
102 /// instead, via `ComponentBatch::partitioned`.
103 ///
104 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
105 ///
106 /// The specified `lengths` must sum to the total length of the component batch.
108 return detail::partition_batches({&enabled, &distance, &iterations}, lengths_)
109 .value_or_throw();
110 }
111
112 /// Partitions the component data into unit-length sub-batches.
113 ///
114 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
115 /// where `n` is automatically guessed.
117 return detail::partition_batches_of_unit_length({&enabled, &distance, &iterations})
118 .value_or_throw();
119 }
120 };
121
122} // namespace rerun::blueprint::archetypes
123
124namespace rerun {
125 /// \private
126 template <typename T>
127 struct AsComponents;
128
129 /// \private
130 template <>
131 struct AsComponents<blueprint::archetypes::ForceLink> {
132 /// Serialize all set component batches.
133 static Result<Collection<ComponentBatch>> as_batches(
134 const blueprint::archetypes::ForceLink& archetype
135 ) {
136 return detail::collect_batches(
137 {&archetype.enabled, &archetype.distance, &archetype.iterations}
138 );
139 }
140 };
141} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Component: Whether a procedure is enabled.
Definition enabled.hpp:17
Component: The target distance between two nodes.
Definition force_distance.hpp:19
Component: Specifies how often this force should be applied per iteration.
Definition force_iterations.hpp:19