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