6#include "../result.hpp"
7#include "translation_and_mat3x3.hpp"
8#include "translation_rotation_scale3d.hpp"
19 class DenseUnionBuilder;
25 enum class Transform3DTag : uint8_t {
29 TranslationRotationScale,
33 union Transform3DData {
39 std::memset(
reinterpret_cast<void*
>(
this), 0,
sizeof(Transform3DData));
44 void swap(Transform3DData& other)
noexcept {
46 char temp[
sizeof(Transform3DData)];
47 void* otherbytes =
reinterpret_cast<void*
>(&other);
48 void* thisbytes =
reinterpret_cast<void*
>(
this);
49 std::memcpy(temp, thisbytes,
sizeof(Transform3DData));
50 std::memcpy(thisbytes, otherbytes,
sizeof(Transform3DData));
51 std::memcpy(otherbytes, temp,
sizeof(Transform3DData));
58 Transform3D() : _tag(detail::Transform3DTag::None) {}
62 const void* otherbytes =
reinterpret_cast<const void*
>(&other._data);
63 void* thisbytes =
reinterpret_cast<void*
>(&this->_data);
64 std::memcpy(thisbytes, otherbytes,
sizeof(detail::Transform3DData));
77 Transform3D& operator=(Transform3D&& other)
noexcept {
82 void swap(Transform3D& other)
noexcept {
83 std::swap(this->_tag, other._tag);
84 this->_data.swap(other._data);
88 *
this = Transform3D::translation_and_mat3x3(std::move(translation_and_mat3x3));
93 *
this = Transform3D::translation_rotation_scale(std::move(translation_rotation_scale));
96 static Transform3D translation_and_mat3x3(
100 self._tag = detail::Transform3DTag::TranslationAndMat3x3;
101 new (&self._data.translation_and_mat3x3)
106 static Transform3D translation_rotation_scale(
110 self._tag = detail::Transform3DTag::TranslationRotationScale;
111 new (&self._data.translation_rotation_scale)
118 if (_tag == detail::Transform3DTag::TranslationAndMat3x3) {
119 return &_data.translation_and_mat3x3;
127 if (_tag == detail::Transform3DTag::TranslationRotationScale) {
128 return &_data.translation_rotation_scale;
135 const detail::Transform3DData& get_union_data()
const {
140 detail::Transform3DTag get_union_tag()
const {
145 detail::Transform3DTag _tag;
146 detail::Transform3DData _data;
151 template <
typename T>
156 struct Loggable<datatypes::Transform3D> {
157 static constexpr const char Name[] =
"rerun.datatypes.Transform3D";
160 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
164 arrow::DenseUnionBuilder* builder,
const datatypes::Transform3D* elements,
169 static Result<std::shared_ptr<arrow::Array>> to_arrow(
170 const datatypes::Transform3D* instances,
size_t num_instances
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:87
All built-in datatypes. See Types in the Rerun manual.
Definition rerun.hpp:72
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Datatype: Representation of an affine transform via a 3x3 affine matrix paired with a translation.
Definition translation_and_mat3x3.hpp:24
Datatype: Representation of an affine transform via separate translation, rotation & scale.
Definition translation_rotation_scale3d.hpp:24