re_types/archetypes/
depth_image.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/depth_image.fbs".
3
4#![allow(unused_imports)]
5#![allow(unused_parens)]
6#![allow(clippy::clone_on_copy)]
7#![allow(clippy::cloned_instead_of_copied)]
8#![allow(clippy::map_flatten)]
9#![allow(clippy::needless_question_mark)]
10#![allow(clippy::new_without_default)]
11#![allow(clippy::redundant_closure)]
12#![allow(clippy::too_many_arguments)]
13#![allow(clippy::too_many_lines)]
14
15use ::re_types_core::try_serialize_field;
16use ::re_types_core::SerializationResult;
17use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
18use ::re_types_core::{ComponentDescriptor, ComponentName};
19use ::re_types_core::{DeserializationError, DeserializationResult};
20
21/// **Archetype**: A depth image, i.e. as captured by a depth camera.
22///
23/// Each pixel corresponds to a depth value in units specified by [`components::DepthMeter`][crate::components::DepthMeter].
24///
25/// ## Example
26///
27/// ### Depth to 3D example
28/// ```ignore
29/// use ndarray::{s, Array, ShapeBuilder as _};
30///
31/// fn main() -> Result<(), Box<dyn std::error::Error>> {
32///     let rec = rerun::RecordingStreamBuilder::new("rerun_example_depth_image_3d").spawn()?;
33///
34///     let width = 300;
35///     let height = 200;
36///     let mut image = Array::<u16, _>::from_elem((height, width).f(), 65535);
37///     image.slice_mut(s![50..150, 50..150]).fill(20000);
38///     image.slice_mut(s![130..180, 100..280]).fill(45000);
39///
40///     let depth_image = rerun::DepthImage::try_from(image)?
41///         .with_meter(10000.0)
42///         .with_colormap(rerun::components::Colormap::Viridis);
43///
44///     // If we log a pinhole camera model, the depth gets automatically back-projected to 3D
45///     rec.log(
46///         "world/camera",
47///         &rerun::Pinhole::from_focal_length_and_resolution(
48///             [200.0, 200.0],
49///             [width as f32, height as f32],
50///         ),
51///     )?;
52///
53///     rec.log("world/camera/depth", &depth_image)?;
54///
55///     Ok(())
56/// }
57/// ```
58/// <center>
59/// <picture>
60///   <source media="(max-width: 480px)" srcset="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/480w.png">
61///   <source media="(max-width: 768px)" srcset="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/768w.png">
62///   <source media="(max-width: 1024px)" srcset="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/1024w.png">
63///   <source media="(max-width: 1200px)" srcset="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/1200w.png">
64///   <img src="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/full.png" width="640">
65/// </picture>
66/// </center>
67#[derive(Clone, Debug, PartialEq, Default)]
68pub struct DepthImage {
69    /// The raw depth image data.
70    pub buffer: Option<SerializedComponentBatch>,
71
72    /// The format of the image.
73    pub format: Option<SerializedComponentBatch>,
74
75    /// An optional floating point value that specifies how long a meter is in the native depth units.
76    ///
77    /// For instance: with uint16, perhaps meter=1000 which would mean you have millimeter precision
78    /// and a range of up to ~65 meters (2^16 / 1000).
79    ///
80    /// Note that the only effect on 2D views is the physical depth values shown when hovering the image.
81    /// In 3D views on the other hand, this affects where the points of the point cloud are placed.
82    pub meter: Option<SerializedComponentBatch>,
83
84    /// Colormap to use for rendering the depth image.
85    ///
86    /// If not set, the depth image will be rendered using the Turbo colormap.
87    pub colormap: Option<SerializedComponentBatch>,
88
89    /// The expected range of depth values.
90    ///
91    /// This is typically the expected range of valid values.
92    /// Everything outside of the range is clamped to the range for the purpose of colormpaping.
93    /// Note that point clouds generated from this image will still display all points, regardless of this range.
94    ///
95    /// If not specified, the range will be automatically estimated from the data.
96    /// Note that the Viewer may try to guess a wider range than the minimum/maximum of values
97    /// in the contents of the depth image.
98    /// E.g. if all values are positive, some bigger than 1.0 and all smaller than 255.0,
99    /// the Viewer will guess that the data likely came from an 8bit image, thus assuming a range of 0-255.
100    pub depth_range: Option<SerializedComponentBatch>,
101
102    /// Scale the radii of the points in the point cloud generated from this image.
103    ///
104    /// A fill ratio of 1.0 (the default) means that each point is as big as to touch the center of its neighbor
105    /// if it is at the same depth, leaving no gaps.
106    /// A fill ratio of 0.5 means that each point touches the edge of its neighbor if it has the same depth.
107    ///
108    /// TODO(#6744): This applies only to 3D views!
109    pub point_fill_ratio: Option<SerializedComponentBatch>,
110
111    /// An optional floating point value that specifies the 2D drawing order, used only if the depth image is shown as a 2D image.
112    ///
113    /// Objects with higher values are drawn on top of those with lower values.
114    /// Defaults to `-20.0`.
115    pub draw_order: Option<SerializedComponentBatch>,
116}
117
118impl DepthImage {
119    /// Returns the [`ComponentDescriptor`] for [`Self::buffer`].
120    #[inline]
121    pub fn descriptor_buffer() -> ComponentDescriptor {
122        ComponentDescriptor {
123            archetype_name: Some("rerun.archetypes.DepthImage".into()),
124            component_name: "rerun.components.ImageBuffer".into(),
125            archetype_field_name: Some("buffer".into()),
126        }
127    }
128
129    /// Returns the [`ComponentDescriptor`] for [`Self::format`].
130    #[inline]
131    pub fn descriptor_format() -> ComponentDescriptor {
132        ComponentDescriptor {
133            archetype_name: Some("rerun.archetypes.DepthImage".into()),
134            component_name: "rerun.components.ImageFormat".into(),
135            archetype_field_name: Some("format".into()),
136        }
137    }
138
139    /// Returns the [`ComponentDescriptor`] for [`Self::meter`].
140    #[inline]
141    pub fn descriptor_meter() -> ComponentDescriptor {
142        ComponentDescriptor {
143            archetype_name: Some("rerun.archetypes.DepthImage".into()),
144            component_name: "rerun.components.DepthMeter".into(),
145            archetype_field_name: Some("meter".into()),
146        }
147    }
148
149    /// Returns the [`ComponentDescriptor`] for [`Self::colormap`].
150    #[inline]
151    pub fn descriptor_colormap() -> ComponentDescriptor {
152        ComponentDescriptor {
153            archetype_name: Some("rerun.archetypes.DepthImage".into()),
154            component_name: "rerun.components.Colormap".into(),
155            archetype_field_name: Some("colormap".into()),
156        }
157    }
158
159    /// Returns the [`ComponentDescriptor`] for [`Self::depth_range`].
160    #[inline]
161    pub fn descriptor_depth_range() -> ComponentDescriptor {
162        ComponentDescriptor {
163            archetype_name: Some("rerun.archetypes.DepthImage".into()),
164            component_name: "rerun.components.ValueRange".into(),
165            archetype_field_name: Some("depth_range".into()),
166        }
167    }
168
169    /// Returns the [`ComponentDescriptor`] for [`Self::point_fill_ratio`].
170    #[inline]
171    pub fn descriptor_point_fill_ratio() -> ComponentDescriptor {
172        ComponentDescriptor {
173            archetype_name: Some("rerun.archetypes.DepthImage".into()),
174            component_name: "rerun.components.FillRatio".into(),
175            archetype_field_name: Some("point_fill_ratio".into()),
176        }
177    }
178
179    /// Returns the [`ComponentDescriptor`] for [`Self::draw_order`].
180    #[inline]
181    pub fn descriptor_draw_order() -> ComponentDescriptor {
182        ComponentDescriptor {
183            archetype_name: Some("rerun.archetypes.DepthImage".into()),
184            component_name: "rerun.components.DrawOrder".into(),
185            archetype_field_name: Some("draw_order".into()),
186        }
187    }
188
189    /// Returns the [`ComponentDescriptor`] for the associated indicator component.
190    #[inline]
191    pub fn descriptor_indicator() -> ComponentDescriptor {
192        ComponentDescriptor {
193            archetype_name: Some("rerun.archetypes.DepthImage".into()),
194            component_name: "rerun.components.DepthImageIndicator".into(),
195            archetype_field_name: None,
196        }
197    }
198}
199
200static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
201    once_cell::sync::Lazy::new(|| {
202        [
203            DepthImage::descriptor_buffer(),
204            DepthImage::descriptor_format(),
205        ]
206    });
207
208static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
209    once_cell::sync::Lazy::new(|| [DepthImage::descriptor_indicator()]);
210
211static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 5usize]> =
212    once_cell::sync::Lazy::new(|| {
213        [
214            DepthImage::descriptor_meter(),
215            DepthImage::descriptor_colormap(),
216            DepthImage::descriptor_depth_range(),
217            DepthImage::descriptor_point_fill_ratio(),
218            DepthImage::descriptor_draw_order(),
219        ]
220    });
221
222static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 8usize]> =
223    once_cell::sync::Lazy::new(|| {
224        [
225            DepthImage::descriptor_buffer(),
226            DepthImage::descriptor_format(),
227            DepthImage::descriptor_indicator(),
228            DepthImage::descriptor_meter(),
229            DepthImage::descriptor_colormap(),
230            DepthImage::descriptor_depth_range(),
231            DepthImage::descriptor_point_fill_ratio(),
232            DepthImage::descriptor_draw_order(),
233        ]
234    });
235
236impl DepthImage {
237    /// The total number of components in the archetype: 2 required, 1 recommended, 5 optional
238    pub const NUM_COMPONENTS: usize = 8usize;
239}
240
241/// Indicator component for the [`DepthImage`] [`::re_types_core::Archetype`]
242pub type DepthImageIndicator = ::re_types_core::GenericIndicatorComponent<DepthImage>;
243
244impl ::re_types_core::Archetype for DepthImage {
245    type Indicator = DepthImageIndicator;
246
247    #[inline]
248    fn name() -> ::re_types_core::ArchetypeName {
249        "rerun.archetypes.DepthImage".into()
250    }
251
252    #[inline]
253    fn display_name() -> &'static str {
254        "Depth image"
255    }
256
257    #[inline]
258    fn indicator() -> SerializedComponentBatch {
259        #[allow(clippy::unwrap_used)]
260        DepthImageIndicator::DEFAULT.serialized().unwrap()
261    }
262
263    #[inline]
264    fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
265        REQUIRED_COMPONENTS.as_slice().into()
266    }
267
268    #[inline]
269    fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
270        RECOMMENDED_COMPONENTS.as_slice().into()
271    }
272
273    #[inline]
274    fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
275        OPTIONAL_COMPONENTS.as_slice().into()
276    }
277
278    #[inline]
279    fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
280        ALL_COMPONENTS.as_slice().into()
281    }
282
283    #[inline]
284    fn from_arrow_components(
285        arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
286    ) -> DeserializationResult<Self> {
287        re_tracing::profile_function!();
288        use ::re_types_core::{Loggable as _, ResultExt as _};
289        let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
290        let buffer = arrays_by_descr
291            .get(&Self::descriptor_buffer())
292            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_buffer()));
293        let format = arrays_by_descr
294            .get(&Self::descriptor_format())
295            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_format()));
296        let meter = arrays_by_descr
297            .get(&Self::descriptor_meter())
298            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_meter()));
299        let colormap = arrays_by_descr
300            .get(&Self::descriptor_colormap())
301            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colormap()));
302        let depth_range = arrays_by_descr
303            .get(&Self::descriptor_depth_range())
304            .map(|array| {
305                SerializedComponentBatch::new(array.clone(), Self::descriptor_depth_range())
306            });
307        let point_fill_ratio = arrays_by_descr
308            .get(&Self::descriptor_point_fill_ratio())
309            .map(|array| {
310                SerializedComponentBatch::new(array.clone(), Self::descriptor_point_fill_ratio())
311            });
312        let draw_order = arrays_by_descr
313            .get(&Self::descriptor_draw_order())
314            .map(|array| {
315                SerializedComponentBatch::new(array.clone(), Self::descriptor_draw_order())
316            });
317        Ok(Self {
318            buffer,
319            format,
320            meter,
321            colormap,
322            depth_range,
323            point_fill_ratio,
324            draw_order,
325        })
326    }
327}
328
329impl ::re_types_core::AsComponents for DepthImage {
330    #[inline]
331    fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
332        use ::re_types_core::Archetype as _;
333        [
334            Some(Self::indicator()),
335            self.buffer.clone(),
336            self.format.clone(),
337            self.meter.clone(),
338            self.colormap.clone(),
339            self.depth_range.clone(),
340            self.point_fill_ratio.clone(),
341            self.draw_order.clone(),
342        ]
343        .into_iter()
344        .flatten()
345        .collect()
346    }
347}
348
349impl ::re_types_core::ArchetypeReflectionMarker for DepthImage {}
350
351impl DepthImage {
352    /// Create a new `DepthImage`.
353    #[inline]
354    pub fn new(
355        buffer: impl Into<crate::components::ImageBuffer>,
356        format: impl Into<crate::components::ImageFormat>,
357    ) -> Self {
358        Self {
359            buffer: try_serialize_field(Self::descriptor_buffer(), [buffer]),
360            format: try_serialize_field(Self::descriptor_format(), [format]),
361            meter: None,
362            colormap: None,
363            depth_range: None,
364            point_fill_ratio: None,
365            draw_order: None,
366        }
367    }
368
369    /// Update only some specific fields of a `DepthImage`.
370    #[inline]
371    pub fn update_fields() -> Self {
372        Self::default()
373    }
374
375    /// Clear all the fields of a `DepthImage`.
376    #[inline]
377    pub fn clear_fields() -> Self {
378        use ::re_types_core::Loggable as _;
379        Self {
380            buffer: Some(SerializedComponentBatch::new(
381                crate::components::ImageBuffer::arrow_empty(),
382                Self::descriptor_buffer(),
383            )),
384            format: Some(SerializedComponentBatch::new(
385                crate::components::ImageFormat::arrow_empty(),
386                Self::descriptor_format(),
387            )),
388            meter: Some(SerializedComponentBatch::new(
389                crate::components::DepthMeter::arrow_empty(),
390                Self::descriptor_meter(),
391            )),
392            colormap: Some(SerializedComponentBatch::new(
393                crate::components::Colormap::arrow_empty(),
394                Self::descriptor_colormap(),
395            )),
396            depth_range: Some(SerializedComponentBatch::new(
397                crate::components::ValueRange::arrow_empty(),
398                Self::descriptor_depth_range(),
399            )),
400            point_fill_ratio: Some(SerializedComponentBatch::new(
401                crate::components::FillRatio::arrow_empty(),
402                Self::descriptor_point_fill_ratio(),
403            )),
404            draw_order: Some(SerializedComponentBatch::new(
405                crate::components::DrawOrder::arrow_empty(),
406                Self::descriptor_draw_order(),
407            )),
408        }
409    }
410
411    /// Partitions the component data into multiple sub-batches.
412    ///
413    /// Specifically, this transforms the existing [`SerializedComponentBatch`]es data into [`SerializedComponentColumn`]s
414    /// instead, via [`SerializedComponentBatch::partitioned`].
415    ///
416    /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
417    ///
418    /// The specified `lengths` must sum to the total length of the component batch.
419    ///
420    /// [`SerializedComponentColumn`]: [::re_types_core::SerializedComponentColumn]
421    #[inline]
422    pub fn columns<I>(
423        self,
424        _lengths: I,
425    ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
426    where
427        I: IntoIterator<Item = usize> + Clone,
428    {
429        let columns = [
430            self.buffer
431                .map(|buffer| buffer.partitioned(_lengths.clone()))
432                .transpose()?,
433            self.format
434                .map(|format| format.partitioned(_lengths.clone()))
435                .transpose()?,
436            self.meter
437                .map(|meter| meter.partitioned(_lengths.clone()))
438                .transpose()?,
439            self.colormap
440                .map(|colormap| colormap.partitioned(_lengths.clone()))
441                .transpose()?,
442            self.depth_range
443                .map(|depth_range| depth_range.partitioned(_lengths.clone()))
444                .transpose()?,
445            self.point_fill_ratio
446                .map(|point_fill_ratio| point_fill_ratio.partitioned(_lengths.clone()))
447                .transpose()?,
448            self.draw_order
449                .map(|draw_order| draw_order.partitioned(_lengths.clone()))
450                .transpose()?,
451        ];
452        Ok(columns
453            .into_iter()
454            .flatten()
455            .chain([::re_types_core::indicator_column::<Self>(
456                _lengths.into_iter().count(),
457            )?]))
458    }
459
460    /// Helper to partition the component data into unit-length sub-batches.
461    ///
462    /// This is semantically similar to calling [`Self::columns`] with `std::iter::take(1).repeat(n)`,
463    /// where `n` is automatically guessed.
464    #[inline]
465    pub fn columns_of_unit_batches(
466        self,
467    ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
468        let len_buffer = self.buffer.as_ref().map(|b| b.array.len());
469        let len_format = self.format.as_ref().map(|b| b.array.len());
470        let len_meter = self.meter.as_ref().map(|b| b.array.len());
471        let len_colormap = self.colormap.as_ref().map(|b| b.array.len());
472        let len_depth_range = self.depth_range.as_ref().map(|b| b.array.len());
473        let len_point_fill_ratio = self.point_fill_ratio.as_ref().map(|b| b.array.len());
474        let len_draw_order = self.draw_order.as_ref().map(|b| b.array.len());
475        let len = None
476            .or(len_buffer)
477            .or(len_format)
478            .or(len_meter)
479            .or(len_colormap)
480            .or(len_depth_range)
481            .or(len_point_fill_ratio)
482            .or(len_draw_order)
483            .unwrap_or(0);
484        self.columns(std::iter::repeat(1).take(len))
485    }
486
487    /// The raw depth image data.
488    #[inline]
489    pub fn with_buffer(mut self, buffer: impl Into<crate::components::ImageBuffer>) -> Self {
490        self.buffer = try_serialize_field(Self::descriptor_buffer(), [buffer]);
491        self
492    }
493
494    /// This method makes it possible to pack multiple [`crate::components::ImageBuffer`] in a single component batch.
495    ///
496    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_buffer`] should
497    /// be used when logging a single row's worth of data.
498    #[inline]
499    pub fn with_many_buffer(
500        mut self,
501        buffer: impl IntoIterator<Item = impl Into<crate::components::ImageBuffer>>,
502    ) -> Self {
503        self.buffer = try_serialize_field(Self::descriptor_buffer(), buffer);
504        self
505    }
506
507    /// The format of the image.
508    #[inline]
509    pub fn with_format(mut self, format: impl Into<crate::components::ImageFormat>) -> Self {
510        self.format = try_serialize_field(Self::descriptor_format(), [format]);
511        self
512    }
513
514    /// This method makes it possible to pack multiple [`crate::components::ImageFormat`] in a single component batch.
515    ///
516    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_format`] should
517    /// be used when logging a single row's worth of data.
518    #[inline]
519    pub fn with_many_format(
520        mut self,
521        format: impl IntoIterator<Item = impl Into<crate::components::ImageFormat>>,
522    ) -> Self {
523        self.format = try_serialize_field(Self::descriptor_format(), format);
524        self
525    }
526
527    /// An optional floating point value that specifies how long a meter is in the native depth units.
528    ///
529    /// For instance: with uint16, perhaps meter=1000 which would mean you have millimeter precision
530    /// and a range of up to ~65 meters (2^16 / 1000).
531    ///
532    /// Note that the only effect on 2D views is the physical depth values shown when hovering the image.
533    /// In 3D views on the other hand, this affects where the points of the point cloud are placed.
534    #[inline]
535    pub fn with_meter(mut self, meter: impl Into<crate::components::DepthMeter>) -> Self {
536        self.meter = try_serialize_field(Self::descriptor_meter(), [meter]);
537        self
538    }
539
540    /// This method makes it possible to pack multiple [`crate::components::DepthMeter`] in a single component batch.
541    ///
542    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_meter`] should
543    /// be used when logging a single row's worth of data.
544    #[inline]
545    pub fn with_many_meter(
546        mut self,
547        meter: impl IntoIterator<Item = impl Into<crate::components::DepthMeter>>,
548    ) -> Self {
549        self.meter = try_serialize_field(Self::descriptor_meter(), meter);
550        self
551    }
552
553    /// Colormap to use for rendering the depth image.
554    ///
555    /// If not set, the depth image will be rendered using the Turbo colormap.
556    #[inline]
557    pub fn with_colormap(mut self, colormap: impl Into<crate::components::Colormap>) -> Self {
558        self.colormap = try_serialize_field(Self::descriptor_colormap(), [colormap]);
559        self
560    }
561
562    /// This method makes it possible to pack multiple [`crate::components::Colormap`] in a single component batch.
563    ///
564    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_colormap`] should
565    /// be used when logging a single row's worth of data.
566    #[inline]
567    pub fn with_many_colormap(
568        mut self,
569        colormap: impl IntoIterator<Item = impl Into<crate::components::Colormap>>,
570    ) -> Self {
571        self.colormap = try_serialize_field(Self::descriptor_colormap(), colormap);
572        self
573    }
574
575    /// The expected range of depth values.
576    ///
577    /// This is typically the expected range of valid values.
578    /// Everything outside of the range is clamped to the range for the purpose of colormpaping.
579    /// Note that point clouds generated from this image will still display all points, regardless of this range.
580    ///
581    /// If not specified, the range will be automatically estimated from the data.
582    /// Note that the Viewer may try to guess a wider range than the minimum/maximum of values
583    /// in the contents of the depth image.
584    /// E.g. if all values are positive, some bigger than 1.0 and all smaller than 255.0,
585    /// the Viewer will guess that the data likely came from an 8bit image, thus assuming a range of 0-255.
586    #[inline]
587    pub fn with_depth_range(
588        mut self,
589        depth_range: impl Into<crate::components::ValueRange>,
590    ) -> Self {
591        self.depth_range = try_serialize_field(Self::descriptor_depth_range(), [depth_range]);
592        self
593    }
594
595    /// This method makes it possible to pack multiple [`crate::components::ValueRange`] in a single component batch.
596    ///
597    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_depth_range`] should
598    /// be used when logging a single row's worth of data.
599    #[inline]
600    pub fn with_many_depth_range(
601        mut self,
602        depth_range: impl IntoIterator<Item = impl Into<crate::components::ValueRange>>,
603    ) -> Self {
604        self.depth_range = try_serialize_field(Self::descriptor_depth_range(), depth_range);
605        self
606    }
607
608    /// Scale the radii of the points in the point cloud generated from this image.
609    ///
610    /// A fill ratio of 1.0 (the default) means that each point is as big as to touch the center of its neighbor
611    /// if it is at the same depth, leaving no gaps.
612    /// A fill ratio of 0.5 means that each point touches the edge of its neighbor if it has the same depth.
613    ///
614    /// TODO(#6744): This applies only to 3D views!
615    #[inline]
616    pub fn with_point_fill_ratio(
617        mut self,
618        point_fill_ratio: impl Into<crate::components::FillRatio>,
619    ) -> Self {
620        self.point_fill_ratio =
621            try_serialize_field(Self::descriptor_point_fill_ratio(), [point_fill_ratio]);
622        self
623    }
624
625    /// This method makes it possible to pack multiple [`crate::components::FillRatio`] in a single component batch.
626    ///
627    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_point_fill_ratio`] should
628    /// be used when logging a single row's worth of data.
629    #[inline]
630    pub fn with_many_point_fill_ratio(
631        mut self,
632        point_fill_ratio: impl IntoIterator<Item = impl Into<crate::components::FillRatio>>,
633    ) -> Self {
634        self.point_fill_ratio =
635            try_serialize_field(Self::descriptor_point_fill_ratio(), point_fill_ratio);
636        self
637    }
638
639    /// An optional floating point value that specifies the 2D drawing order, used only if the depth image is shown as a 2D image.
640    ///
641    /// Objects with higher values are drawn on top of those with lower values.
642    /// Defaults to `-20.0`.
643    #[inline]
644    pub fn with_draw_order(mut self, draw_order: impl Into<crate::components::DrawOrder>) -> Self {
645        self.draw_order = try_serialize_field(Self::descriptor_draw_order(), [draw_order]);
646        self
647    }
648
649    /// This method makes it possible to pack multiple [`crate::components::DrawOrder`] in a single component batch.
650    ///
651    /// This only makes sense when used in conjunction with [`Self::columns`]. [`Self::with_draw_order`] should
652    /// be used when logging a single row's worth of data.
653    #[inline]
654    pub fn with_many_draw_order(
655        mut self,
656        draw_order: impl IntoIterator<Item = impl Into<crate::components::DrawOrder>>,
657    ) -> Self {
658        self.draw_order = try_serialize_field(Self::descriptor_draw_order(), draw_order);
659        self
660    }
661}
662
663impl ::re_byte_size::SizeBytes for DepthImage {
664    #[inline]
665    fn heap_size_bytes(&self) -> u64 {
666        self.buffer.heap_size_bytes()
667            + self.format.heap_size_bytes()
668            + self.meter.heap_size_bytes()
669            + self.colormap.heap_size_bytes()
670            + self.depth_range.heap_size_bytes()
671            + self.point_fill_ratio.heap_size_bytes()
672            + self.draw_order.heap_size_bytes()
673    }
674}