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.,
pcd.point["labels"] = o3d.core.Tensor(...)
pcd.line["features"] = o3d.core.Tensor(...)
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self, device=CPU:0)

    Construct an empty LineSet on the provided device.

Parameters
  • (open3d.core.Device (device) –

  • optional

  • default=CPU

  1. __init__(self, point_positions, line_indices)

    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.

Parameters
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.

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.

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.