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)]
103pub struct LineStrips3D {
104 pub strips: Option<SerializedComponentBatch>,
106
107 pub radii: Option<SerializedComponentBatch>,
109
110 pub colors: Option<SerializedComponentBatch>,
112
113 pub labels: Option<SerializedComponentBatch>,
118
119 pub show_labels: Option<SerializedComponentBatch>,
124
125 pub class_ids: Option<SerializedComponentBatch>,
129}
130
131impl LineStrips3D {
132 #[inline]
136 pub fn descriptor_strips() -> ComponentDescriptor {
137 ComponentDescriptor {
138 archetype: Some("rerun.archetypes.LineStrips3D".into()),
139 component: "LineStrips3D:strips".into(),
140 component_type: Some("rerun.components.LineStrip3D".into()),
141 }
142 }
143
144 #[inline]
148 pub fn descriptor_radii() -> ComponentDescriptor {
149 ComponentDescriptor {
150 archetype: Some("rerun.archetypes.LineStrips3D".into()),
151 component: "LineStrips3D:radii".into(),
152 component_type: Some("rerun.components.Radius".into()),
153 }
154 }
155
156 #[inline]
160 pub fn descriptor_colors() -> ComponentDescriptor {
161 ComponentDescriptor {
162 archetype: Some("rerun.archetypes.LineStrips3D".into()),
163 component: "LineStrips3D:colors".into(),
164 component_type: Some("rerun.components.Color".into()),
165 }
166 }
167
168 #[inline]
172 pub fn descriptor_labels() -> ComponentDescriptor {
173 ComponentDescriptor {
174 archetype: Some("rerun.archetypes.LineStrips3D".into()),
175 component: "LineStrips3D:labels".into(),
176 component_type: Some("rerun.components.Text".into()),
177 }
178 }
179
180 #[inline]
184 pub fn descriptor_show_labels() -> ComponentDescriptor {
185 ComponentDescriptor {
186 archetype: Some("rerun.archetypes.LineStrips3D".into()),
187 component: "LineStrips3D:show_labels".into(),
188 component_type: Some("rerun.components.ShowLabels".into()),
189 }
190 }
191
192 #[inline]
196 pub fn descriptor_class_ids() -> ComponentDescriptor {
197 ComponentDescriptor {
198 archetype: Some("rerun.archetypes.LineStrips3D".into()),
199 component: "LineStrips3D:class_ids".into(),
200 component_type: Some("rerun.components.ClassId".into()),
201 }
202 }
203}
204
205static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
206 once_cell::sync::Lazy::new(|| [LineStrips3D::descriptor_strips()]);
207
208static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 2usize]> =
209 once_cell::sync::Lazy::new(|| {
210 [
211 LineStrips3D::descriptor_radii(),
212 LineStrips3D::descriptor_colors(),
213 ]
214 });
215
216static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 3usize]> =
217 once_cell::sync::Lazy::new(|| {
218 [
219 LineStrips3D::descriptor_labels(),
220 LineStrips3D::descriptor_show_labels(),
221 LineStrips3D::descriptor_class_ids(),
222 ]
223 });
224
225static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 6usize]> =
226 once_cell::sync::Lazy::new(|| {
227 [
228 LineStrips3D::descriptor_strips(),
229 LineStrips3D::descriptor_radii(),
230 LineStrips3D::descriptor_colors(),
231 LineStrips3D::descriptor_labels(),
232 LineStrips3D::descriptor_show_labels(),
233 LineStrips3D::descriptor_class_ids(),
234 ]
235 });
236
237impl LineStrips3D {
238 pub const NUM_COMPONENTS: usize = 6usize;
240}
241
242impl ::re_types_core::Archetype for LineStrips3D {
243 #[inline]
244 fn name() -> ::re_types_core::ArchetypeName {
245 "rerun.archetypes.LineStrips3D".into()
246 }
247
248 #[inline]
249 fn display_name() -> &'static str {
250 "Line strips 3D"
251 }
252
253 #[inline]
254 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
255 REQUIRED_COMPONENTS.as_slice().into()
256 }
257
258 #[inline]
259 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
260 RECOMMENDED_COMPONENTS.as_slice().into()
261 }
262
263 #[inline]
264 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
265 OPTIONAL_COMPONENTS.as_slice().into()
266 }
267
268 #[inline]
269 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
270 ALL_COMPONENTS.as_slice().into()
271 }
272
273 #[inline]
274 fn from_arrow_components(
275 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
276 ) -> DeserializationResult<Self> {
277 re_tracing::profile_function!();
278 use ::re_types_core::{Loggable as _, ResultExt as _};
279 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
280 let strips = arrays_by_descr
281 .get(&Self::descriptor_strips())
282 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_strips()));
283 let radii = arrays_by_descr
284 .get(&Self::descriptor_radii())
285 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_radii()));
286 let colors = arrays_by_descr
287 .get(&Self::descriptor_colors())
288 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
289 let labels = arrays_by_descr
290 .get(&Self::descriptor_labels())
291 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_labels()));
292 let show_labels = arrays_by_descr
293 .get(&Self::descriptor_show_labels())
294 .map(|array| {
295 SerializedComponentBatch::new(array.clone(), Self::descriptor_show_labels())
296 });
297 let class_ids = arrays_by_descr
298 .get(&Self::descriptor_class_ids())
299 .map(|array| {
300 SerializedComponentBatch::new(array.clone(), Self::descriptor_class_ids())
301 });
302 Ok(Self {
303 strips,
304 radii,
305 colors,
306 labels,
307 show_labels,
308 class_ids,
309 })
310 }
311}
312
313impl ::re_types_core::AsComponents for LineStrips3D {
314 #[inline]
315 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
316 use ::re_types_core::Archetype as _;
317 [
318 self.strips.clone(),
319 self.radii.clone(),
320 self.colors.clone(),
321 self.labels.clone(),
322 self.show_labels.clone(),
323 self.class_ids.clone(),
324 ]
325 .into_iter()
326 .flatten()
327 .collect()
328 }
329}
330
331impl ::re_types_core::ArchetypeReflectionMarker for LineStrips3D {}
332
333impl LineStrips3D {
334 #[inline]
336 pub fn new(
337 strips: impl IntoIterator<Item = impl Into<crate::components::LineStrip3D>>,
338 ) -> Self {
339 Self {
340 strips: try_serialize_field(Self::descriptor_strips(), strips),
341 radii: None,
342 colors: None,
343 labels: None,
344 show_labels: None,
345 class_ids: None,
346 }
347 }
348
349 #[inline]
351 pub fn update_fields() -> Self {
352 Self::default()
353 }
354
355 #[inline]
357 pub fn clear_fields() -> Self {
358 use ::re_types_core::Loggable as _;
359 Self {
360 strips: Some(SerializedComponentBatch::new(
361 crate::components::LineStrip3D::arrow_empty(),
362 Self::descriptor_strips(),
363 )),
364 radii: Some(SerializedComponentBatch::new(
365 crate::components::Radius::arrow_empty(),
366 Self::descriptor_radii(),
367 )),
368 colors: Some(SerializedComponentBatch::new(
369 crate::components::Color::arrow_empty(),
370 Self::descriptor_colors(),
371 )),
372 labels: Some(SerializedComponentBatch::new(
373 crate::components::Text::arrow_empty(),
374 Self::descriptor_labels(),
375 )),
376 show_labels: Some(SerializedComponentBatch::new(
377 crate::components::ShowLabels::arrow_empty(),
378 Self::descriptor_show_labels(),
379 )),
380 class_ids: Some(SerializedComponentBatch::new(
381 crate::components::ClassId::arrow_empty(),
382 Self::descriptor_class_ids(),
383 )),
384 }
385 }
386
387 #[inline]
398 pub fn columns<I>(
399 self,
400 _lengths: I,
401 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
402 where
403 I: IntoIterator<Item = usize> + Clone,
404 {
405 let columns = [
406 self.strips
407 .map(|strips| strips.partitioned(_lengths.clone()))
408 .transpose()?,
409 self.radii
410 .map(|radii| radii.partitioned(_lengths.clone()))
411 .transpose()?,
412 self.colors
413 .map(|colors| colors.partitioned(_lengths.clone()))
414 .transpose()?,
415 self.labels
416 .map(|labels| labels.partitioned(_lengths.clone()))
417 .transpose()?,
418 self.show_labels
419 .map(|show_labels| show_labels.partitioned(_lengths.clone()))
420 .transpose()?,
421 self.class_ids
422 .map(|class_ids| class_ids.partitioned(_lengths.clone()))
423 .transpose()?,
424 ];
425 Ok(columns.into_iter().flatten())
426 }
427
428 #[inline]
433 pub fn columns_of_unit_batches(
434 self,
435 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
436 let len_strips = self.strips.as_ref().map(|b| b.array.len());
437 let len_radii = self.radii.as_ref().map(|b| b.array.len());
438 let len_colors = self.colors.as_ref().map(|b| b.array.len());
439 let len_labels = self.labels.as_ref().map(|b| b.array.len());
440 let len_show_labels = self.show_labels.as_ref().map(|b| b.array.len());
441 let len_class_ids = self.class_ids.as_ref().map(|b| b.array.len());
442 let len = None
443 .or(len_strips)
444 .or(len_radii)
445 .or(len_colors)
446 .or(len_labels)
447 .or(len_show_labels)
448 .or(len_class_ids)
449 .unwrap_or(0);
450 self.columns(std::iter::repeat(1).take(len))
451 }
452
453 #[inline]
455 pub fn with_strips(
456 mut self,
457 strips: impl IntoIterator<Item = impl Into<crate::components::LineStrip3D>>,
458 ) -> Self {
459 self.strips = try_serialize_field(Self::descriptor_strips(), strips);
460 self
461 }
462
463 #[inline]
465 pub fn with_radii(
466 mut self,
467 radii: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
468 ) -> Self {
469 self.radii = try_serialize_field(Self::descriptor_radii(), radii);
470 self
471 }
472
473 #[inline]
475 pub fn with_colors(
476 mut self,
477 colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
478 ) -> Self {
479 self.colors = try_serialize_field(Self::descriptor_colors(), colors);
480 self
481 }
482
483 #[inline]
488 pub fn with_labels(
489 mut self,
490 labels: impl IntoIterator<Item = impl Into<crate::components::Text>>,
491 ) -> Self {
492 self.labels = try_serialize_field(Self::descriptor_labels(), labels);
493 self
494 }
495
496 #[inline]
501 pub fn with_show_labels(
502 mut self,
503 show_labels: impl Into<crate::components::ShowLabels>,
504 ) -> Self {
505 self.show_labels = try_serialize_field(Self::descriptor_show_labels(), [show_labels]);
506 self
507 }
508
509 #[inline]
514 pub fn with_many_show_labels(
515 mut self,
516 show_labels: impl IntoIterator<Item = impl Into<crate::components::ShowLabels>>,
517 ) -> Self {
518 self.show_labels = try_serialize_field(Self::descriptor_show_labels(), show_labels);
519 self
520 }
521
522 #[inline]
526 pub fn with_class_ids(
527 mut self,
528 class_ids: impl IntoIterator<Item = impl Into<crate::components::ClassId>>,
529 ) -> Self {
530 self.class_ids = try_serialize_field(Self::descriptor_class_ids(), class_ids);
531 self
532 }
533}
534
535impl ::re_byte_size::SizeBytes for LineStrips3D {
536 #[inline]
537 fn heap_size_bytes(&self) -> u64 {
538 self.strips.heap_size_bytes()
539 + self.radii.heap_size_bytes()
540 + self.colors.heap_size_bytes()
541 + self.labels.heap_size_bytes()
542 + self.show_labels.heap_size_bytes()
543 + self.class_ids.heap_size_bytes()
544 }
545}