re_types/components/
plane3d.rs

1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs
2// Based on "crates/store/re_types/definitions/rerun/components/plane3d.fbs".
3
4#![allow(unused_imports)]
5#![allow(unused_parens)]
6#![allow(clippy::clone_on_copy)]
7#![allow(clippy::cloned_instead_of_copied)]
8#![allow(clippy::map_flatten)]
9#![allow(clippy::needless_question_mark)]
10#![allow(clippy::new_without_default)]
11#![allow(clippy::redundant_closure)]
12#![allow(clippy::too_many_arguments)]
13#![allow(clippy::too_many_lines)]
14
15use ::re_types_core::try_serialize_field;
16use ::re_types_core::SerializationResult;
17use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
18use ::re_types_core::{ComponentDescriptor, ComponentName};
19use ::re_types_core::{DeserializationError, DeserializationResult};
20
21/// **Component**: An infinite 3D plane represented by a unit normal vector and a distance.
22///
23/// Any point P on the plane fulfills the equation `dot(xyz, P) - d = 0`,
24/// where `xyz` is the plane's normal and `d` the distance of the plane from the origin.
25/// This representation is also known as the Hesse normal form.
26///
27/// Note: although the normal will be passed through to the
28/// datastore as provided, when used in the Viewer, planes will always be normalized.
29/// I.e. the plane with xyz = (2, 0, 0), d = 1 is equivalent to xyz = (1, 0, 0), d = 0.5
30#[derive(Clone, Debug, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
31#[repr(transparent)]
32pub struct Plane3D(pub crate::datatypes::Plane3D);
33
34impl ::re_types_core::Component for Plane3D {
35    #[inline]
36    fn descriptor() -> ComponentDescriptor {
37        ComponentDescriptor::new("rerun.components.Plane3D")
38    }
39}
40
41::re_types_core::macros::impl_into_cow!(Plane3D);
42
43impl ::re_types_core::Loggable for Plane3D {
44    #[inline]
45    fn arrow_datatype() -> arrow::datatypes::DataType {
46        crate::datatypes::Plane3D::arrow_datatype()
47    }
48
49    fn to_arrow_opt<'a>(
50        data: impl IntoIterator<Item = Option<impl Into<::std::borrow::Cow<'a, Self>>>>,
51    ) -> SerializationResult<arrow::array::ArrayRef>
52    where
53        Self: Clone + 'a,
54    {
55        crate::datatypes::Plane3D::to_arrow_opt(data.into_iter().map(|datum| {
56            datum.map(|datum| match datum.into() {
57                ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0),
58                ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0),
59            })
60        }))
61    }
62
63    fn from_arrow_opt(
64        arrow_data: &dyn arrow::array::Array,
65    ) -> DeserializationResult<Vec<Option<Self>>>
66    where
67        Self: Sized,
68    {
69        crate::datatypes::Plane3D::from_arrow_opt(arrow_data)
70            .map(|v| v.into_iter().map(|v| v.map(Self)).collect())
71    }
72
73    #[inline]
74    fn from_arrow(arrow_data: &dyn arrow::array::Array) -> DeserializationResult<Vec<Self>>
75    where
76        Self: Sized,
77    {
78        crate::datatypes::Plane3D::from_arrow(arrow_data).map(bytemuck::cast_vec)
79    }
80}
81
82impl<T: Into<crate::datatypes::Plane3D>> From<T> for Plane3D {
83    fn from(v: T) -> Self {
84        Self(v.into())
85    }
86}
87
88impl std::borrow::Borrow<crate::datatypes::Plane3D> for Plane3D {
89    #[inline]
90    fn borrow(&self) -> &crate::datatypes::Plane3D {
91        &self.0
92    }
93}
94
95impl std::ops::Deref for Plane3D {
96    type Target = crate::datatypes::Plane3D;
97
98    #[inline]
99    fn deref(&self) -> &crate::datatypes::Plane3D {
100        &self.0
101    }
102}
103
104impl std::ops::DerefMut for Plane3D {
105    #[inline]
106    fn deref_mut(&mut self) -> &mut crate::datatypes::Plane3D {
107        &mut self.0
108    }
109}
110
111impl ::re_byte_size::SizeBytes for Plane3D {
112    #[inline]
113    fn heap_size_bytes(&self) -> u64 {
114        self.0.heap_size_bytes()
115    }
116
117    #[inline]
118    fn is_pod() -> bool {
119        <crate::datatypes::Plane3D>::is_pod()
120    }
121}