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)]
90pub struct LineStrips2D {
91 pub strips: Option<SerializedComponentBatch>,
93
94 pub radii: Option<SerializedComponentBatch>,
96
97 pub colors: Option<SerializedComponentBatch>,
99
100 pub labels: Option<SerializedComponentBatch>,
105
106 pub show_labels: Option<SerializedComponentBatch>,
111
112 pub draw_order: Option<SerializedComponentBatch>,
117
118 pub class_ids: Option<SerializedComponentBatch>,
122}
123
124impl LineStrips2D {
125 #[inline]
129 pub fn descriptor_strips() -> ComponentDescriptor {
130 ComponentDescriptor {
131 archetype: Some("rerun.archetypes.LineStrips2D".into()),
132 component: "LineStrips2D:strips".into(),
133 component_type: Some("rerun.components.LineStrip2D".into()),
134 }
135 }
136
137 #[inline]
141 pub fn descriptor_radii() -> ComponentDescriptor {
142 ComponentDescriptor {
143 archetype: Some("rerun.archetypes.LineStrips2D".into()),
144 component: "LineStrips2D:radii".into(),
145 component_type: Some("rerun.components.Radius".into()),
146 }
147 }
148
149 #[inline]
153 pub fn descriptor_colors() -> ComponentDescriptor {
154 ComponentDescriptor {
155 archetype: Some("rerun.archetypes.LineStrips2D".into()),
156 component: "LineStrips2D:colors".into(),
157 component_type: Some("rerun.components.Color".into()),
158 }
159 }
160
161 #[inline]
165 pub fn descriptor_labels() -> ComponentDescriptor {
166 ComponentDescriptor {
167 archetype: Some("rerun.archetypes.LineStrips2D".into()),
168 component: "LineStrips2D:labels".into(),
169 component_type: Some("rerun.components.Text".into()),
170 }
171 }
172
173 #[inline]
177 pub fn descriptor_show_labels() -> ComponentDescriptor {
178 ComponentDescriptor {
179 archetype: Some("rerun.archetypes.LineStrips2D".into()),
180 component: "LineStrips2D:show_labels".into(),
181 component_type: Some("rerun.components.ShowLabels".into()),
182 }
183 }
184
185 #[inline]
189 pub fn descriptor_draw_order() -> ComponentDescriptor {
190 ComponentDescriptor {
191 archetype: Some("rerun.archetypes.LineStrips2D".into()),
192 component: "LineStrips2D:draw_order".into(),
193 component_type: Some("rerun.components.DrawOrder".into()),
194 }
195 }
196
197 #[inline]
201 pub fn descriptor_class_ids() -> ComponentDescriptor {
202 ComponentDescriptor {
203 archetype: Some("rerun.archetypes.LineStrips2D".into()),
204 component: "LineStrips2D:class_ids".into(),
205 component_type: Some("rerun.components.ClassId".into()),
206 }
207 }
208}
209
210static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
211 once_cell::sync::Lazy::new(|| [LineStrips2D::descriptor_strips()]);
212
213static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
214 once_cell::sync::Lazy::new(|| {
215 [
216 LineStrips2D::descriptor_radii(),
217 LineStrips2D::descriptor_colors(),
218 ]
219 });
220
221static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 4usize]> =
222 once_cell::sync::Lazy::new(|| {
223 [
224 LineStrips2D::descriptor_labels(),
225 LineStrips2D::descriptor_show_labels(),
226 LineStrips2D::descriptor_draw_order(),
227 LineStrips2D::descriptor_class_ids(),
228 ]
229 });
230
231static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 7usize]> =
232 once_cell::sync::Lazy::new(|| {
233 [
234 LineStrips2D::descriptor_strips(),
235 LineStrips2D::descriptor_radii(),
236 LineStrips2D::descriptor_colors(),
237 LineStrips2D::descriptor_labels(),
238 LineStrips2D::descriptor_show_labels(),
239 LineStrips2D::descriptor_draw_order(),
240 LineStrips2D::descriptor_class_ids(),
241 ]
242 });
243
244impl LineStrips2D {
245 pub const NUM_COMPONENTS: usize = 7usize;
247}
248
249impl ::re_types_core::Archetype for LineStrips2D {
250 #[inline]
251 fn name() -> ::re_types_core::ArchetypeName {
252 "rerun.archetypes.LineStrips2D".into()
253 }
254
255 #[inline]
256 fn display_name() -> &'static str {
257 "Line strips 2D"
258 }
259
260 #[inline]
261 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
262 REQUIRED_COMPONENTS.as_slice().into()
263 }
264
265 #[inline]
266 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
267 RECOMMENDED_COMPONENTS.as_slice().into()
268 }
269
270 #[inline]
271 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
272 OPTIONAL_COMPONENTS.as_slice().into()
273 }
274
275 #[inline]
276 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
277 ALL_COMPONENTS.as_slice().into()
278 }
279
280 #[inline]
281 fn from_arrow_components(
282 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
283 ) -> DeserializationResult<Self> {
284 re_tracing::profile_function!();
285 use ::re_types_core::{Loggable as _, ResultExt as _};
286 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
287 let strips = arrays_by_descr
288 .get(&Self::descriptor_strips())
289 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_strips()));
290 let radii = arrays_by_descr
291 .get(&Self::descriptor_radii())
292 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_radii()));
293 let colors = arrays_by_descr
294 .get(&Self::descriptor_colors())
295 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
296 let labels = arrays_by_descr
297 .get(&Self::descriptor_labels())
298 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_labels()));
299 let show_labels = arrays_by_descr
300 .get(&Self::descriptor_show_labels())
301 .map(|array| {
302 SerializedComponentBatch::new(array.clone(), Self::descriptor_show_labels())
303 });
304 let draw_order = arrays_by_descr
305 .get(&Self::descriptor_draw_order())
306 .map(|array| {
307 SerializedComponentBatch::new(array.clone(), Self::descriptor_draw_order())
308 });
309 let class_ids = arrays_by_descr
310 .get(&Self::descriptor_class_ids())
311 .map(|array| {
312 SerializedComponentBatch::new(array.clone(), Self::descriptor_class_ids())
313 });
314 Ok(Self {
315 strips,
316 radii,
317 colors,
318 labels,
319 show_labels,
320 draw_order,
321 class_ids,
322 })
323 }
324}
325
326impl ::re_types_core::AsComponents for LineStrips2D {
327 #[inline]
328 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
329 use ::re_types_core::Archetype as _;
330 [
331 self.strips.clone(),
332 self.radii.clone(),
333 self.colors.clone(),
334 self.labels.clone(),
335 self.show_labels.clone(),
336 self.draw_order.clone(),
337 self.class_ids.clone(),
338 ]
339 .into_iter()
340 .flatten()
341 .collect()
342 }
343}
344
345impl ::re_types_core::ArchetypeReflectionMarker for LineStrips2D {}
346
347impl LineStrips2D {
348 #[inline]
350 pub fn new(
351 strips: impl IntoIterator<Item = impl Into<crate::components::LineStrip2D>>,
352 ) -> Self {
353 Self {
354 strips: try_serialize_field(Self::descriptor_strips(), strips),
355 radii: None,
356 colors: None,
357 labels: None,
358 show_labels: None,
359 draw_order: None,
360 class_ids: None,
361 }
362 }
363
364 #[inline]
366 pub fn update_fields() -> Self {
367 Self::default()
368 }
369
370 #[inline]
372 pub fn clear_fields() -> Self {
373 use ::re_types_core::Loggable as _;
374 Self {
375 strips: Some(SerializedComponentBatch::new(
376 crate::components::LineStrip2D::arrow_empty(),
377 Self::descriptor_strips(),
378 )),
379 radii: Some(SerializedComponentBatch::new(
380 crate::components::Radius::arrow_empty(),
381 Self::descriptor_radii(),
382 )),
383 colors: Some(SerializedComponentBatch::new(
384 crate::components::Color::arrow_empty(),
385 Self::descriptor_colors(),
386 )),
387 labels: Some(SerializedComponentBatch::new(
388 crate::components::Text::arrow_empty(),
389 Self::descriptor_labels(),
390 )),
391 show_labels: Some(SerializedComponentBatch::new(
392 crate::components::ShowLabels::arrow_empty(),
393 Self::descriptor_show_labels(),
394 )),
395 draw_order: Some(SerializedComponentBatch::new(
396 crate::components::DrawOrder::arrow_empty(),
397 Self::descriptor_draw_order(),
398 )),
399 class_ids: Some(SerializedComponentBatch::new(
400 crate::components::ClassId::arrow_empty(),
401 Self::descriptor_class_ids(),
402 )),
403 }
404 }
405
406 #[inline]
417 pub fn columns<I>(
418 self,
419 _lengths: I,
420 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
421 where
422 I: IntoIterator<Item = usize> + Clone,
423 {
424 let columns = [
425 self.strips
426 .map(|strips| strips.partitioned(_lengths.clone()))
427 .transpose()?,
428 self.radii
429 .map(|radii| radii.partitioned(_lengths.clone()))
430 .transpose()?,
431 self.colors
432 .map(|colors| colors.partitioned(_lengths.clone()))
433 .transpose()?,
434 self.labels
435 .map(|labels| labels.partitioned(_lengths.clone()))
436 .transpose()?,
437 self.show_labels
438 .map(|show_labels| show_labels.partitioned(_lengths.clone()))
439 .transpose()?,
440 self.draw_order
441 .map(|draw_order| draw_order.partitioned(_lengths.clone()))
442 .transpose()?,
443 self.class_ids
444 .map(|class_ids| class_ids.partitioned(_lengths.clone()))
445 .transpose()?,
446 ];
447 Ok(columns.into_iter().flatten())
448 }
449
450 #[inline]
455 pub fn columns_of_unit_batches(
456 self,
457 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
458 let len_strips = self.strips.as_ref().map(|b| b.array.len());
459 let len_radii = self.radii.as_ref().map(|b| b.array.len());
460 let len_colors = self.colors.as_ref().map(|b| b.array.len());
461 let len_labels = self.labels.as_ref().map(|b| b.array.len());
462 let len_show_labels = self.show_labels.as_ref().map(|b| b.array.len());
463 let len_draw_order = self.draw_order.as_ref().map(|b| b.array.len());
464 let len_class_ids = self.class_ids.as_ref().map(|b| b.array.len());
465 let len = None
466 .or(len_strips)
467 .or(len_radii)
468 .or(len_colors)
469 .or(len_labels)
470 .or(len_show_labels)
471 .or(len_draw_order)
472 .or(len_class_ids)
473 .unwrap_or(0);
474 self.columns(std::iter::repeat(1).take(len))
475 }
476
477 #[inline]
479 pub fn with_strips(
480 mut self,
481 strips: impl IntoIterator<Item = impl Into<crate::components::LineStrip2D>>,
482 ) -> Self {
483 self.strips = try_serialize_field(Self::descriptor_strips(), strips);
484 self
485 }
486
487 #[inline]
489 pub fn with_radii(
490 mut self,
491 radii: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
492 ) -> Self {
493 self.radii = try_serialize_field(Self::descriptor_radii(), radii);
494 self
495 }
496
497 #[inline]
499 pub fn with_colors(
500 mut self,
501 colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
502 ) -> Self {
503 self.colors = try_serialize_field(Self::descriptor_colors(), colors);
504 self
505 }
506
507 #[inline]
512 pub fn with_labels(
513 mut self,
514 labels: impl IntoIterator<Item = impl Into<crate::components::Text>>,
515 ) -> Self {
516 self.labels = try_serialize_field(Self::descriptor_labels(), labels);
517 self
518 }
519
520 #[inline]
525 pub fn with_show_labels(
526 mut self,
527 show_labels: impl Into<crate::components::ShowLabels>,
528 ) -> Self {
529 self.show_labels = try_serialize_field(Self::descriptor_show_labels(), [show_labels]);
530 self
531 }
532
533 #[inline]
538 pub fn with_many_show_labels(
539 mut self,
540 show_labels: impl IntoIterator<Item = impl Into<crate::components::ShowLabels>>,
541 ) -> Self {
542 self.show_labels = try_serialize_field(Self::descriptor_show_labels(), show_labels);
543 self
544 }
545
546 #[inline]
551 pub fn with_draw_order(mut self, draw_order: impl Into<crate::components::DrawOrder>) -> Self {
552 self.draw_order = try_serialize_field(Self::descriptor_draw_order(), [draw_order]);
553 self
554 }
555
556 #[inline]
561 pub fn with_many_draw_order(
562 mut self,
563 draw_order: impl IntoIterator<Item = impl Into<crate::components::DrawOrder>>,
564 ) -> Self {
565 self.draw_order = try_serialize_field(Self::descriptor_draw_order(), draw_order);
566 self
567 }
568
569 #[inline]
573 pub fn with_class_ids(
574 mut self,
575 class_ids: impl IntoIterator<Item = impl Into<crate::components::ClassId>>,
576 ) -> Self {
577 self.class_ids = try_serialize_field(Self::descriptor_class_ids(), class_ids);
578 self
579 }
580}
581
582impl ::re_byte_size::SizeBytes for LineStrips2D {
583 #[inline]
584 fn heap_size_bytes(&self) -> u64 {
585 self.strips.heap_size_bytes()
586 + self.radii.heap_size_bytes()
587 + self.colors.heap_size_bytes()
588 + self.labels.heap_size_bytes()
589 + self.show_labels.heap_size_bytes()
590 + self.draw_order.heap_size_bytes()
591 + self.class_ids.heap_size_bytes()
592 }
593}