#![allow(unused_braces)]
#![allow(unused_imports)]
#![allow(unused_parens)]
#![allow(clippy::allow_attributes)]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::cloned_instead_of_copied)]
#![allow(clippy::map_flatten)]
#![allow(clippy::needless_question_mark)]
#![allow(clippy::new_without_default)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::too_many_lines)]
#![allow(clippy::wildcard_imports)]
use ::re_types_core::SerializationResult;
use ::re_types_core::try_serialize_field;
use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
use ::re_types_core::{ComponentDescriptor, ComponentType};
use ::re_types_core::{DeserializationError, DeserializationResult};
#[derive(Clone, Debug, PartialEq, Default)]
pub struct Pinhole {
pub image_from_camera: Option<SerializedComponentBatch>,
pub resolution: Option<SerializedComponentBatch>,
pub camera_xyz: Option<SerializedComponentBatch>,
pub image_plane_distance: Option<SerializedComponentBatch>,
pub color: Option<SerializedComponentBatch>,
pub line_width: Option<SerializedComponentBatch>,
}
impl Pinhole {
#[inline]
pub fn descriptor_image_from_camera() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Pinhole".into()),
component: "Pinhole:image_from_camera".into(),
component_type: Some("rerun.components.PinholeProjection".into()),
}
}
#[inline]
pub fn descriptor_resolution() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Pinhole".into()),
component: "Pinhole:resolution".into(),
component_type: Some("rerun.components.Resolution".into()),
}
}
#[inline]
pub fn descriptor_camera_xyz() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Pinhole".into()),
component: "Pinhole:camera_xyz".into(),
component_type: Some("rerun.components.ViewCoordinates".into()),
}
}
#[inline]
pub fn descriptor_image_plane_distance() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Pinhole".into()),
component: "Pinhole:image_plane_distance".into(),
component_type: Some("rerun.components.ImagePlaneDistance".into()),
}
}
#[inline]
pub fn descriptor_color() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Pinhole".into()),
component: "Pinhole:color".into(),
component_type: Some("rerun.components.Color".into()),
}
}
#[inline]
pub fn descriptor_line_width() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Pinhole".into()),
component: "Pinhole:line_width".into(),
component_type: Some("rerun.components.Radius".into()),
}
}
}
static REQUIRED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
std::sync::LazyLock::new(|| [Pinhole::descriptor_image_from_camera()]);
static RECOMMENDED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
std::sync::LazyLock::new(|| [Pinhole::descriptor_resolution()]);
static OPTIONAL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 4usize]> =
std::sync::LazyLock::new(|| {
[
Pinhole::descriptor_camera_xyz(),
Pinhole::descriptor_image_plane_distance(),
Pinhole::descriptor_color(),
Pinhole::descriptor_line_width(),
]
});
static ALL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 6usize]> =
std::sync::LazyLock::new(|| {
[
Pinhole::descriptor_image_from_camera(),
Pinhole::descriptor_resolution(),
Pinhole::descriptor_camera_xyz(),
Pinhole::descriptor_image_plane_distance(),
Pinhole::descriptor_color(),
Pinhole::descriptor_line_width(),
]
});
impl Pinhole {
pub const NUM_COMPONENTS: usize = 6usize;
}
impl ::re_types_core::Archetype for Pinhole {
#[inline]
fn name() -> ::re_types_core::ArchetypeName {
"rerun.archetypes.Pinhole".into()
}
#[inline]
fn display_name() -> &'static str {
"Pinhole"
}
#[inline]
fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
REQUIRED_COMPONENTS.as_slice().into()
}
#[inline]
fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
RECOMMENDED_COMPONENTS.as_slice().into()
}
#[inline]
fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
OPTIONAL_COMPONENTS.as_slice().into()
}
#[inline]
fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
ALL_COMPONENTS.as_slice().into()
}
#[inline]
fn from_arrow_components(
arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
) -> DeserializationResult<Self> {
re_tracing::profile_function!();
use ::re_types_core::{Loggable as _, ResultExt as _};
let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
let image_from_camera = arrays_by_descr
.get(&Self::descriptor_image_from_camera())
.map(|array| {
SerializedComponentBatch::new(array.clone(), Self::descriptor_image_from_camera())
});
let resolution = arrays_by_descr
.get(&Self::descriptor_resolution())
.map(|array| {
SerializedComponentBatch::new(array.clone(), Self::descriptor_resolution())
});
let camera_xyz = arrays_by_descr
.get(&Self::descriptor_camera_xyz())
.map(|array| {
SerializedComponentBatch::new(array.clone(), Self::descriptor_camera_xyz())
});
let image_plane_distance = arrays_by_descr
.get(&Self::descriptor_image_plane_distance())
.map(|array| {
SerializedComponentBatch::new(
array.clone(),
Self::descriptor_image_plane_distance(),
)
});
let color = arrays_by_descr
.get(&Self::descriptor_color())
.map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_color()));
let line_width = arrays_by_descr
.get(&Self::descriptor_line_width())
.map(|array| {
SerializedComponentBatch::new(array.clone(), Self::descriptor_line_width())
});
Ok(Self {
image_from_camera,
resolution,
camera_xyz,
image_plane_distance,
color,
line_width,
})
}
}
impl ::re_types_core::AsComponents for Pinhole {
#[inline]
fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
use ::re_types_core::Archetype as _;
[
self.image_from_camera.clone(),
self.resolution.clone(),
self.camera_xyz.clone(),
self.image_plane_distance.clone(),
self.color.clone(),
self.line_width.clone(),
]
.into_iter()
.flatten()
.collect()
}
}
impl ::re_types_core::ArchetypeReflectionMarker for Pinhole {}
impl Pinhole {
#[inline]
pub fn new(image_from_camera: impl Into<crate::components::PinholeProjection>) -> Self {
Self {
image_from_camera: try_serialize_field(
Self::descriptor_image_from_camera(),
[image_from_camera],
),
resolution: None,
camera_xyz: None,
image_plane_distance: None,
color: None,
line_width: None,
}
}
#[inline]
pub fn update_fields() -> Self {
Self::default()
}
#[inline]
pub fn clear_fields() -> Self {
use ::re_types_core::Loggable as _;
Self {
image_from_camera: Some(SerializedComponentBatch::new(
crate::components::PinholeProjection::arrow_empty(),
Self::descriptor_image_from_camera(),
)),
resolution: Some(SerializedComponentBatch::new(
crate::components::Resolution::arrow_empty(),
Self::descriptor_resolution(),
)),
camera_xyz: Some(SerializedComponentBatch::new(
crate::components::ViewCoordinates::arrow_empty(),
Self::descriptor_camera_xyz(),
)),
image_plane_distance: Some(SerializedComponentBatch::new(
crate::components::ImagePlaneDistance::arrow_empty(),
Self::descriptor_image_plane_distance(),
)),
color: Some(SerializedComponentBatch::new(
crate::components::Color::arrow_empty(),
Self::descriptor_color(),
)),
line_width: Some(SerializedComponentBatch::new(
crate::components::Radius::arrow_empty(),
Self::descriptor_line_width(),
)),
}
}
#[inline]
pub fn columns<I>(
self,
_lengths: I,
) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
where
I: IntoIterator<Item = usize> + Clone,
{
let columns = [
self.image_from_camera
.map(|image_from_camera| image_from_camera.partitioned(_lengths.clone()))
.transpose()?,
self.resolution
.map(|resolution| resolution.partitioned(_lengths.clone()))
.transpose()?,
self.camera_xyz
.map(|camera_xyz| camera_xyz.partitioned(_lengths.clone()))
.transpose()?,
self.image_plane_distance
.map(|image_plane_distance| image_plane_distance.partitioned(_lengths.clone()))
.transpose()?,
self.color
.map(|color| color.partitioned(_lengths.clone()))
.transpose()?,
self.line_width
.map(|line_width| line_width.partitioned(_lengths.clone()))
.transpose()?,
];
Ok(columns.into_iter().flatten())
}
#[inline]
pub fn columns_of_unit_batches(
self,
) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
let len_image_from_camera = self.image_from_camera.as_ref().map(|b| b.array.len());
let len_resolution = self.resolution.as_ref().map(|b| b.array.len());
let len_camera_xyz = self.camera_xyz.as_ref().map(|b| b.array.len());
let len_image_plane_distance = self.image_plane_distance.as_ref().map(|b| b.array.len());
let len_color = self.color.as_ref().map(|b| b.array.len());
let len_line_width = self.line_width.as_ref().map(|b| b.array.len());
let len = None
.or(len_image_from_camera)
.or(len_resolution)
.or(len_camera_xyz)
.or(len_image_plane_distance)
.or(len_color)
.or(len_line_width)
.unwrap_or(0);
self.columns(std::iter::repeat_n(1, len))
}
#[inline]
pub fn with_image_from_camera(
mut self,
image_from_camera: impl Into<crate::components::PinholeProjection>,
) -> Self {
self.image_from_camera =
try_serialize_field(Self::descriptor_image_from_camera(), [image_from_camera]);
self
}
#[inline]
pub fn with_many_image_from_camera(
mut self,
image_from_camera: impl IntoIterator<Item = impl Into<crate::components::PinholeProjection>>,
) -> Self {
self.image_from_camera =
try_serialize_field(Self::descriptor_image_from_camera(), image_from_camera);
self
}
#[inline]
pub fn with_resolution(mut self, resolution: impl Into<crate::components::Resolution>) -> Self {
self.resolution = try_serialize_field(Self::descriptor_resolution(), [resolution]);
self
}
#[inline]
pub fn with_many_resolution(
mut self,
resolution: impl IntoIterator<Item = impl Into<crate::components::Resolution>>,
) -> Self {
self.resolution = try_serialize_field(Self::descriptor_resolution(), resolution);
self
}
#[inline]
pub fn with_camera_xyz(
mut self,
camera_xyz: impl Into<crate::components::ViewCoordinates>,
) -> Self {
self.camera_xyz = try_serialize_field(Self::descriptor_camera_xyz(), [camera_xyz]);
self
}
#[inline]
pub fn with_many_camera_xyz(
mut self,
camera_xyz: impl IntoIterator<Item = impl Into<crate::components::ViewCoordinates>>,
) -> Self {
self.camera_xyz = try_serialize_field(Self::descriptor_camera_xyz(), camera_xyz);
self
}
#[inline]
pub fn with_image_plane_distance(
mut self,
image_plane_distance: impl Into<crate::components::ImagePlaneDistance>,
) -> Self {
self.image_plane_distance = try_serialize_field(
Self::descriptor_image_plane_distance(),
[image_plane_distance],
);
self
}
#[inline]
pub fn with_many_image_plane_distance(
mut self,
image_plane_distance: impl IntoIterator<Item = impl Into<crate::components::ImagePlaneDistance>>,
) -> Self {
self.image_plane_distance = try_serialize_field(
Self::descriptor_image_plane_distance(),
image_plane_distance,
);
self
}
#[inline]
pub fn with_color(mut self, color: impl Into<crate::components::Color>) -> Self {
self.color = try_serialize_field(Self::descriptor_color(), [color]);
self
}
#[inline]
pub fn with_many_color(
mut self,
color: impl IntoIterator<Item = impl Into<crate::components::Color>>,
) -> Self {
self.color = try_serialize_field(Self::descriptor_color(), color);
self
}
#[inline]
pub fn with_line_width(mut self, line_width: impl Into<crate::components::Radius>) -> Self {
self.line_width = try_serialize_field(Self::descriptor_line_width(), [line_width]);
self
}
#[inline]
pub fn with_many_line_width(
mut self,
line_width: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
) -> Self {
self.line_width = try_serialize_field(Self::descriptor_line_width(), line_width);
self
}
}
impl ::re_byte_size::SizeBytes for Pinhole {
#[inline]
fn heap_size_bytes(&self) -> u64 {
self.image_from_camera.heap_size_bytes()
+ self.resolution.heap_size_bytes()
+ self.camera_xyz.heap_size_bytes()
+ self.image_plane_distance.heap_size_bytes()
+ self.color.heap_size_bytes()
+ self.line_width.heap_size_bytes()
}
}