1#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::clone_on_copy)]
8#![allow(clippy::cloned_instead_of_copied)]
9#![allow(clippy::map_flatten)]
10#![allow(clippy::needless_question_mark)]
11#![allow(clippy::new_without_default)]
12#![allow(clippy::redundant_closure)]
13#![allow(clippy::too_many_arguments)]
14#![allow(clippy::too_many_lines)]
15
16use ::re_types_core::try_serialize_field;
17use ::re_types_core::SerializationResult;
18use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
19use ::re_types_core::{ComponentDescriptor, ComponentType};
20use ::re_types_core::{DeserializationError, DeserializationResult};
21
22#[derive(Clone, Debug, PartialEq, Default)]
95pub struct InstancePoses3D {
96 pub translations: Option<SerializedComponentBatch>,
98
99 pub rotation_axis_angles: Option<SerializedComponentBatch>,
101
102 pub quaternions: Option<SerializedComponentBatch>,
104
105 pub scales: Option<SerializedComponentBatch>,
107
108 pub mat3x3: Option<SerializedComponentBatch>,
110}
111
112impl InstancePoses3D {
113 #[inline]
117 pub fn descriptor_translations() -> ComponentDescriptor {
118 ComponentDescriptor {
119 archetype: Some("rerun.archetypes.InstancePoses3D".into()),
120 component: "InstancePoses3D:translations".into(),
121 component_type: Some("rerun.components.PoseTranslation3D".into()),
122 }
123 }
124
125 #[inline]
129 pub fn descriptor_rotation_axis_angles() -> ComponentDescriptor {
130 ComponentDescriptor {
131 archetype: Some("rerun.archetypes.InstancePoses3D".into()),
132 component: "InstancePoses3D:rotation_axis_angles".into(),
133 component_type: Some("rerun.components.PoseRotationAxisAngle".into()),
134 }
135 }
136
137 #[inline]
141 pub fn descriptor_quaternions() -> ComponentDescriptor {
142 ComponentDescriptor {
143 archetype: Some("rerun.archetypes.InstancePoses3D".into()),
144 component: "InstancePoses3D:quaternions".into(),
145 component_type: Some("rerun.components.PoseRotationQuat".into()),
146 }
147 }
148
149 #[inline]
153 pub fn descriptor_scales() -> ComponentDescriptor {
154 ComponentDescriptor {
155 archetype: Some("rerun.archetypes.InstancePoses3D".into()),
156 component: "InstancePoses3D:scales".into(),
157 component_type: Some("rerun.components.PoseScale3D".into()),
158 }
159 }
160
161 #[inline]
165 pub fn descriptor_mat3x3() -> ComponentDescriptor {
166 ComponentDescriptor {
167 archetype: Some("rerun.archetypes.InstancePoses3D".into()),
168 component: "InstancePoses3D:mat3x3".into(),
169 component_type: Some("rerun.components.PoseTransformMat3x3".into()),
170 }
171 }
172}
173
174static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
175 once_cell::sync::Lazy::new(|| []);
176
177static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
178 once_cell::sync::Lazy::new(|| []);
179
180static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 5usize]> =
181 once_cell::sync::Lazy::new(|| {
182 [
183 InstancePoses3D::descriptor_translations(),
184 InstancePoses3D::descriptor_rotation_axis_angles(),
185 InstancePoses3D::descriptor_quaternions(),
186 InstancePoses3D::descriptor_scales(),
187 InstancePoses3D::descriptor_mat3x3(),
188 ]
189 });
190
191static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 5usize]> =
192 once_cell::sync::Lazy::new(|| {
193 [
194 InstancePoses3D::descriptor_translations(),
195 InstancePoses3D::descriptor_rotation_axis_angles(),
196 InstancePoses3D::descriptor_quaternions(),
197 InstancePoses3D::descriptor_scales(),
198 InstancePoses3D::descriptor_mat3x3(),
199 ]
200 });
201
202impl InstancePoses3D {
203 pub const NUM_COMPONENTS: usize = 5usize;
205}
206
207impl ::re_types_core::Archetype for InstancePoses3D {
208 #[inline]
209 fn name() -> ::re_types_core::ArchetypeName {
210 "rerun.archetypes.InstancePoses3D".into()
211 }
212
213 #[inline]
214 fn display_name() -> &'static str {
215 "Instance poses 3D"
216 }
217
218 #[inline]
219 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
220 REQUIRED_COMPONENTS.as_slice().into()
221 }
222
223 #[inline]
224 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
225 RECOMMENDED_COMPONENTS.as_slice().into()
226 }
227
228 #[inline]
229 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
230 OPTIONAL_COMPONENTS.as_slice().into()
231 }
232
233 #[inline]
234 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
235 ALL_COMPONENTS.as_slice().into()
236 }
237
238 #[inline]
239 fn from_arrow_components(
240 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
241 ) -> DeserializationResult<Self> {
242 re_tracing::profile_function!();
243 use ::re_types_core::{Loggable as _, ResultExt as _};
244 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
245 let translations = arrays_by_descr
246 .get(&Self::descriptor_translations())
247 .map(|array| {
248 SerializedComponentBatch::new(array.clone(), Self::descriptor_translations())
249 });
250 let rotation_axis_angles = arrays_by_descr
251 .get(&Self::descriptor_rotation_axis_angles())
252 .map(|array| {
253 SerializedComponentBatch::new(
254 array.clone(),
255 Self::descriptor_rotation_axis_angles(),
256 )
257 });
258 let quaternions = arrays_by_descr
259 .get(&Self::descriptor_quaternions())
260 .map(|array| {
261 SerializedComponentBatch::new(array.clone(), Self::descriptor_quaternions())
262 });
263 let scales = arrays_by_descr
264 .get(&Self::descriptor_scales())
265 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_scales()));
266 let mat3x3 = arrays_by_descr
267 .get(&Self::descriptor_mat3x3())
268 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_mat3x3()));
269 Ok(Self {
270 translations,
271 rotation_axis_angles,
272 quaternions,
273 scales,
274 mat3x3,
275 })
276 }
277}
278
279impl ::re_types_core::AsComponents for InstancePoses3D {
280 #[inline]
281 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
282 use ::re_types_core::Archetype as _;
283 [
284 self.translations.clone(),
285 self.rotation_axis_angles.clone(),
286 self.quaternions.clone(),
287 self.scales.clone(),
288 self.mat3x3.clone(),
289 ]
290 .into_iter()
291 .flatten()
292 .collect()
293 }
294}
295
296impl ::re_types_core::ArchetypeReflectionMarker for InstancePoses3D {}
297
298impl InstancePoses3D {
299 #[inline]
301 pub fn new() -> Self {
302 Self {
303 translations: None,
304 rotation_axis_angles: None,
305 quaternions: None,
306 scales: None,
307 mat3x3: None,
308 }
309 }
310
311 #[inline]
313 pub fn update_fields() -> Self {
314 Self::default()
315 }
316
317 #[inline]
319 pub fn clear_fields() -> Self {
320 use ::re_types_core::Loggable as _;
321 Self {
322 translations: Some(SerializedComponentBatch::new(
323 crate::components::PoseTranslation3D::arrow_empty(),
324 Self::descriptor_translations(),
325 )),
326 rotation_axis_angles: Some(SerializedComponentBatch::new(
327 crate::components::PoseRotationAxisAngle::arrow_empty(),
328 Self::descriptor_rotation_axis_angles(),
329 )),
330 quaternions: Some(SerializedComponentBatch::new(
331 crate::components::PoseRotationQuat::arrow_empty(),
332 Self::descriptor_quaternions(),
333 )),
334 scales: Some(SerializedComponentBatch::new(
335 crate::components::PoseScale3D::arrow_empty(),
336 Self::descriptor_scales(),
337 )),
338 mat3x3: Some(SerializedComponentBatch::new(
339 crate::components::PoseTransformMat3x3::arrow_empty(),
340 Self::descriptor_mat3x3(),
341 )),
342 }
343 }
344
345 #[inline]
356 pub fn columns<I>(
357 self,
358 _lengths: I,
359 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
360 where
361 I: IntoIterator<Item = usize> + Clone,
362 {
363 let columns = [
364 self.translations
365 .map(|translations| translations.partitioned(_lengths.clone()))
366 .transpose()?,
367 self.rotation_axis_angles
368 .map(|rotation_axis_angles| rotation_axis_angles.partitioned(_lengths.clone()))
369 .transpose()?,
370 self.quaternions
371 .map(|quaternions| quaternions.partitioned(_lengths.clone()))
372 .transpose()?,
373 self.scales
374 .map(|scales| scales.partitioned(_lengths.clone()))
375 .transpose()?,
376 self.mat3x3
377 .map(|mat3x3| mat3x3.partitioned(_lengths.clone()))
378 .transpose()?,
379 ];
380 Ok(columns.into_iter().flatten())
381 }
382
383 #[inline]
388 pub fn columns_of_unit_batches(
389 self,
390 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
391 let len_translations = self.translations.as_ref().map(|b| b.array.len());
392 let len_rotation_axis_angles = self.rotation_axis_angles.as_ref().map(|b| b.array.len());
393 let len_quaternions = self.quaternions.as_ref().map(|b| b.array.len());
394 let len_scales = self.scales.as_ref().map(|b| b.array.len());
395 let len_mat3x3 = self.mat3x3.as_ref().map(|b| b.array.len());
396 let len = None
397 .or(len_translations)
398 .or(len_rotation_axis_angles)
399 .or(len_quaternions)
400 .or(len_scales)
401 .or(len_mat3x3)
402 .unwrap_or(0);
403 self.columns(std::iter::repeat(1).take(len))
404 }
405
406 #[inline]
408 pub fn with_translations(
409 mut self,
410 translations: impl IntoIterator<Item = impl Into<crate::components::PoseTranslation3D>>,
411 ) -> Self {
412 self.translations = try_serialize_field(Self::descriptor_translations(), translations);
413 self
414 }
415
416 #[inline]
418 pub fn with_rotation_axis_angles(
419 mut self,
420 rotation_axis_angles: impl IntoIterator<
421 Item = impl Into<crate::components::PoseRotationAxisAngle>,
422 >,
423 ) -> Self {
424 self.rotation_axis_angles = try_serialize_field(
425 Self::descriptor_rotation_axis_angles(),
426 rotation_axis_angles,
427 );
428 self
429 }
430
431 #[inline]
433 pub fn with_quaternions(
434 mut self,
435 quaternions: impl IntoIterator<Item = impl Into<crate::components::PoseRotationQuat>>,
436 ) -> Self {
437 self.quaternions = try_serialize_field(Self::descriptor_quaternions(), quaternions);
438 self
439 }
440
441 #[inline]
443 pub fn with_scales(
444 mut self,
445 scales: impl IntoIterator<Item = impl Into<crate::components::PoseScale3D>>,
446 ) -> Self {
447 self.scales = try_serialize_field(Self::descriptor_scales(), scales);
448 self
449 }
450
451 #[inline]
453 pub fn with_mat3x3(
454 mut self,
455 mat3x3: impl IntoIterator<Item = impl Into<crate::components::PoseTransformMat3x3>>,
456 ) -> Self {
457 self.mat3x3 = try_serialize_field(Self::descriptor_mat3x3(), mat3x3);
458 self
459 }
460}
461
462impl ::re_byte_size::SizeBytes for InstancePoses3D {
463 #[inline]
464 fn heap_size_bytes(&self) -> u64 {
465 self.translations.heap_size_bytes()
466 + self.rotation_axis_angles.heap_size_bytes()
467 + self.quaternions.heap_size_bytes()
468 + self.scales.heap_size_bytes()
469 + self.mat3x3.heap_size_bytes()
470 }
471}