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)]
83pub struct Ellipsoids3D {
84 pub half_sizes: Option<SerializedComponentBatch>,
88
89 pub centers: Option<SerializedComponentBatch>,
93
94 pub rotation_axis_angles: Option<SerializedComponentBatch>,
98
99 pub quaternions: Option<SerializedComponentBatch>,
103
104 pub colors: Option<SerializedComponentBatch>,
106
107 pub line_radii: Option<SerializedComponentBatch>,
109
110 pub fill_mode: Option<SerializedComponentBatch>,
112
113 pub labels: Option<SerializedComponentBatch>,
115
116 pub show_labels: Option<SerializedComponentBatch>,
121
122 pub class_ids: Option<SerializedComponentBatch>,
126}
127
128impl Ellipsoids3D {
129 #[inline]
133 pub fn descriptor_half_sizes() -> ComponentDescriptor {
134 ComponentDescriptor {
135 archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
136 component: "Ellipsoids3D:half_sizes".into(),
137 component_type: Some("rerun.components.HalfSize3D".into()),
138 }
139 }
140
141 #[inline]
145 pub fn descriptor_centers() -> ComponentDescriptor {
146 ComponentDescriptor {
147 archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
148 component: "Ellipsoids3D:centers".into(),
149 component_type: Some("rerun.components.PoseTranslation3D".into()),
150 }
151 }
152
153 #[inline]
157 pub fn descriptor_rotation_axis_angles() -> ComponentDescriptor {
158 ComponentDescriptor {
159 archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
160 component: "Ellipsoids3D:rotation_axis_angles".into(),
161 component_type: Some("rerun.components.PoseRotationAxisAngle".into()),
162 }
163 }
164
165 #[inline]
169 pub fn descriptor_quaternions() -> ComponentDescriptor {
170 ComponentDescriptor {
171 archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
172 component: "Ellipsoids3D:quaternions".into(),
173 component_type: Some("rerun.components.PoseRotationQuat".into()),
174 }
175 }
176
177 #[inline]
181 pub fn descriptor_colors() -> ComponentDescriptor {
182 ComponentDescriptor {
183 archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
184 component: "Ellipsoids3D:colors".into(),
185 component_type: Some("rerun.components.Color".into()),
186 }
187 }
188
189 #[inline]
193 pub fn descriptor_line_radii() -> ComponentDescriptor {
194 ComponentDescriptor {
195 archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
196 component: "Ellipsoids3D:line_radii".into(),
197 component_type: Some("rerun.components.Radius".into()),
198 }
199 }
200
201 #[inline]
205 pub fn descriptor_fill_mode() -> ComponentDescriptor {
206 ComponentDescriptor {
207 archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
208 component: "Ellipsoids3D:fill_mode".into(),
209 component_type: Some("rerun.components.FillMode".into()),
210 }
211 }
212
213 #[inline]
217 pub fn descriptor_labels() -> ComponentDescriptor {
218 ComponentDescriptor {
219 archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
220 component: "Ellipsoids3D:labels".into(),
221 component_type: Some("rerun.components.Text".into()),
222 }
223 }
224
225 #[inline]
229 pub fn descriptor_show_labels() -> ComponentDescriptor {
230 ComponentDescriptor {
231 archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
232 component: "Ellipsoids3D:show_labels".into(),
233 component_type: Some("rerun.components.ShowLabels".into()),
234 }
235 }
236
237 #[inline]
241 pub fn descriptor_class_ids() -> ComponentDescriptor {
242 ComponentDescriptor {
243 archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
244 component: "Ellipsoids3D:class_ids".into(),
245 component_type: Some("rerun.components.ClassId".into()),
246 }
247 }
248}
249
250static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
251 once_cell::sync::Lazy::new(|| [Ellipsoids3D::descriptor_half_sizes()]);
252
253static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
254 once_cell::sync::Lazy::new(|| {
255 [
256 Ellipsoids3D::descriptor_centers(),
257 Ellipsoids3D::descriptor_colors(),
258 ]
259 });
260
261static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 7usize]> =
262 once_cell::sync::Lazy::new(|| {
263 [
264 Ellipsoids3D::descriptor_rotation_axis_angles(),
265 Ellipsoids3D::descriptor_quaternions(),
266 Ellipsoids3D::descriptor_line_radii(),
267 Ellipsoids3D::descriptor_fill_mode(),
268 Ellipsoids3D::descriptor_labels(),
269 Ellipsoids3D::descriptor_show_labels(),
270 Ellipsoids3D::descriptor_class_ids(),
271 ]
272 });
273
274static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 10usize]> =
275 once_cell::sync::Lazy::new(|| {
276 [
277 Ellipsoids3D::descriptor_half_sizes(),
278 Ellipsoids3D::descriptor_centers(),
279 Ellipsoids3D::descriptor_colors(),
280 Ellipsoids3D::descriptor_rotation_axis_angles(),
281 Ellipsoids3D::descriptor_quaternions(),
282 Ellipsoids3D::descriptor_line_radii(),
283 Ellipsoids3D::descriptor_fill_mode(),
284 Ellipsoids3D::descriptor_labels(),
285 Ellipsoids3D::descriptor_show_labels(),
286 Ellipsoids3D::descriptor_class_ids(),
287 ]
288 });
289
290impl Ellipsoids3D {
291 pub const NUM_COMPONENTS: usize = 10usize;
293}
294
295impl ::re_types_core::Archetype for Ellipsoids3D {
296 #[inline]
297 fn name() -> ::re_types_core::ArchetypeName {
298 "rerun.archetypes.Ellipsoids3D".into()
299 }
300
301 #[inline]
302 fn display_name() -> &'static str {
303 "Ellipsoids 3D"
304 }
305
306 #[inline]
307 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
308 REQUIRED_COMPONENTS.as_slice().into()
309 }
310
311 #[inline]
312 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
313 RECOMMENDED_COMPONENTS.as_slice().into()
314 }
315
316 #[inline]
317 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
318 OPTIONAL_COMPONENTS.as_slice().into()
319 }
320
321 #[inline]
322 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
323 ALL_COMPONENTS.as_slice().into()
324 }
325
326 #[inline]
327 fn from_arrow_components(
328 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
329 ) -> DeserializationResult<Self> {
330 re_tracing::profile_function!();
331 use ::re_types_core::{Loggable as _, ResultExt as _};
332 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
333 let half_sizes = arrays_by_descr
334 .get(&Self::descriptor_half_sizes())
335 .map(|array| {
336 SerializedComponentBatch::new(array.clone(), Self::descriptor_half_sizes())
337 });
338 let centers = arrays_by_descr
339 .get(&Self::descriptor_centers())
340 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_centers()));
341 let rotation_axis_angles = arrays_by_descr
342 .get(&Self::descriptor_rotation_axis_angles())
343 .map(|array| {
344 SerializedComponentBatch::new(
345 array.clone(),
346 Self::descriptor_rotation_axis_angles(),
347 )
348 });
349 let quaternions = arrays_by_descr
350 .get(&Self::descriptor_quaternions())
351 .map(|array| {
352 SerializedComponentBatch::new(array.clone(), Self::descriptor_quaternions())
353 });
354 let colors = arrays_by_descr
355 .get(&Self::descriptor_colors())
356 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
357 let line_radii = arrays_by_descr
358 .get(&Self::descriptor_line_radii())
359 .map(|array| {
360 SerializedComponentBatch::new(array.clone(), Self::descriptor_line_radii())
361 });
362 let fill_mode = arrays_by_descr
363 .get(&Self::descriptor_fill_mode())
364 .map(|array| {
365 SerializedComponentBatch::new(array.clone(), Self::descriptor_fill_mode())
366 });
367 let labels = arrays_by_descr
368 .get(&Self::descriptor_labels())
369 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_labels()));
370 let show_labels = arrays_by_descr
371 .get(&Self::descriptor_show_labels())
372 .map(|array| {
373 SerializedComponentBatch::new(array.clone(), Self::descriptor_show_labels())
374 });
375 let class_ids = arrays_by_descr
376 .get(&Self::descriptor_class_ids())
377 .map(|array| {
378 SerializedComponentBatch::new(array.clone(), Self::descriptor_class_ids())
379 });
380 Ok(Self {
381 half_sizes,
382 centers,
383 rotation_axis_angles,
384 quaternions,
385 colors,
386 line_radii,
387 fill_mode,
388 labels,
389 show_labels,
390 class_ids,
391 })
392 }
393}
394
395impl ::re_types_core::AsComponents for Ellipsoids3D {
396 #[inline]
397 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
398 use ::re_types_core::Archetype as _;
399 [
400 self.half_sizes.clone(),
401 self.centers.clone(),
402 self.rotation_axis_angles.clone(),
403 self.quaternions.clone(),
404 self.colors.clone(),
405 self.line_radii.clone(),
406 self.fill_mode.clone(),
407 self.labels.clone(),
408 self.show_labels.clone(),
409 self.class_ids.clone(),
410 ]
411 .into_iter()
412 .flatten()
413 .collect()
414 }
415}
416
417impl ::re_types_core::ArchetypeReflectionMarker for Ellipsoids3D {}
418
419impl Ellipsoids3D {
420 #[inline]
422 pub(crate) fn new(
423 half_sizes: impl IntoIterator<Item = impl Into<crate::components::HalfSize3D>>,
424 ) -> Self {
425 Self {
426 half_sizes: try_serialize_field(Self::descriptor_half_sizes(), half_sizes),
427 centers: None,
428 rotation_axis_angles: None,
429 quaternions: None,
430 colors: None,
431 line_radii: None,
432 fill_mode: None,
433 labels: None,
434 show_labels: None,
435 class_ids: None,
436 }
437 }
438
439 #[inline]
441 pub fn update_fields() -> Self {
442 Self::default()
443 }
444
445 #[inline]
447 pub fn clear_fields() -> Self {
448 use ::re_types_core::Loggable as _;
449 Self {
450 half_sizes: Some(SerializedComponentBatch::new(
451 crate::components::HalfSize3D::arrow_empty(),
452 Self::descriptor_half_sizes(),
453 )),
454 centers: Some(SerializedComponentBatch::new(
455 crate::components::PoseTranslation3D::arrow_empty(),
456 Self::descriptor_centers(),
457 )),
458 rotation_axis_angles: Some(SerializedComponentBatch::new(
459 crate::components::PoseRotationAxisAngle::arrow_empty(),
460 Self::descriptor_rotation_axis_angles(),
461 )),
462 quaternions: Some(SerializedComponentBatch::new(
463 crate::components::PoseRotationQuat::arrow_empty(),
464 Self::descriptor_quaternions(),
465 )),
466 colors: Some(SerializedComponentBatch::new(
467 crate::components::Color::arrow_empty(),
468 Self::descriptor_colors(),
469 )),
470 line_radii: Some(SerializedComponentBatch::new(
471 crate::components::Radius::arrow_empty(),
472 Self::descriptor_line_radii(),
473 )),
474 fill_mode: Some(SerializedComponentBatch::new(
475 crate::components::FillMode::arrow_empty(),
476 Self::descriptor_fill_mode(),
477 )),
478 labels: Some(SerializedComponentBatch::new(
479 crate::components::Text::arrow_empty(),
480 Self::descriptor_labels(),
481 )),
482 show_labels: Some(SerializedComponentBatch::new(
483 crate::components::ShowLabels::arrow_empty(),
484 Self::descriptor_show_labels(),
485 )),
486 class_ids: Some(SerializedComponentBatch::new(
487 crate::components::ClassId::arrow_empty(),
488 Self::descriptor_class_ids(),
489 )),
490 }
491 }
492
493 #[inline]
504 pub fn columns<I>(
505 self,
506 _lengths: I,
507 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
508 where
509 I: IntoIterator<Item = usize> + Clone,
510 {
511 let columns = [
512 self.half_sizes
513 .map(|half_sizes| half_sizes.partitioned(_lengths.clone()))
514 .transpose()?,
515 self.centers
516 .map(|centers| centers.partitioned(_lengths.clone()))
517 .transpose()?,
518 self.rotation_axis_angles
519 .map(|rotation_axis_angles| rotation_axis_angles.partitioned(_lengths.clone()))
520 .transpose()?,
521 self.quaternions
522 .map(|quaternions| quaternions.partitioned(_lengths.clone()))
523 .transpose()?,
524 self.colors
525 .map(|colors| colors.partitioned(_lengths.clone()))
526 .transpose()?,
527 self.line_radii
528 .map(|line_radii| line_radii.partitioned(_lengths.clone()))
529 .transpose()?,
530 self.fill_mode
531 .map(|fill_mode| fill_mode.partitioned(_lengths.clone()))
532 .transpose()?,
533 self.labels
534 .map(|labels| labels.partitioned(_lengths.clone()))
535 .transpose()?,
536 self.show_labels
537 .map(|show_labels| show_labels.partitioned(_lengths.clone()))
538 .transpose()?,
539 self.class_ids
540 .map(|class_ids| class_ids.partitioned(_lengths.clone()))
541 .transpose()?,
542 ];
543 Ok(columns.into_iter().flatten())
544 }
545
546 #[inline]
551 pub fn columns_of_unit_batches(
552 self,
553 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
554 let len_half_sizes = self.half_sizes.as_ref().map(|b| b.array.len());
555 let len_centers = self.centers.as_ref().map(|b| b.array.len());
556 let len_rotation_axis_angles = self.rotation_axis_angles.as_ref().map(|b| b.array.len());
557 let len_quaternions = self.quaternions.as_ref().map(|b| b.array.len());
558 let len_colors = self.colors.as_ref().map(|b| b.array.len());
559 let len_line_radii = self.line_radii.as_ref().map(|b| b.array.len());
560 let len_fill_mode = self.fill_mode.as_ref().map(|b| b.array.len());
561 let len_labels = self.labels.as_ref().map(|b| b.array.len());
562 let len_show_labels = self.show_labels.as_ref().map(|b| b.array.len());
563 let len_class_ids = self.class_ids.as_ref().map(|b| b.array.len());
564 let len = None
565 .or(len_half_sizes)
566 .or(len_centers)
567 .or(len_rotation_axis_angles)
568 .or(len_quaternions)
569 .or(len_colors)
570 .or(len_line_radii)
571 .or(len_fill_mode)
572 .or(len_labels)
573 .or(len_show_labels)
574 .or(len_class_ids)
575 .unwrap_or(0);
576 self.columns(std::iter::repeat(1).take(len))
577 }
578
579 #[inline]
583 pub fn with_half_sizes(
584 mut self,
585 half_sizes: impl IntoIterator<Item = impl Into<crate::components::HalfSize3D>>,
586 ) -> Self {
587 self.half_sizes = try_serialize_field(Self::descriptor_half_sizes(), half_sizes);
588 self
589 }
590
591 #[inline]
595 pub fn with_centers(
596 mut self,
597 centers: impl IntoIterator<Item = impl Into<crate::components::PoseTranslation3D>>,
598 ) -> Self {
599 self.centers = try_serialize_field(Self::descriptor_centers(), centers);
600 self
601 }
602
603 #[inline]
607 pub fn with_rotation_axis_angles(
608 mut self,
609 rotation_axis_angles: impl IntoIterator<
610 Item = impl Into<crate::components::PoseRotationAxisAngle>,
611 >,
612 ) -> Self {
613 self.rotation_axis_angles = try_serialize_field(
614 Self::descriptor_rotation_axis_angles(),
615 rotation_axis_angles,
616 );
617 self
618 }
619
620 #[inline]
624 pub fn with_quaternions(
625 mut self,
626 quaternions: impl IntoIterator<Item = impl Into<crate::components::PoseRotationQuat>>,
627 ) -> Self {
628 self.quaternions = try_serialize_field(Self::descriptor_quaternions(), quaternions);
629 self
630 }
631
632 #[inline]
634 pub fn with_colors(
635 mut self,
636 colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
637 ) -> Self {
638 self.colors = try_serialize_field(Self::descriptor_colors(), colors);
639 self
640 }
641
642 #[inline]
644 pub fn with_line_radii(
645 mut self,
646 line_radii: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
647 ) -> Self {
648 self.line_radii = try_serialize_field(Self::descriptor_line_radii(), line_radii);
649 self
650 }
651
652 #[inline]
654 pub fn with_fill_mode(mut self, fill_mode: impl Into<crate::components::FillMode>) -> Self {
655 self.fill_mode = try_serialize_field(Self::descriptor_fill_mode(), [fill_mode]);
656 self
657 }
658
659 #[inline]
664 pub fn with_many_fill_mode(
665 mut self,
666 fill_mode: impl IntoIterator<Item = impl Into<crate::components::FillMode>>,
667 ) -> Self {
668 self.fill_mode = try_serialize_field(Self::descriptor_fill_mode(), fill_mode);
669 self
670 }
671
672 #[inline]
674 pub fn with_labels(
675 mut self,
676 labels: impl IntoIterator<Item = impl Into<crate::components::Text>>,
677 ) -> Self {
678 self.labels = try_serialize_field(Self::descriptor_labels(), labels);
679 self
680 }
681
682 #[inline]
687 pub fn with_show_labels(
688 mut self,
689 show_labels: impl Into<crate::components::ShowLabels>,
690 ) -> Self {
691 self.show_labels = try_serialize_field(Self::descriptor_show_labels(), [show_labels]);
692 self
693 }
694
695 #[inline]
700 pub fn with_many_show_labels(
701 mut self,
702 show_labels: impl IntoIterator<Item = impl Into<crate::components::ShowLabels>>,
703 ) -> Self {
704 self.show_labels = try_serialize_field(Self::descriptor_show_labels(), show_labels);
705 self
706 }
707
708 #[inline]
712 pub fn with_class_ids(
713 mut self,
714 class_ids: impl IntoIterator<Item = impl Into<crate::components::ClassId>>,
715 ) -> Self {
716 self.class_ids = try_serialize_field(Self::descriptor_class_ids(), class_ids);
717 self
718 }
719}
720
721impl ::re_byte_size::SizeBytes for Ellipsoids3D {
722 #[inline]
723 fn heap_size_bytes(&self) -> u64 {
724 self.half_sizes.heap_size_bytes()
725 + self.centers.heap_size_bytes()
726 + self.rotation_axis_angles.heap_size_bytes()
727 + self.quaternions.heap_size_bytes()
728 + self.colors.heap_size_bytes()
729 + self.line_radii.heap_size_bytes()
730 + self.fill_mode.heap_size_bytes()
731 + self.labels.heap_size_bytes()
732 + self.show_labels.heap_size_bytes()
733 + self.class_ids.heap_size_bytes()
734 }
735}