File size: 2,718 Bytes
9ff4bea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs
# Based on "crates/build/re_type_definitions/rerun/components/line_strip3d.def.rs".

# You can extend this class by creating a "LineStrip3DExt" class in "line_strip3d_ext.py".

from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING, Any

import numpy as np
import numpy.typing as npt
import pyarrow as pa
from attrs import define, field

from .._baseclasses import (
    BaseBatch,
    ComponentBatchMixin,
    ComponentMixin,
)
from .line_strip3d_ext import LineStrip3DExt

__all__ = ["LineStrip3D", "LineStrip3DArrayLike", "LineStrip3DBatch", "LineStrip3DLike"]


@define(init=False)
class LineStrip3D(LineStrip3DExt, ComponentMixin):
    r"""
    **Component**: A line strip in 3D space.

    A line strip is a list of points connected by line segments. It can be used to draw
    approximations of smooth curves.

    The points will be connected in order, like so:
    ```text
           2------3     5
          /        \   /
    0----1          \ /
                     4
    ```
    """

    _BATCH_TYPE = None

    def __init__(self: Any, points: LineStrip3DLike) -> None:
        """Create a new instance of the LineStrip3D component."""

        # You can define your own __init__ function as a member of LineStrip3DExt in line_strip3d_ext.py
        self.__attrs_init__(points=points)

    points: list[encodings.Vec3D] = field()

    def __len__(self) -> int:
        # You can define your own __len__ function as a member of LineStrip3DExt in line_strip3d_ext.py
        return len(self.points)


if TYPE_CHECKING:
    from .. import encodings

    LineStrip3DLike = LineStrip3D | encodings.Vec3DArrayLike | npt.NDArray[np.float32]
    """A type alias for any LineStrip3D-like object."""
else:
    LineStrip3DLike = Any

LineStrip3DArrayLike = LineStrip3D | Sequence[LineStrip3DLike] | npt.NDArray[np.float32]
"""A type alias for any LineStrip3D-like array object."""


class LineStrip3DBatch(BaseBatch[LineStrip3DArrayLike], ComponentBatchMixin):
    _ARROW_DATATYPE = pa.list_(
        pa.field(
            "item",
            pa.list_(pa.field("item", pa.float32(), nullable=False, metadata={}), 3),
            nullable=False,
            metadata={},
        )
    )
    _COMPONENT_TYPE: str = "rerun.components.LineStrip3D"

    @staticmethod
    def _native_to_pa_array(data: LineStrip3DArrayLike, data_type: pa.DataType) -> pa.Array:
        return LineStrip3DExt.native_to_pa_array_override(data, data_type)


# This is patched in late to avoid circular dependencies.
LineStrip3D._BATCH_TYPE = LineStrip3DBatch  # type: ignore[assignment]