1#![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#[derive(Clone, Debug, PartialEq, Default)]
68pub struct DepthImage {
69 pub buffer: Option<SerializedComponentBatch>,
71
72 pub format: Option<SerializedComponentBatch>,
74
75 pub meter: Option<SerializedComponentBatch>,
83
84 pub colormap: Option<SerializedComponentBatch>,
88
89 pub depth_range: Option<SerializedComponentBatch>,
101
102 pub point_fill_ratio: Option<SerializedComponentBatch>,
110
111 pub draw_order: Option<SerializedComponentBatch>,
116}
117
118impl DepthImage {
119 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 pub const NUM_COMPONENTS: usize = 8usize;
239}
240
241pub 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 #[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 #[inline]
371 pub fn update_fields() -> Self {
372 Self::default()
373 }
374
375 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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}