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::SerializationResult;
17use ::re_types_core::try_serialize_field;
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)]
66pub struct Arrows3D {
67 pub vectors: Option<SerializedComponentBatch>,
69
70 pub origins: Option<SerializedComponentBatch>,
74
75 pub radii: Option<SerializedComponentBatch>,
80
81 pub colors: Option<SerializedComponentBatch>,
83
84 pub labels: Option<SerializedComponentBatch>,
89
90 pub show_labels: Option<SerializedComponentBatch>,
95
96 pub class_ids: Option<SerializedComponentBatch>,
100}
101
102impl Arrows3D {
103 #[inline]
107 pub fn descriptor_vectors() -> ComponentDescriptor {
108 ComponentDescriptor {
109 archetype: Some("rerun.archetypes.Arrows3D".into()),
110 component: "Arrows3D:vectors".into(),
111 component_type: Some("rerun.components.Vector3D".into()),
112 }
113 }
114
115 #[inline]
119 pub fn descriptor_origins() -> ComponentDescriptor {
120 ComponentDescriptor {
121 archetype: Some("rerun.archetypes.Arrows3D".into()),
122 component: "Arrows3D:origins".into(),
123 component_type: Some("rerun.components.Position3D".into()),
124 }
125 }
126
127 #[inline]
131 pub fn descriptor_radii() -> ComponentDescriptor {
132 ComponentDescriptor {
133 archetype: Some("rerun.archetypes.Arrows3D".into()),
134 component: "Arrows3D:radii".into(),
135 component_type: Some("rerun.components.Radius".into()),
136 }
137 }
138
139 #[inline]
143 pub fn descriptor_colors() -> ComponentDescriptor {
144 ComponentDescriptor {
145 archetype: Some("rerun.archetypes.Arrows3D".into()),
146 component: "Arrows3D:colors".into(),
147 component_type: Some("rerun.components.Color".into()),
148 }
149 }
150
151 #[inline]
155 pub fn descriptor_labels() -> ComponentDescriptor {
156 ComponentDescriptor {
157 archetype: Some("rerun.archetypes.Arrows3D".into()),
158 component: "Arrows3D:labels".into(),
159 component_type: Some("rerun.components.Text".into()),
160 }
161 }
162
163 #[inline]
167 pub fn descriptor_show_labels() -> ComponentDescriptor {
168 ComponentDescriptor {
169 archetype: Some("rerun.archetypes.Arrows3D".into()),
170 component: "Arrows3D:show_labels".into(),
171 component_type: Some("rerun.components.ShowLabels".into()),
172 }
173 }
174
175 #[inline]
179 pub fn descriptor_class_ids() -> ComponentDescriptor {
180 ComponentDescriptor {
181 archetype: Some("rerun.archetypes.Arrows3D".into()),
182 component: "Arrows3D:class_ids".into(),
183 component_type: Some("rerun.components.ClassId".into()),
184 }
185 }
186}
187
188static REQUIRED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
189 std::sync::LazyLock::new(|| [Arrows3D::descriptor_vectors()]);
190
191static RECOMMENDED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
192 std::sync::LazyLock::new(|| [Arrows3D::descriptor_origins()]);
193
194static OPTIONAL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 5usize]> =
195 std::sync::LazyLock::new(|| {
196 [
197 Arrows3D::descriptor_radii(),
198 Arrows3D::descriptor_colors(),
199 Arrows3D::descriptor_labels(),
200 Arrows3D::descriptor_show_labels(),
201 Arrows3D::descriptor_class_ids(),
202 ]
203 });
204
205static ALL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 7usize]> =
206 std::sync::LazyLock::new(|| {
207 [
208 Arrows3D::descriptor_vectors(),
209 Arrows3D::descriptor_origins(),
210 Arrows3D::descriptor_radii(),
211 Arrows3D::descriptor_colors(),
212 Arrows3D::descriptor_labels(),
213 Arrows3D::descriptor_show_labels(),
214 Arrows3D::descriptor_class_ids(),
215 ]
216 });
217
218impl Arrows3D {
219 pub const NUM_COMPONENTS: usize = 7usize;
221}
222
223impl ::re_types_core::Archetype for Arrows3D {
224 #[inline]
225 fn name() -> ::re_types_core::ArchetypeName {
226 "rerun.archetypes.Arrows3D".into()
227 }
228
229 #[inline]
230 fn display_name() -> &'static str {
231 "Arrows 3D"
232 }
233
234 #[inline]
235 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
236 REQUIRED_COMPONENTS.as_slice().into()
237 }
238
239 #[inline]
240 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
241 RECOMMENDED_COMPONENTS.as_slice().into()
242 }
243
244 #[inline]
245 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
246 OPTIONAL_COMPONENTS.as_slice().into()
247 }
248
249 #[inline]
250 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
251 ALL_COMPONENTS.as_slice().into()
252 }
253
254 #[inline]
255 fn from_arrow_components(
256 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
257 ) -> DeserializationResult<Self> {
258 re_tracing::profile_function!();
259 use ::re_types_core::{Loggable as _, ResultExt as _};
260 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
261 let vectors = arrays_by_descr
262 .get(&Self::descriptor_vectors())
263 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_vectors()));
264 let origins = arrays_by_descr
265 .get(&Self::descriptor_origins())
266 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_origins()));
267 let radii = arrays_by_descr
268 .get(&Self::descriptor_radii())
269 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_radii()));
270 let colors = arrays_by_descr
271 .get(&Self::descriptor_colors())
272 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
273 let labels = arrays_by_descr
274 .get(&Self::descriptor_labels())
275 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_labels()));
276 let show_labels = arrays_by_descr
277 .get(&Self::descriptor_show_labels())
278 .map(|array| {
279 SerializedComponentBatch::new(array.clone(), Self::descriptor_show_labels())
280 });
281 let class_ids = arrays_by_descr
282 .get(&Self::descriptor_class_ids())
283 .map(|array| {
284 SerializedComponentBatch::new(array.clone(), Self::descriptor_class_ids())
285 });
286 Ok(Self {
287 vectors,
288 origins,
289 radii,
290 colors,
291 labels,
292 show_labels,
293 class_ids,
294 })
295 }
296}
297
298impl ::re_types_core::AsComponents for Arrows3D {
299 #[inline]
300 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
301 use ::re_types_core::Archetype as _;
302 [
303 self.vectors.clone(),
304 self.origins.clone(),
305 self.radii.clone(),
306 self.colors.clone(),
307 self.labels.clone(),
308 self.show_labels.clone(),
309 self.class_ids.clone(),
310 ]
311 .into_iter()
312 .flatten()
313 .collect()
314 }
315}
316
317impl ::re_types_core::ArchetypeReflectionMarker for Arrows3D {}
318
319impl Arrows3D {
320 #[inline]
322 pub(crate) fn new(
323 vectors: impl IntoIterator<Item = impl Into<crate::components::Vector3D>>,
324 ) -> Self {
325 Self {
326 vectors: try_serialize_field(Self::descriptor_vectors(), vectors),
327 origins: None,
328 radii: None,
329 colors: None,
330 labels: None,
331 show_labels: None,
332 class_ids: None,
333 }
334 }
335
336 #[inline]
338 pub fn update_fields() -> Self {
339 Self::default()
340 }
341
342 #[inline]
344 pub fn clear_fields() -> Self {
345 use ::re_types_core::Loggable as _;
346 Self {
347 vectors: Some(SerializedComponentBatch::new(
348 crate::components::Vector3D::arrow_empty(),
349 Self::descriptor_vectors(),
350 )),
351 origins: Some(SerializedComponentBatch::new(
352 crate::components::Position3D::arrow_empty(),
353 Self::descriptor_origins(),
354 )),
355 radii: Some(SerializedComponentBatch::new(
356 crate::components::Radius::arrow_empty(),
357 Self::descriptor_radii(),
358 )),
359 colors: Some(SerializedComponentBatch::new(
360 crate::components::Color::arrow_empty(),
361 Self::descriptor_colors(),
362 )),
363 labels: Some(SerializedComponentBatch::new(
364 crate::components::Text::arrow_empty(),
365 Self::descriptor_labels(),
366 )),
367 show_labels: Some(SerializedComponentBatch::new(
368 crate::components::ShowLabels::arrow_empty(),
369 Self::descriptor_show_labels(),
370 )),
371 class_ids: Some(SerializedComponentBatch::new(
372 crate::components::ClassId::arrow_empty(),
373 Self::descriptor_class_ids(),
374 )),
375 }
376 }
377
378 #[inline]
389 pub fn columns<I>(
390 self,
391 _lengths: I,
392 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
393 where
394 I: IntoIterator<Item = usize> + Clone,
395 {
396 let columns = [
397 self.vectors
398 .map(|vectors| vectors.partitioned(_lengths.clone()))
399 .transpose()?,
400 self.origins
401 .map(|origins| origins.partitioned(_lengths.clone()))
402 .transpose()?,
403 self.radii
404 .map(|radii| radii.partitioned(_lengths.clone()))
405 .transpose()?,
406 self.colors
407 .map(|colors| colors.partitioned(_lengths.clone()))
408 .transpose()?,
409 self.labels
410 .map(|labels| labels.partitioned(_lengths.clone()))
411 .transpose()?,
412 self.show_labels
413 .map(|show_labels| show_labels.partitioned(_lengths.clone()))
414 .transpose()?,
415 self.class_ids
416 .map(|class_ids| class_ids.partitioned(_lengths.clone()))
417 .transpose()?,
418 ];
419 Ok(columns.into_iter().flatten())
420 }
421
422 #[inline]
427 pub fn columns_of_unit_batches(
428 self,
429 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
430 let len_vectors = self.vectors.as_ref().map(|b| b.array.len());
431 let len_origins = self.origins.as_ref().map(|b| b.array.len());
432 let len_radii = self.radii.as_ref().map(|b| b.array.len());
433 let len_colors = self.colors.as_ref().map(|b| b.array.len());
434 let len_labels = self.labels.as_ref().map(|b| b.array.len());
435 let len_show_labels = self.show_labels.as_ref().map(|b| b.array.len());
436 let len_class_ids = self.class_ids.as_ref().map(|b| b.array.len());
437 let len = None
438 .or(len_vectors)
439 .or(len_origins)
440 .or(len_radii)
441 .or(len_colors)
442 .or(len_labels)
443 .or(len_show_labels)
444 .or(len_class_ids)
445 .unwrap_or(0);
446 self.columns(std::iter::repeat_n(1, len))
447 }
448
449 #[inline]
451 pub fn with_vectors(
452 mut self,
453 vectors: impl IntoIterator<Item = impl Into<crate::components::Vector3D>>,
454 ) -> Self {
455 self.vectors = try_serialize_field(Self::descriptor_vectors(), vectors);
456 self
457 }
458
459 #[inline]
463 pub fn with_origins(
464 mut self,
465 origins: impl IntoIterator<Item = impl Into<crate::components::Position3D>>,
466 ) -> Self {
467 self.origins = try_serialize_field(Self::descriptor_origins(), origins);
468 self
469 }
470
471 #[inline]
476 pub fn with_radii(
477 mut self,
478 radii: impl IntoIterator<Item = impl Into<crate::components::Radius>>,
479 ) -> Self {
480 self.radii = try_serialize_field(Self::descriptor_radii(), radii);
481 self
482 }
483
484 #[inline]
486 pub fn with_colors(
487 mut self,
488 colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
489 ) -> Self {
490 self.colors = try_serialize_field(Self::descriptor_colors(), colors);
491 self
492 }
493
494 #[inline]
499 pub fn with_labels(
500 mut self,
501 labels: impl IntoIterator<Item = impl Into<crate::components::Text>>,
502 ) -> Self {
503 self.labels = try_serialize_field(Self::descriptor_labels(), labels);
504 self
505 }
506
507 #[inline]
512 pub fn with_show_labels(
513 mut self,
514 show_labels: impl Into<crate::components::ShowLabels>,
515 ) -> Self {
516 self.show_labels = try_serialize_field(Self::descriptor_show_labels(), [show_labels]);
517 self
518 }
519
520 #[inline]
525 pub fn with_many_show_labels(
526 mut self,
527 show_labels: impl IntoIterator<Item = 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]
537 pub fn with_class_ids(
538 mut self,
539 class_ids: impl IntoIterator<Item = impl Into<crate::components::ClassId>>,
540 ) -> Self {
541 self.class_ids = try_serialize_field(Self::descriptor_class_ids(), class_ids);
542 self
543 }
544}
545
546impl ::re_byte_size::SizeBytes for Arrows3D {
547 #[inline]
548 fn heap_size_bytes(&self) -> u64 {
549 self.vectors.heap_size_bytes()
550 + self.origins.heap_size_bytes()
551 + self.radii.heap_size_bytes()
552 + self.colors.heap_size_bytes()
553 + self.labels.heap_size_bytes()
554 + self.show_labels.heap_size_bytes()
555 + self.class_ids.heap_size_bytes()
556 }
557}