open3d.t.geometry.LineSet

class open3d.t.geometry.LineSet

A LineSet contains points and lines joining them and optionally attributes on the points and lines. The LineSet class stores the attribute data in key-value maps, where the key is the attribute name and value is a Tensor containing the attribute data. There are two maps: one each for point and line.

The attributes of the line set have different levels:

import open3d as o3d

dtype_f = o3d.core.float32
dtype_i = o3d.core.int32

# Create an empty line set
# Use lineset.point to access the point attributes
# Use lineset.line to access the line attributes
lineset = o3d.t.geometry.LineSet()

# Default attribute: point.positions, line.indices
# These attributes is created by default and are required by all line
# sets. The shape must be (N, 3) and (N, 2) respectively. The device of
# "positions" determines the device of the line set.
lineset.point.positions = o3d.core.Tensor([[0, 0, 0],
                                              [0, 0, 1],
                                              [0, 1, 0],
                                              [0, 1, 1]], dtype_f, device)
lineset.line.indices = o3d.core.Tensor([[0, 1],
                                           [1, 2],
                                           [2, 3],
                                           [3, 0]], dtype_i, device)

# Common attributes: line.colors
# Common attributes are used in built-in line set operations. The
# spellings must be correct. For example, if "color" is used instead of
# "color", some internal operations that expects "colors" will not work.
# "colors" must have shape (N, 3) and must be on the same device as the
# line set.
lineset.line.colors = o3d.core.Tensor([[0.0, 0.0, 0.0],
                                          [0.1, 0.1, 0.1],
                                          [0.2, 0.2, 0.2],
                                          [0.3, 0.3, 0.3]], dtype_f, device)

# User-defined attributes
# You can also attach custom attributes. The value tensor must be on the
# same device as the line set. The are no restrictions on the shape or
# dtype, e.g.,
lineset.point.labels = o3d.core.Tensor(...)
lineset.line.features = o3d.core.Tensor(...)
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: open3d.cpu.pybind.t.geometry.LineSet, device: open3d.cpu.pybind.core.Device = CPU:0) -> None

Construct an empty LineSet on the provided device.

  1. __init__(self: open3d.cpu.pybind.t.geometry.LineSet, point_positions: open3d.cpu.pybind.core.Tensor, line_indices: open3d.cpu.pybind.core.Tensor) -> None

Construct a LineSet from point_positions and line_indices.

The input tensors will be directly used as the underlying storage of the line set (no memory copy). The resulting LineSet will have the same dtype and device as the tensor. The device for point_positions must be consistent with line_indices.

  1. __init__(self: open3d.cpu.pybind.t.geometry.LineSet, arg0: open3d.cpu.pybind.t.geometry.LineSet) -> None

Copy constructor

clear(self)

Clear all elements in the geometry.

Returns

open3d.t.geometry.Geometry

clone(self: open3d.cpu.pybind.t.geometry.LineSet) → open3d.cpu.pybind.t.geometry.LineSet

Returns copy of the line set on the same device.

cpu(self: open3d.cpu.pybind.t.geometry.LineSet) → open3d.cpu.pybind.t.geometry.LineSet

Transfer the line set to CPU. If the line set is already on CPU, no copy will be performed.

cuda(self: open3d.cpu.pybind.t.geometry.LineSet, device_id: int = 0) → open3d.cpu.pybind.t.geometry.LineSet

Transfer the line set to a CUDA device. If the line set is already on the specified CUDA device, no copy will be performed.

extrude_linear(self: open3d.cpu.pybind.t.geometry.LineSet, vector: open3d.cpu.pybind.core.Tensor, scale: float = 1.0, capping: bool = True) → open3d::t::geometry::TriangleMesh

Sweeps the line set along a direction vector.

Parameters
  • vector (open3d.core.Tensor) – The direction vector.

  • scale (float) – Scalar factor which essentially scales the direction vector.

Returns

A triangle mesh with the result of the sweep operation.

Example

This code generates an L-shaped mesh::

import open3d as o3d

lines = o3d.t.geometry.LineSet([[1.0,0.0,0.0],[0,0,0],[0,0,1]], [[0,1],[1,2]]) mesh = lines.extrude_linear([0,1,0]) o3d.visualization.draw([{‘name’: ‘L’, ‘geometry’: mesh}])

extrude_rotation(self: open3d.cpu.pybind.t.geometry.LineSet, angle: float, axis: open3d.cpu.pybind.core.Tensor, resolution: int = 16, translation: float = 0.0, capping: bool = True) → open3d::t::geometry::TriangleMesh

Sweeps the line set rotationally about an axis.

Parameters
  • angle (float) – The rotation angle in degree.

  • axis (open3d.core.Tensor) – The rotation axis.

  • resolution (int) – The resolution defines the number of intermediate sweeps about the rotation axis.

  • translation (float) – The translation along the rotation axis.

Returns

A triangle mesh with the result of the sweep operation.

Example

This code generates a spring from a single line:

import open3d as o3d

line = o3d.t.geometry.LineSet([[0.7,0,0],[1,0,0]], [[0,1]])
spring = line.extrude_rotation(3*360, [0,1,0], resolution=3*16, translation=2)
o3d.visualization.draw([{'name': 'spring', 'geometry': spring}])
static from_legacy(lineset_legacy, float_dtype=Float32, int_dtype=Int64, device=CPU:0)

Create a LineSet from a legacy Open3D LineSet.

Parameters
  • lineset_legacy (open3d.geometry.LineSet) – Legacy Open3D LineSet.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float32 or Float64, used to store floating point values, e.g. points, normals, colors.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int32 or Int64, used to store index values, e.g. line indices.

  • (open3d.core.Device (device) – 0): The device where the resulting LineSet resides.

  • optional – 0): The device where the resulting LineSet resides.

  • default=CPU – 0): The device where the resulting LineSet resides.

Returns

open3d.t.geometry.LineSet

get_axis_aligned_bounding_box(self: open3d.cpu.pybind.t.geometry.LineSet) → open3d::t::geometry::AxisAlignedBoundingBox

Create an axis-aligned bounding box from point attribute ‘positions’.

get_center(self: open3d.cpu.pybind.t.geometry.LineSet) → open3d.cpu.pybind.core.Tensor

Returns the center for point coordinates.

get_max_bound(self: open3d.cpu.pybind.t.geometry.LineSet) → open3d.cpu.pybind.core.Tensor

Returns the max bound for point coordinates.

get_min_bound(self: open3d.cpu.pybind.t.geometry.LineSet) → open3d.cpu.pybind.core.Tensor

Returns the min bound for point coordinates.

get_oriented_bounding_box(self: open3d.cpu.pybind.t.geometry.LineSet) → open3d::t::geometry::OrientedBoundingBox

Create an oriented bounding box from point attribute ‘positions’.

has_valid_material(self: open3d.cpu.pybind.t.geometry.DrawableGeometry) → bool

Returns true if the geometry’s material is valid.

is_empty(self)

Returns True iff the geometry is empty.

Returns

bool

rotate(self, R, center)

Rotate points and lines. Custom attributes (e.g. point normals) are not rotated.

Parameters
  • R (open3d.core.Tensor) – Rotation [Tensor of shape (3,3)].

  • center (open3d.core.Tensor) – Center [Tensor of shape (3,)] about which the LineSet is to be rotated. Should be on the same device as the LineSet.

Returns

open3d.t.geometry.LineSet

scale(self, scale, center)

Scale points and lines. Custom attributes are not scaled.

Parameters
  • scale (float) – Scale magnitude.

  • center (open3d.core.Tensor) – Center [Tensor of shape (3,)] about which the LineSet is to be scaled. Should be on the same device as the LineSet.

Returns

open3d.t.geometry.LineSet

to(self: open3d.cpu.pybind.t.geometry.LineSet, device: open3d.cpu.pybind.core.Device, copy: bool = False) → open3d.cpu.pybind.t.geometry.LineSet

Transfer the line set to a specified device.

to_legacy(self: open3d.cpu.pybind.t.geometry.LineSet) → open3d.cpu.pybind.geometry.LineSet

Convert to a legacy Open3D LineSet.

transform(self, transformation)

Transforms the points and lines. Custom attributes (e.g. point normals) are not transformed. Extracts R, t from the transformation as:

\[\begin{split}T_{(4,4)} = \begin{bmatrix} R_{(3,3)} & t_{(3,1)} \\ O_{(1,3)} & s_{(1,1)} \end{bmatrix}\end{split}\]

It assumes \(s = 1\) (no scaling) and \(O = [0,0,0]\) and applies the transformation as \(P = R(P) + t\)

Parameters

transformation (open3d.core.Tensor) – Transformation [Tensor of shape (4,4)]. Should be on the same device as the LineSet

Returns

open3d.t.geometry.LineSet

translate(self, translation, relative=True)

Translates points and lines of the LineSet.

Parameters
  • translation (open3d.core.Tensor) – Translation tensor of dimension (3,). Should be on the same device as the LineSet

  • relative (bool, optional, default=True) – If true (default) translates relative to center of LineSet.

Returns

open3d.t.geometry.LineSet

property device

Returns the device of the geometry.

property is_cpu

Returns true if the geometry is on CPU.

property is_cuda

Returns true if the geometry is on CUDA.

property line

Dictionary containing line attributes. The primary key indices contains indices of points defining the lines.

property material
property point

Dictionary containing point attributes. The primary key positions contains point positions.