#![allow(unused_imports)]
#![allow(unused_parens)]
#![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)]
use ::re_types_core::external::arrow2;
use ::re_types_core::SerializationResult;
use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor};
use ::re_types_core::{ComponentDescriptor, ComponentName};
use ::re_types_core::{DeserializationError, DeserializationResult};
#[derive(Clone, Debug, PartialEq)]
pub struct Mesh3D {
pub vertex_positions: Vec<crate::components::Position3D>,
pub triangle_indices: Option<Vec<crate::components::TriangleIndices>>,
pub vertex_normals: Option<Vec<crate::components::Vector3D>>,
pub vertex_colors: Option<Vec<crate::components::Color>>,
pub vertex_texcoords: Option<Vec<crate::components::Texcoord2D>>,
pub albedo_factor: Option<crate::components::AlbedoFactor>,
pub albedo_texture_buffer: Option<crate::components::ImageBuffer>,
pub albedo_texture_format: Option<crate::components::ImageFormat>,
pub class_ids: Option<Vec<crate::components::ClassId>>,
}
static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
once_cell::sync::Lazy::new(|| {
[ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.Position3D".into(),
archetype_field_name: Some("vertex_positions".into()),
}]
});
static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> =
once_cell::sync::Lazy::new(|| {
[
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.TriangleIndices".into(),
archetype_field_name: Some("triangle_indices".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.Vector3D".into(),
archetype_field_name: Some("vertex_normals".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.Mesh3DIndicator".into(),
archetype_field_name: None,
},
]
});
static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 6usize]> =
once_cell::sync::Lazy::new(|| {
[
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.Color".into(),
archetype_field_name: Some("vertex_colors".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.Texcoord2D".into(),
archetype_field_name: Some("vertex_texcoords".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.AlbedoFactor".into(),
archetype_field_name: Some("albedo_factor".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.ImageBuffer".into(),
archetype_field_name: Some("albedo_texture_buffer".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.ImageFormat".into(),
archetype_field_name: Some("albedo_texture_format".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.ClassId".into(),
archetype_field_name: Some("class_ids".into()),
},
]
});
static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 10usize]> =
once_cell::sync::Lazy::new(|| {
[
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.Position3D".into(),
archetype_field_name: Some("vertex_positions".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.TriangleIndices".into(),
archetype_field_name: Some("triangle_indices".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.Vector3D".into(),
archetype_field_name: Some("vertex_normals".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.Mesh3DIndicator".into(),
archetype_field_name: None,
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.Color".into(),
archetype_field_name: Some("vertex_colors".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.Texcoord2D".into(),
archetype_field_name: Some("vertex_texcoords".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.AlbedoFactor".into(),
archetype_field_name: Some("albedo_factor".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.ImageBuffer".into(),
archetype_field_name: Some("albedo_texture_buffer".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.ImageFormat".into(),
archetype_field_name: Some("albedo_texture_format".into()),
},
ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
component_name: "rerun.components.ClassId".into(),
archetype_field_name: Some("class_ids".into()),
},
]
});
impl Mesh3D {
pub const NUM_COMPONENTS: usize = 10usize;
}
pub type Mesh3DIndicator = ::re_types_core::GenericIndicatorComponent<Mesh3D>;
impl ::re_types_core::Archetype for Mesh3D {
type Indicator = Mesh3DIndicator;
#[inline]
fn name() -> ::re_types_core::ArchetypeName {
"rerun.archetypes.Mesh3D".into()
}
#[inline]
fn display_name() -> &'static str {
"Mesh 3D"
}
#[inline]
fn indicator() -> ComponentBatchCowWithDescriptor<'static> {
static INDICATOR: Mesh3DIndicator = Mesh3DIndicator::DEFAULT;
ComponentBatchCowWithDescriptor::new(&INDICATOR as &dyn ::re_types_core::ComponentBatch)
}
#[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_arrow2_components(
arrow_data: impl IntoIterator<Item = (ComponentName, Box<dyn arrow2::array::Array>)>,
) -> DeserializationResult<Self> {
re_tracing::profile_function!();
use ::re_types_core::{Loggable as _, ResultExt as _};
let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data
.into_iter()
.map(|(name, array)| (name.full_name(), array))
.collect();
let vertex_positions = {
let array = arrays_by_name
.get("rerun.components.Position3D")
.ok_or_else(DeserializationError::missing_data)
.with_context("rerun.archetypes.Mesh3D#vertex_positions")?;
<crate::components::Position3D>::from_arrow2_opt(&**array)
.with_context("rerun.archetypes.Mesh3D#vertex_positions")?
.into_iter()
.map(|v| v.ok_or_else(DeserializationError::missing_data))
.collect::<DeserializationResult<Vec<_>>>()
.with_context("rerun.archetypes.Mesh3D#vertex_positions")?
};
let triangle_indices =
if let Some(array) = arrays_by_name.get("rerun.components.TriangleIndices") {
Some({
<crate::components::TriangleIndices>::from_arrow2_opt(&**array)
.with_context("rerun.archetypes.Mesh3D#triangle_indices")?
.into_iter()
.map(|v| v.ok_or_else(DeserializationError::missing_data))
.collect::<DeserializationResult<Vec<_>>>()
.with_context("rerun.archetypes.Mesh3D#triangle_indices")?
})
} else {
None
};
let vertex_normals = if let Some(array) = arrays_by_name.get("rerun.components.Vector3D") {
Some({
<crate::components::Vector3D>::from_arrow2_opt(&**array)
.with_context("rerun.archetypes.Mesh3D#vertex_normals")?
.into_iter()
.map(|v| v.ok_or_else(DeserializationError::missing_data))
.collect::<DeserializationResult<Vec<_>>>()
.with_context("rerun.archetypes.Mesh3D#vertex_normals")?
})
} else {
None
};
let vertex_colors = if let Some(array) = arrays_by_name.get("rerun.components.Color") {
Some({
<crate::components::Color>::from_arrow2_opt(&**array)
.with_context("rerun.archetypes.Mesh3D#vertex_colors")?
.into_iter()
.map(|v| v.ok_or_else(DeserializationError::missing_data))
.collect::<DeserializationResult<Vec<_>>>()
.with_context("rerun.archetypes.Mesh3D#vertex_colors")?
})
} else {
None
};
let vertex_texcoords =
if let Some(array) = arrays_by_name.get("rerun.components.Texcoord2D") {
Some({
<crate::components::Texcoord2D>::from_arrow2_opt(&**array)
.with_context("rerun.archetypes.Mesh3D#vertex_texcoords")?
.into_iter()
.map(|v| v.ok_or_else(DeserializationError::missing_data))
.collect::<DeserializationResult<Vec<_>>>()
.with_context("rerun.archetypes.Mesh3D#vertex_texcoords")?
})
} else {
None
};
let albedo_factor = if let Some(array) = arrays_by_name.get("rerun.components.AlbedoFactor")
{
<crate::components::AlbedoFactor>::from_arrow2_opt(&**array)
.with_context("rerun.archetypes.Mesh3D#albedo_factor")?
.into_iter()
.next()
.flatten()
} else {
None
};
let albedo_texture_buffer =
if let Some(array) = arrays_by_name.get("rerun.components.ImageBuffer") {
<crate::components::ImageBuffer>::from_arrow2_opt(&**array)
.with_context("rerun.archetypes.Mesh3D#albedo_texture_buffer")?
.into_iter()
.next()
.flatten()
} else {
None
};
let albedo_texture_format =
if let Some(array) = arrays_by_name.get("rerun.components.ImageFormat") {
<crate::components::ImageFormat>::from_arrow2_opt(&**array)
.with_context("rerun.archetypes.Mesh3D#albedo_texture_format")?
.into_iter()
.next()
.flatten()
} else {
None
};
let class_ids = if let Some(array) = arrays_by_name.get("rerun.components.ClassId") {
Some({
<crate::components::ClassId>::from_arrow2_opt(&**array)
.with_context("rerun.archetypes.Mesh3D#class_ids")?
.into_iter()
.map(|v| v.ok_or_else(DeserializationError::missing_data))
.collect::<DeserializationResult<Vec<_>>>()
.with_context("rerun.archetypes.Mesh3D#class_ids")?
})
} else {
None
};
Ok(Self {
vertex_positions,
triangle_indices,
vertex_normals,
vertex_colors,
vertex_texcoords,
albedo_factor,
albedo_texture_buffer,
albedo_texture_format,
class_ids,
})
}
}
impl ::re_types_core::AsComponents for Mesh3D {
fn as_component_batches(&self) -> Vec<ComponentBatchCowWithDescriptor<'_>> {
re_tracing::profile_function!();
use ::re_types_core::Archetype as _;
[
Some(Self::indicator()),
(Some(&self.vertex_positions as &dyn ComponentBatch)).map(|batch| {
::re_types_core::ComponentBatchCowWithDescriptor {
batch: batch.into(),
descriptor_override: Some(ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
archetype_field_name: Some(("vertex_positions").into()),
component_name: ("rerun.components.Position3D").into(),
}),
}
}),
(self
.triangle_indices
.as_ref()
.map(|comp_batch| (comp_batch as &dyn ComponentBatch)))
.map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor {
batch: batch.into(),
descriptor_override: Some(ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
archetype_field_name: Some(("triangle_indices").into()),
component_name: ("rerun.components.TriangleIndices").into(),
}),
}),
(self
.vertex_normals
.as_ref()
.map(|comp_batch| (comp_batch as &dyn ComponentBatch)))
.map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor {
batch: batch.into(),
descriptor_override: Some(ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
archetype_field_name: Some(("vertex_normals").into()),
component_name: ("rerun.components.Vector3D").into(),
}),
}),
(self
.vertex_colors
.as_ref()
.map(|comp_batch| (comp_batch as &dyn ComponentBatch)))
.map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor {
batch: batch.into(),
descriptor_override: Some(ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
archetype_field_name: Some(("vertex_colors").into()),
component_name: ("rerun.components.Color").into(),
}),
}),
(self
.vertex_texcoords
.as_ref()
.map(|comp_batch| (comp_batch as &dyn ComponentBatch)))
.map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor {
batch: batch.into(),
descriptor_override: Some(ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
archetype_field_name: Some(("vertex_texcoords").into()),
component_name: ("rerun.components.Texcoord2D").into(),
}),
}),
(self
.albedo_factor
.as_ref()
.map(|comp| (comp as &dyn ComponentBatch)))
.map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor {
batch: batch.into(),
descriptor_override: Some(ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
archetype_field_name: Some(("albedo_factor").into()),
component_name: ("rerun.components.AlbedoFactor").into(),
}),
}),
(self
.albedo_texture_buffer
.as_ref()
.map(|comp| (comp as &dyn ComponentBatch)))
.map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor {
batch: batch.into(),
descriptor_override: Some(ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
archetype_field_name: Some(("albedo_texture_buffer").into()),
component_name: ("rerun.components.ImageBuffer").into(),
}),
}),
(self
.albedo_texture_format
.as_ref()
.map(|comp| (comp as &dyn ComponentBatch)))
.map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor {
batch: batch.into(),
descriptor_override: Some(ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
archetype_field_name: Some(("albedo_texture_format").into()),
component_name: ("rerun.components.ImageFormat").into(),
}),
}),
(self
.class_ids
.as_ref()
.map(|comp_batch| (comp_batch as &dyn ComponentBatch)))
.map(|batch| ::re_types_core::ComponentBatchCowWithDescriptor {
batch: batch.into(),
descriptor_override: Some(ComponentDescriptor {
archetype_name: Some("rerun.archetypes.Mesh3D".into()),
archetype_field_name: Some(("class_ids").into()),
component_name: ("rerun.components.ClassId").into(),
}),
}),
]
.into_iter()
.flatten()
.collect()
}
}
impl ::re_types_core::ArchetypeReflectionMarker for Mesh3D {}
impl Mesh3D {
#[inline]
pub fn new(
vertex_positions: impl IntoIterator<Item = impl Into<crate::components::Position3D>>,
) -> Self {
Self {
vertex_positions: vertex_positions.into_iter().map(Into::into).collect(),
triangle_indices: None,
vertex_normals: None,
vertex_colors: None,
vertex_texcoords: None,
albedo_factor: None,
albedo_texture_buffer: None,
albedo_texture_format: None,
class_ids: None,
}
}
#[inline]
pub fn with_triangle_indices(
mut self,
triangle_indices: impl IntoIterator<Item = impl Into<crate::components::TriangleIndices>>,
) -> Self {
self.triangle_indices = Some(triangle_indices.into_iter().map(Into::into).collect());
self
}
#[inline]
pub fn with_vertex_normals(
mut self,
vertex_normals: impl IntoIterator<Item = impl Into<crate::components::Vector3D>>,
) -> Self {
self.vertex_normals = Some(vertex_normals.into_iter().map(Into::into).collect());
self
}
#[inline]
pub fn with_vertex_colors(
mut self,
vertex_colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
) -> Self {
self.vertex_colors = Some(vertex_colors.into_iter().map(Into::into).collect());
self
}
#[inline]
pub fn with_vertex_texcoords(
mut self,
vertex_texcoords: impl IntoIterator<Item = impl Into<crate::components::Texcoord2D>>,
) -> Self {
self.vertex_texcoords = Some(vertex_texcoords.into_iter().map(Into::into).collect());
self
}
#[inline]
pub fn with_albedo_factor(
mut self,
albedo_factor: impl Into<crate::components::AlbedoFactor>,
) -> Self {
self.albedo_factor = Some(albedo_factor.into());
self
}
#[inline]
pub fn with_albedo_texture_buffer(
mut self,
albedo_texture_buffer: impl Into<crate::components::ImageBuffer>,
) -> Self {
self.albedo_texture_buffer = Some(albedo_texture_buffer.into());
self
}
#[inline]
pub fn with_albedo_texture_format(
mut self,
albedo_texture_format: impl Into<crate::components::ImageFormat>,
) -> Self {
self.albedo_texture_format = Some(albedo_texture_format.into());
self
}
#[inline]
pub fn with_class_ids(
mut self,
class_ids: impl IntoIterator<Item = impl Into<crate::components::ClassId>>,
) -> Self {
self.class_ids = Some(class_ids.into_iter().map(Into::into).collect());
self
}
}
impl ::re_types_core::SizeBytes for Mesh3D {
#[inline]
fn heap_size_bytes(&self) -> u64 {
self.vertex_positions.heap_size_bytes()
+ self.triangle_indices.heap_size_bytes()
+ self.vertex_normals.heap_size_bytes()
+ self.vertex_colors.heap_size_bytes()
+ self.vertex_texcoords.heap_size_bytes()
+ self.albedo_factor.heap_size_bytes()
+ self.albedo_texture_buffer.heap_size_bytes()
+ self.albedo_texture_format.heap_size_bytes()
+ self.class_ids.heap_size_bytes()
}
#[inline]
fn is_pod() -> bool {
<Vec<crate::components::Position3D>>::is_pod()
&& <Option<Vec<crate::components::TriangleIndices>>>::is_pod()
&& <Option<Vec<crate::components::Vector3D>>>::is_pod()
&& <Option<Vec<crate::components::Color>>>::is_pod()
&& <Option<Vec<crate::components::Texcoord2D>>>::is_pod()
&& <Option<crate::components::AlbedoFactor>>::is_pod()
&& <Option<crate::components::ImageBuffer>>::is_pod()
&& <Option<crate::components::ImageFormat>>::is_pod()
&& <Option<Vec<crate::components::ClassId>>>::is_pod()
}
}