re_types/archetypes/
ellipsoids3d.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/archetypes/ellipsoids3d.fbs".
3
4#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::allow_attributes)]
8#![allow(clippy::clone_on_copy)]
9#![allow(clippy::cloned_instead_of_copied)]
10#![allow(clippy::map_flatten)]
11#![allow(clippy::needless_question_mark)]
12#![allow(clippy::new_without_default)]
13#![allow(clippy::redundant_closure)]
14#![allow(clippy::too_many_arguments)]
15#![allow(clippy::too_many_lines)]
16#![allow(clippy::wildcard_imports)]
17
18use ::re_types_core::SerializationResult;
19use ::re_types_core::try_serialize_field;
20use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
21use ::re_types_core::{ComponentDescriptor, ComponentType};
22use ::re_types_core::{DeserializationError, DeserializationResult};
23
24/// **Archetype**: 3D ellipsoids or spheres.
25///
26/// This archetype is for ellipsoids or spheres whose size is a key part of the data
27/// (e.g. a bounding sphere).
28/// For points whose radii are for the sake of visualization, use [`archetypes::Points3D`][crate::archetypes::Points3D] instead.
29///
30/// If there's more instance poses than half sizes, the last ellipsoid/sphere's orientation will be repeated for the remaining poses.
31/// Orienting and placing ellipsoids/spheres forms a separate transform that is applied prior to [`archetypes::InstancePoses3D`][crate::archetypes::InstancePoses3D] and [`archetypes::Transform3D`][crate::archetypes::Transform3D].
32///
33/// ## Example
34///
35/// ### Covariance ellipsoid
36/// ```ignore
37/// use rand::prelude::*;
38///
39/// fn main() -> Result<(), Box<dyn std::error::Error>> {
40///     let rec = rerun::RecordingStreamBuilder::new("rerun_example_ellipsoid_simple").spawn()?;
41///
42///     let sigmas: [f32; 3] = [5., 3., 1.];
43///
44///     let mut rng = rand::rngs::SmallRng::seed_from_u64(42);
45///     let normal = rand_distr::Normal::new(0.0, 1.0)?;
46///
47///     rec.log(
48///         "points",
49///         &rerun::Points3D::new((0..50_000).map(|_| {
50///             (
51///                 sigmas[0] * normal.sample(&mut rng),
52///                 sigmas[1] * normal.sample(&mut rng),
53///                 sigmas[2] * normal.sample(&mut rng),
54///             )
55///         }))
56///         .with_radii([0.02])
57///         .with_colors([rerun::Color::from_rgb(188, 77, 185)]),
58///     )?;
59///
60///     rec.log(
61///         "ellipsoid",
62///         &rerun::Ellipsoids3D::from_centers_and_half_sizes(
63///             [(0.0, 0.0, 0.0), (0.0, 0.0, 0.0)],
64///             [sigmas, [sigmas[0] * 3., sigmas[1] * 3., sigmas[2] * 3.]],
65///         )
66///         .with_colors([
67///             rerun::Color::from_rgb(255, 255, 0),
68///             rerun::Color::from_rgb(64, 64, 0),
69///         ]),
70///     )?;
71///
72///     Ok(())
73/// }
74/// ```
75/// <center>
76/// <picture>
77///   <source media="(max-width: 480px)" srcset="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/480w.png">
78///   <source media="(max-width: 768px)" srcset="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/768w.png">
79///   <source media="(max-width: 1024px)" srcset="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/1024w.png">
80///   <source media="(max-width: 1200px)" srcset="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/1200w.png">
81///   <img src="https://static.rerun.io/elliopsoid3d_simple/bd5d46e61b80ae44792b52ee07d750a7137002ea/full.png" width="640">
82/// </picture>
83/// </center>
84#[derive(Clone, Debug, PartialEq, Default)]
85pub struct Ellipsoids3D {
86    /// For each ellipsoid, half of its size on its three axes.
87    ///
88    /// If all components are equal, then it is a sphere with that radius.
89    pub half_sizes: Option<SerializedComponentBatch>,
90
91    /// Optional center positions of the ellipsoids.
92    ///
93    /// If not specified, the centers will be at (0, 0, 0).
94    pub centers: Option<SerializedComponentBatch>,
95
96    /// Rotations via axis + angle.
97    ///
98    /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
99    pub rotation_axis_angles: Option<SerializedComponentBatch>,
100
101    /// Rotations via quaternion.
102    ///
103    /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
104    pub quaternions: Option<SerializedComponentBatch>,
105
106    /// Optional colors for the ellipsoids.
107    ///
108    /// Alpha channel is used for transparency for solid fill-mode.
109    pub colors: Option<SerializedComponentBatch>,
110
111    /// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
112    pub line_radii: Option<SerializedComponentBatch>,
113
114    /// Optionally choose whether the ellipsoids are drawn with lines or solid.
115    pub fill_mode: Option<SerializedComponentBatch>,
116
117    /// Optional text labels for the ellipsoids.
118    pub labels: Option<SerializedComponentBatch>,
119
120    /// Whether the text labels should be shown.
121    ///
122    /// If not set, labels will automatically appear when there is exactly one label for this entity
123    /// or the number of instances on this entity is under a certain threshold.
124    pub show_labels: Option<SerializedComponentBatch>,
125
126    /// Optional class ID for the ellipsoids.
127    ///
128    /// The class ID provides colors and labels if not specified explicitly.
129    pub class_ids: Option<SerializedComponentBatch>,
130}
131
132impl Ellipsoids3D {
133    /// Returns the [`ComponentDescriptor`] for [`Self::half_sizes`].
134    ///
135    /// The corresponding component is [`crate::components::HalfSize3D`].
136    #[inline]
137    pub fn descriptor_half_sizes() -> ComponentDescriptor {
138        ComponentDescriptor {
139            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
140            component: "Ellipsoids3D:half_sizes".into(),
141            component_type: Some("rerun.components.HalfSize3D".into()),
142        }
143    }
144
145    /// Returns the [`ComponentDescriptor`] for [`Self::centers`].
146    ///
147    /// The corresponding component is [`crate::components::PoseTranslation3D`].
148    #[inline]
149    pub fn descriptor_centers() -> ComponentDescriptor {
150        ComponentDescriptor {
151            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
152            component: "Ellipsoids3D:centers".into(),
153            component_type: Some("rerun.components.PoseTranslation3D".into()),
154        }
155    }
156
157    /// Returns the [`ComponentDescriptor`] for [`Self::rotation_axis_angles`].
158    ///
159    /// The corresponding component is [`crate::components::PoseRotationAxisAngle`].
160    #[inline]
161    pub fn descriptor_rotation_axis_angles() -> ComponentDescriptor {
162        ComponentDescriptor {
163            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
164            component: "Ellipsoids3D:rotation_axis_angles".into(),
165            component_type: Some("rerun.components.PoseRotationAxisAngle".into()),
166        }
167    }
168
169    /// Returns the [`ComponentDescriptor`] for [`Self::quaternions`].
170    ///
171    /// The corresponding component is [`crate::components::PoseRotationQuat`].
172    #[inline]
173    pub fn descriptor_quaternions() -> ComponentDescriptor {
174        ComponentDescriptor {
175            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
176            component: "Ellipsoids3D:quaternions".into(),
177            component_type: Some("rerun.components.PoseRotationQuat".into()),
178        }
179    }
180
181    /// Returns the [`ComponentDescriptor`] for [`Self::colors`].
182    ///
183    /// The corresponding component is [`crate::components::Color`].
184    #[inline]
185    pub fn descriptor_colors() -> ComponentDescriptor {
186        ComponentDescriptor {
187            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
188            component: "Ellipsoids3D:colors".into(),
189            component_type: Some("rerun.components.Color".into()),
190        }
191    }
192
193    /// Returns the [`ComponentDescriptor`] for [`Self::line_radii`].
194    ///
195    /// The corresponding component is [`crate::components::Radius`].
196    #[inline]
197    pub fn descriptor_line_radii() -> ComponentDescriptor {
198        ComponentDescriptor {
199            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
200            component: "Ellipsoids3D:line_radii".into(),
201            component_type: Some("rerun.components.Radius".into()),
202        }
203    }
204
205    /// Returns the [`ComponentDescriptor`] for [`Self::fill_mode`].
206    ///
207    /// The corresponding component is [`crate::components::FillMode`].
208    #[inline]
209    pub fn descriptor_fill_mode() -> ComponentDescriptor {
210        ComponentDescriptor {
211            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
212            component: "Ellipsoids3D:fill_mode".into(),
213            component_type: Some("rerun.components.FillMode".into()),
214        }
215    }
216
217    /// Returns the [`ComponentDescriptor`] for [`Self::labels`].
218    ///
219    /// The corresponding component is [`crate::components::Text`].
220    #[inline]
221    pub fn descriptor_labels() -> ComponentDescriptor {
222        ComponentDescriptor {
223            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
224            component: "Ellipsoids3D:labels".into(),
225            component_type: Some("rerun.components.Text".into()),
226        }
227    }
228
229    /// Returns the [`ComponentDescriptor`] for [`Self::show_labels`].
230    ///
231    /// The corresponding component is [`crate::components::ShowLabels`].
232    #[inline]
233    pub fn descriptor_show_labels() -> ComponentDescriptor {
234        ComponentDescriptor {
235            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
236            component: "Ellipsoids3D:show_labels".into(),
237            component_type: Some("rerun.components.ShowLabels".into()),
238        }
239    }
240
241    /// Returns the [`ComponentDescriptor`] for [`Self::class_ids`].
242    ///
243    /// The corresponding component is [`crate::components::ClassId`].
244    #[inline]
245    pub fn descriptor_class_ids() -> ComponentDescriptor {
246        ComponentDescriptor {
247            archetype: Some("rerun.archetypes.Ellipsoids3D".into()),
248            component: "Ellipsoids3D:class_ids".into(),
249            component_type: Some("rerun.components.ClassId".into()),
250        }
251    }
252}
253
254static REQUIRED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
255    std::sync::LazyLock::new(|| [Ellipsoids3D::descriptor_half_sizes()]);
256
257static RECOMMENDED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 2usize]> =
258    std::sync::LazyLock::new(|| {
259        [
260            Ellipsoids3D::descriptor_centers(),
261            Ellipsoids3D::descriptor_colors(),
262        ]
263    });
264
265static OPTIONAL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 7usize]> =
266    std::sync::LazyLock::new(|| {
267        [
268            Ellipsoids3D::descriptor_rotation_axis_angles(),
269            Ellipsoids3D::descriptor_quaternions(),
270            Ellipsoids3D::descriptor_line_radii(),
271            Ellipsoids3D::descriptor_fill_mode(),
272            Ellipsoids3D::descriptor_labels(),
273            Ellipsoids3D::descriptor_show_labels(),
274            Ellipsoids3D::descriptor_class_ids(),
275        ]
276    });
277
278static ALL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 10usize]> =
279    std::sync::LazyLock::new(|| {
280        [
281            Ellipsoids3D::descriptor_half_sizes(),
282            Ellipsoids3D::descriptor_centers(),
283            Ellipsoids3D::descriptor_colors(),
284            Ellipsoids3D::descriptor_rotation_axis_angles(),
285            Ellipsoids3D::descriptor_quaternions(),
286            Ellipsoids3D::descriptor_line_radii(),
287            Ellipsoids3D::descriptor_fill_mode(),
288            Ellipsoids3D::descriptor_labels(),
289            Ellipsoids3D::descriptor_show_labels(),
290            Ellipsoids3D::descriptor_class_ids(),
291        ]
292    });
293
294impl Ellipsoids3D {
295    /// The total number of components in the archetype: 1 required, 2 recommended, 7 optional
296    pub const NUM_COMPONENTS: usize = 10usize;
297}
298
299impl ::re_types_core::Archetype for Ellipsoids3D {
300    #[inline]
301    fn name() -> ::re_types_core::ArchetypeName {
302        "rerun.archetypes.Ellipsoids3D".into()
303    }
304
305    #[inline]
306    fn display_name() -> &'static str {
307        "Ellipsoids 3D"
308    }
309
310    #[inline]
311    fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
312        REQUIRED_COMPONENTS.as_slice().into()
313    }
314
315    #[inline]
316    fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
317        RECOMMENDED_COMPONENTS.as_slice().into()
318    }
319
320    #[inline]
321    fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
322        OPTIONAL_COMPONENTS.as_slice().into()
323    }
324
325    #[inline]
326    fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
327        ALL_COMPONENTS.as_slice().into()
328    }
329
330    #[inline]
331    fn from_arrow_components(
332        arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
333    ) -> DeserializationResult<Self> {
334        re_tracing::profile_function!();
335        use ::re_types_core::{Loggable as _, ResultExt as _};
336        let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
337        let half_sizes = arrays_by_descr
338            .get(&Self::descriptor_half_sizes())
339            .map(|array| {
340                SerializedComponentBatch::new(array.clone(), Self::descriptor_half_sizes())
341            });
342        let centers = arrays_by_descr
343            .get(&Self::descriptor_centers())
344            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_centers()));
345        let rotation_axis_angles = arrays_by_descr
346            .get(&Self::descriptor_rotation_axis_angles())
347            .map(|array| {
348                SerializedComponentBatch::new(
349                    array.clone(),
350                    Self::descriptor_rotation_axis_angles(),
351                )
352            });
353        let quaternions = arrays_by_descr
354            .get(&Self::descriptor_quaternions())
355            .map(|array| {
356                SerializedComponentBatch::new(array.clone(), Self::descriptor_quaternions())
357            });
358        let colors = arrays_by_descr
359            .get(&Self::descriptor_colors())
360            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
361        let line_radii = arrays_by_descr
362            .get(&Self::descriptor_line_radii())
363            .map(|array| {
364                SerializedComponentBatch::new(array.clone(), Self::descriptor_line_radii())
365            });
366        let fill_mode = arrays_by_descr
367            .get(&Self::descriptor_fill_mode())
368            .map(|array| {
369                SerializedComponentBatch::new(array.clone(), Self::descriptor_fill_mode())
370            });
371        let labels = arrays_by_descr
372            .get(&Self::descriptor_labels())
373            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_labels()));
374        let show_labels = arrays_by_descr
375            .get(&Self::descriptor_show_labels())
376            .map(|array| {
377                SerializedComponentBatch::new(array.clone(), Self::descriptor_show_labels())
378            });
379        let class_ids = arrays_by_descr
380            .get(&Self::descriptor_class_ids())
381            .map(|array| {
382                SerializedComponentBatch::new(array.clone(), Self::descriptor_class_ids())
383            });
384        Ok(Self {
385            half_sizes,
386            centers,
387            rotation_axis_angles,
388            quaternions,
389            colors,
390            line_radii,
391            fill_mode,
392            labels,
393            show_labels,
394            class_ids,
395        })
396    }
397}
398
399impl ::re_types_core::AsComponents for Ellipsoids3D {
400    #[inline]
401    fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
402        use ::re_types_core::Archetype as _;
403        [
404            self.half_sizes.clone(),
405            self.centers.clone(),
406            self.rotation_axis_angles.clone(),
407            self.quaternions.clone(),
408            self.colors.clone(),
409            self.line_radii.clone(),
410            self.fill_mode.clone(),
411            self.labels.clone(),
412            self.show_labels.clone(),
413            self.class_ids.clone(),
414        ]
415        .into_iter()
416        .flatten()
417        .collect()
418    }
419}
420
421impl ::re_types_core::ArchetypeReflectionMarker for Ellipsoids3D {}
422
423impl Ellipsoids3D {
424    /// Create a new `Ellipsoids3D`.
425    #[inline]
426    pub(crate) fn new(
427        half_sizes: impl IntoIterator<Item = impl Into<crate::components::HalfSize3D>>,
428    ) -> Self {
429        Self {
430            half_sizes: try_serialize_field(Self::descriptor_half_sizes(), half_sizes),
431            centers: None,
432            rotation_axis_angles: None,
433            quaternions: None,
434            colors: None,
435            line_radii: None,
436            fill_mode: None,
437            labels: None,
438            show_labels: None,
439            class_ids: None,
440        }
441    }
442
443    /// Update only some specific fields of a `Ellipsoids3D`.
444    #[inline]
445    pub fn update_fields() -> Self {
446        Self::default()
447    }
448
449    /// Clear all the fields of a `Ellipsoids3D`.
450    #[inline]
451    pub fn clear_fields() -> Self {
452        use ::re_types_core::Loggable as _;
453        Self {
454            half_sizes: Some(SerializedComponentBatch::new(
455                crate::components::HalfSize3D::arrow_empty(),
456                Self::descriptor_half_sizes(),
457            )),
458            centers: Some(SerializedComponentBatch::new(
459                crate::components::PoseTranslation3D::arrow_empty(),
460                Self::descriptor_centers(),
461            )),
462            rotation_axis_angles: Some(SerializedComponentBatch::new(
463                crate::components::PoseRotationAxisAngle::arrow_empty(),
464                Self::descriptor_rotation_axis_angles(),
465            )),
466            quaternions: Some(SerializedComponentBatch::new(
467                crate::components::PoseRotationQuat::arrow_empty(),
468                Self::descriptor_quaternions(),
469            )),
470            colors: Some(SerializedComponentBatch::new(
471                crate::components::Color::arrow_empty(),
472                Self::descriptor_colors(),
473            )),
474            line_radii: Some(SerializedComponentBatch::new(
475                crate::components::Radius::arrow_empty(),
476                Self::descriptor_line_radii(),
477            )),
478            fill_mode: Some(SerializedComponentBatch::new(
479                crate::components::FillMode::arrow_empty(),
480                Self::descriptor_fill_mode(),
481            )),
482            labels: Some(SerializedComponentBatch::new(
483                crate::components::Text::arrow_empty(),
484                Self::descriptor_labels(),
485            )),
486            show_labels: Some(SerializedComponentBatch::new(
487                crate::components::ShowLabels::arrow_empty(),
488                Self::descriptor_show_labels(),
489            )),
490            class_ids: Some(SerializedComponentBatch::new(
491                crate::components::ClassId::arrow_empty(),
492                Self::descriptor_class_ids(),
493            )),
494        }
495    }
496
497    /// Partitions the component data into multiple sub-batches.
498    ///
499    /// Specifically, this transforms the existing [`SerializedComponentBatch`]es data into [`SerializedComponentColumn`]s
500    /// instead, via [`SerializedComponentBatch::partitioned`].
501    ///
502    /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
503    ///
504    /// The specified `lengths` must sum to the total length of the component batch.
505    ///
506    /// [`SerializedComponentColumn`]: [::re_types_core::SerializedComponentColumn]
507    #[inline]
508    pub fn columns<I>(
509        self,
510        _lengths: I,
511    ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
512    where
513        I: IntoIterator<Item = usize> + Clone,
514    {
515        let columns = [
516            self.half_sizes
517                .map(|half_sizes| half_sizes.partitioned(_lengths.clone()))
518                .transpose()?,
519            self.centers
520                .map(|centers| centers.partitioned(_lengths.clone()))
521                .transpose()?,
522            self.rotation_axis_angles
523                .map(|rotation_axis_angles| rotation_axis_angles.partitioned(_lengths.clone()))
524                .transpose()?,
525            self.quaternions
526                .map(|quaternions| quaternions.partitioned(_lengths.clone()))
527                .transpose()?,
528            self.colors
529                .map(|colors| colors.partitioned(_lengths.clone()))
530                .transpose()?,
531            self.line_radii
532                .map(|line_radii| line_radii.partitioned(_lengths.clone()))
533                .transpose()?,
534            self.fill_mode
535                .map(|fill_mode| fill_mode.partitioned(_lengths.clone()))
536                .transpose()?,
537            self.labels
538                .map(|labels| labels.partitioned(_lengths.clone()))
539                .transpose()?,
540            self.show_labels
541                .map(|show_labels| show_labels.partitioned(_lengths.clone()))
542                .transpose()?,
543            self.class_ids
544                .map(|class_ids| class_ids.partitioned(_lengths.clone()))
545                .transpose()?,
546        ];
547        Ok(columns.into_iter().flatten())
548    }
549
550    /// Helper to partition the component data into unit-length sub-batches.
551    ///
552    /// This is semantically similar to calling [`Self::columns`] with `std::iter::take(1).repeat(n)`,
553    /// where `n` is automatically guessed.
554    #[inline]
555    pub fn columns_of_unit_batches(
556        self,
557    ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
558        let len_half_sizes = self.half_sizes.as_ref().map(|b| b.array.len());
559        let len_centers = self.centers.as_ref().map(|b| b.array.len());
560        let len_rotation_axis_angles = self.rotation_axis_angles.as_ref().map(|b| b.array.len());
561        let len_quaternions = self.quaternions.as_ref().map(|b| b.array.len());
562        let len_colors = self.colors.as_ref().map(|b| b.array.len());
563        let len_line_radii = self.line_radii.as_ref().map(|b| b.array.len());
564        let len_fill_mode = self.fill_mode.as_ref().map(|b| b.array.len());
565        let len_labels = self.labels.as_ref().map(|b| b.array.len());
566        let len_show_labels = self.show_labels.as_ref().map(|b| b.array.len());
567        let len_class_ids = self.class_ids.as_ref().map(|b| b.array.len());
568        let len = None
569            .or(len_half_sizes)
570            .or(len_centers)
571            .or(len_rotation_axis_angles)
572            .or(len_quaternions)
573            .or(len_colors)
574            .or(len_line_radii)
575            .or(len_fill_mode)
576            .or(len_labels)
577            .or(len_show_labels)
578            .or(len_class_ids)
579            .unwrap_or(0);
580        self.columns(std::iter::repeat_n(1, len))
581    }
582
583    /// For each ellipsoid, half of its size on its three axes.
584    ///
585    /// If all components are equal, then it is a sphere with that radius.
586    #[inline]
587    pub fn with_half_sizes(
588        mut self,
589        half_sizes: impl IntoIterator<Item = impl Into<crate::components::HalfSize3D>>,
590    ) -> Self {
591        self.half_sizes = try_serialize_field(Self::descriptor_half_sizes(), half_sizes);
592        self
593    }
594
595    /// Optional center positions of the ellipsoids.
596    ///
597    /// If not specified, the centers will be at (0, 0, 0).
598    #[inline]
599    pub fn with_centers(
600        mut self,
601        centers: impl IntoIterator<Item = impl Into<crate::components::PoseTranslation3D>>,
602    ) -> Self {
603        self.centers = try_serialize_field(Self::descriptor_centers(), centers);
604        self
605    }
606
607    /// Rotations via axis + angle.
608    ///
609    /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
610    #[inline]
611    pub fn with_rotation_axis_angles(
612        mut self,
613        rotation_axis_angles: impl IntoIterator<
614            Item = impl Into<crate::components::PoseRotationAxisAngle>,
615        >,
616    ) -> Self {
617        self.rotation_axis_angles = try_serialize_field(
618            Self::descriptor_rotation_axis_angles(),
619            rotation_axis_angles,
620        );
621        self
622    }
623
624    /// Rotations via quaternion.
625    ///
626    /// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
627    #[inline]
628    pub fn with_quaternions(
629        mut self,
630        quaternions: impl IntoIterator<Item = impl Into<crate::components::PoseRotationQuat>>,
631    ) -> Self {
632        self.quaternions = try_serialize_field(Self::descriptor_quaternions(), quaternions);
633        self
634    }
635
636    /// Optional colors for the ellipsoids.
637    ///
638    /// Alpha channel is used for transparency for solid fill-mode.
639    #[inline]
640    pub fn with_colors(
641        mut self,
642        colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
643    ) -> Self {
644        self.colors = try_serialize_field(Self::descriptor_colors(), colors);
645        self
646    }
647
648    /// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
649    #[inline]
650    pub fn with_line_radii(
651        mut self,
652        line_radii: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
653    ) -> Self {
654        self.line_radii = try_serialize_field(Self::descriptor_line_radii(), line_radii);
655        self
656    }
657
658    /// Optionally choose whether the ellipsoids are drawn with lines or solid.
659    #[inline]
660    pub fn with_fill_mode(mut self, fill_mode: impl Into<crate::components::FillMode>) -> Self {
661        self.fill_mode = try_serialize_field(Self::descriptor_fill_mode(), [fill_mode]);
662        self
663    }
664
665    /// This method makes it possible to pack multiple [`crate::components::FillMode`] in a single component batch.
666    ///
667    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_fill_mode`] should
668    /// be used when logging a single row's worth of data.
669    #[inline]
670    pub fn with_many_fill_mode(
671        mut self,
672        fill_mode: impl IntoIterator<Item = impl Into<crate::components::FillMode>>,
673    ) -> Self {
674        self.fill_mode = try_serialize_field(Self::descriptor_fill_mode(), fill_mode);
675        self
676    }
677
678    /// Optional text labels for the ellipsoids.
679    #[inline]
680    pub fn with_labels(
681        mut self,
682        labels: impl IntoIterator<Item = impl Into<crate::components::Text>>,
683    ) -> Self {
684        self.labels = try_serialize_field(Self::descriptor_labels(), labels);
685        self
686    }
687
688    /// Whether the text labels should be shown.
689    ///
690    /// If not set, labels will automatically appear when there is exactly one label for this entity
691    /// or the number of instances on this entity is under a certain threshold.
692    #[inline]
693    pub fn with_show_labels(
694        mut self,
695        show_labels: impl Into<crate::components::ShowLabels>,
696    ) -> Self {
697        self.show_labels = try_serialize_field(Self::descriptor_show_labels(), [show_labels]);
698        self
699    }
700
701    /// This method makes it possible to pack multiple [`crate::components::ShowLabels`] in a single component batch.
702    ///
703    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_show_labels`] should
704    /// be used when logging a single row's worth of data.
705    #[inline]
706    pub fn with_many_show_labels(
707        mut self,
708        show_labels: impl IntoIterator<Item = impl Into<crate::components::ShowLabels>>,
709    ) -> Self {
710        self.show_labels = try_serialize_field(Self::descriptor_show_labels(), show_labels);
711        self
712    }
713
714    /// Optional class ID for the ellipsoids.
715    ///
716    /// The class ID provides colors and labels if not specified explicitly.
717    #[inline]
718    pub fn with_class_ids(
719        mut self,
720        class_ids: impl IntoIterator<Item = impl Into<crate::components::ClassId>>,
721    ) -> Self {
722        self.class_ids = try_serialize_field(Self::descriptor_class_ids(), class_ids);
723        self
724    }
725}
726
727impl ::re_byte_size::SizeBytes for Ellipsoids3D {
728    #[inline]
729    fn heap_size_bytes(&self) -> u64 {
730        self.half_sizes.heap_size_bytes()
731            + self.centers.heap_size_bytes()
732            + self.rotation_axis_angles.heap_size_bytes()
733            + self.quaternions.heap_size_bytes()
734            + self.colors.heap_size_bytes()
735            + self.line_radii.heap_size_bytes()
736            + self.fill_mode.heap_size_bytes()
737            + self.labels.heap_size_bytes()
738            + self.show_labels.heap_size_bytes()
739            + self.class_ids.heap_size_bytes()
740    }
741}