Rerun C++ SDK
Loading...
Searching...
No Matches
voxel_index.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/store/re_sdk_types/definitions/rerun/components/voxel_index.fbs".
3
4#pragma once
5
6#include "../datatypes/ivec3d.hpp"
7#include "../result.hpp"
8
9#include <array>
10#include <cstdint>
11#include <memory>
12
13namespace rerun::components {
14 /// **Component**: Integer index of a voxel in a sparse 3D voxel grid.
15 ///
16 /// The voxel center in local grid coordinates is `(index + 0.5) * voxel_size`.
17 struct VoxelIndex {
19
20 public: // START of extensions from voxel_index_ext.cpp:
21 /// Construct VoxelIndex from x/y/z values.
22 VoxelIndex(int32_t x, int32_t y, int32_t z) : index{x, y, z} {}
23
24 // END of extensions from voxel_index_ext.cpp, start of generated code:
25
26 public:
27 VoxelIndex() = default;
28
29 VoxelIndex(rerun::datatypes::IVec3D index_) : index(index_) {}
30
31 VoxelIndex& operator=(rerun::datatypes::IVec3D index_) {
32 index = index_;
33 return *this;
34 }
35
36 VoxelIndex(std::array<int32_t, 3> xyz_) : index(xyz_) {}
37
38 VoxelIndex& operator=(std::array<int32_t, 3> xyz_) {
39 index = xyz_;
40 return *this;
41 }
42
43 /// Cast to the underlying IVec3D datatype
44 operator rerun::datatypes::IVec3D() const {
45 return index;
46 }
47 };
48} // namespace rerun::components
49
50namespace rerun {
51 static_assert(sizeof(rerun::datatypes::IVec3D) == sizeof(components::VoxelIndex));
52
53 /// \private
54 template <>
55 struct Loggable<components::VoxelIndex> {
56 static constexpr std::string_view ComponentType = "rerun.components.VoxelIndex";
57
58 /// Returns the arrow data type this type corresponds to.
59 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
60 return Loggable<rerun::datatypes::IVec3D>::arrow_datatype();
61 }
62
63 /// Serializes an array of `rerun::components::VoxelIndex` into an arrow array.
64 static Result<std::shared_ptr<arrow::Array>> to_arrow(
65 const components::VoxelIndex* instances, size_t num_instances
66 ) {
67 if (num_instances == 0) {
68 return Loggable<rerun::datatypes::IVec3D>::to_arrow(nullptr, 0);
69 } else if (instances == nullptr) {
70 return rerun::Error(
71 ErrorCode::UnexpectedNullArgument,
72 "Passed array instances is null when num_elements> 0."
73 );
74 } else {
75 return Loggable<rerun::datatypes::IVec3D>::to_arrow(
76 &instances->index,
77 num_instances
78 );
79 }
80 }
81 };
82} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:103
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:90
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Component: Integer index of a voxel in a sparse 3D voxel grid.
Definition voxel_index.hpp:17
VoxelIndex(int32_t x, int32_t y, int32_t z)
Construct VoxelIndex from x/y/z values.
Definition voxel_index.hpp:22
Datatype: An int32 vector in 3D space.
Definition ivec3d.hpp:20