Rerun C++ SDK
Loading...
Searching...
No Matches
force_many_body.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_many_body.def.rs".
3
4#pragma once
5
6#include "../../archetype_utils.hpp"
7#include "../../blueprint/components/enabled.hpp"
8#include "../../blueprint/components/force_strength.hpp"
9#include "../../collection.hpp"
10#include "../../component_batch.hpp"
11#include "../../component_column.hpp"
12#include "../../result.hpp"
13
14#include <cstdint>
15#include <optional>
16#include <utility>
17#include <vector>
18
19namespace rerun::blueprint::archetypes {
20 /// **Archetype**: A force between each pair of nodes that ressembles an electrical charge.
21 ///
22 /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together.
23 ///
24 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
25 ///
27 /// Whether the many body force is enabled.
28 ///
29 /// The many body force is applied on each pair of nodes in a way that ressembles an electrical charge. If the
30 /// strength is smaller than 0, it pushes nodes apart; if it is larger than 0, it pulls them together.
31 std::optional<ComponentBatch> enabled;
32
33 /// The strength of the force.
34 ///
35 /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together.
36 std::optional<ComponentBatch> strength;
37
38 public:
39 /// The name of the archetype as used in `ComponentDescriptor`s.
40 static constexpr const char ArchetypeName[] = "rerun.blueprint.archetypes.ForceManyBody";
41
42 /// `ComponentDescriptor` for the `enabled` field.
43 static constexpr auto Descriptor_enabled = ComponentDescriptor(
44 ArchetypeName, "ForceManyBody:enabled",
46 );
47 /// `ComponentDescriptor` for the `strength` field.
49 ArchetypeName, "ForceManyBody:strength",
51 );
52
53 public:
54 ForceManyBody() = default;
55 ForceManyBody(ForceManyBody&& other) = default;
56 ForceManyBody(const ForceManyBody& other) = default;
57 ForceManyBody& operator=(const ForceManyBody& other) = default;
58 ForceManyBody& operator=(ForceManyBody&& other) = default;
59
60 /// Update only some specific fields of a `ForceManyBody`.
62 return ForceManyBody();
63 }
64
65 /// Clear all the fields of a `ForceManyBody`.
67
68 /// Whether the many body force is enabled.
69 ///
70 /// The many body force is applied on each pair of nodes in a way that ressembles an electrical charge. If the
71 /// strength is smaller than 0, it pushes nodes apart; if it is larger than 0, it pulls them together.
73 enabled = ComponentBatch::from_loggable(_enabled, Descriptor_enabled).value_or_throw();
74 return std::move(*this);
75 }
76
77 /// The strength of the force.
78 ///
79 /// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together.
81 ) && {
82 strength =
83 ComponentBatch::from_loggable(_strength, Descriptor_strength).value_or_throw();
84 return std::move(*this);
85 }
86
87 /// Partitions the component data into multiple sub-batches.
88 ///
89 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
90 /// instead, via `ComponentBatch::partitioned`.
91 ///
92 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
93 ///
94 /// The specified `lengths` must sum to the total length of the component batch.
96 return detail::partition_batches({&enabled, &strength}, lengths_).value_or_throw();
97 }
98
99 /// Partitions the component data into unit-length sub-batches.
100 ///
101 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
102 /// where `n` is automatically guessed.
104 return detail::partition_batches_of_unit_length({&enabled, &strength}).value_or_throw();
105 }
106 };
107
108} // namespace rerun::blueprint::archetypes
109
110namespace rerun {
111 /// \private
112 template <typename T>
113 struct AsComponents;
114
115 /// \private
116 template <>
117 struct AsComponents<blueprint::archetypes::ForceManyBody> {
118 /// Serialize all set component batches.
119 static Result<Collection<ComponentBatch>> as_batches(
121 ) {
122 return detail::collect_batches({&archetype.enabled, &archetype.strength});
123 }
124 };
125} // 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
Archetype: A force between each pair of nodes that ressembles an electrical charge.
Definition force_many_body.hpp:26
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition force_many_body.hpp:103
std::optional< ComponentBatch > enabled
Whether the many body force is enabled.
Definition force_many_body.hpp:31
ForceManyBody with_strength(const rerun::blueprint::components::ForceStrength &_strength) &&
The strength of the force.
Definition force_many_body.hpp:80
static ForceManyBody clear_fields()
Clear all the fields of a ForceManyBody.
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition force_many_body.hpp:95
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition force_many_body.hpp:40
static constexpr auto Descriptor_strength
ComponentDescriptor for the strength field.
Definition force_many_body.hpp:48
static constexpr auto Descriptor_enabled
ComponentDescriptor for the enabled field.
Definition force_many_body.hpp:43
std::optional< ComponentBatch > strength
The strength of the force.
Definition force_many_body.hpp:36
static ForceManyBody update_fields()
Update only some specific fields of a ForceManyBody.
Definition force_many_body.hpp:61
ForceManyBody with_enabled(const rerun::blueprint::components::Enabled &_enabled) &&
Whether the many body force is enabled.
Definition force_many_body.hpp:72
Component: Whether a procedure is enabled.
Definition enabled.hpp:17
Component: The strength of a given force.
Definition force_strength.hpp:19