open3d.t.geometry.TriangleMesh

class open3d.t.geometry.TriangleMesh

A triangle mesh contains vertices and triangles. The triangle mesh class stores the attribute data in key-value maps. There are two maps: the vertex attributes map, and the triangle attribute map.

The attributes of the triangle mesh have different levels:

import open3d as o3d

device = o3d.core.Device("CPU:0")
dtype_f = o3d.core.float32
dtype_i = o3d.core.int32

# Create an empty triangle mesh
# Use mesh.vertex to access the vertices' attributes
# Use mesh.triangle to access the triangles' attributes
mesh = o3d.t.geometry.TriangleMesh(device)

# Default attribute: vertex["positions"], triangle["indices"]
# These attributes is created by default and is required by all triangle
# meshes. The shape of both must be (N, 3). The device of "positions"
# determines the device of the triangle mesh.
mesh.vertex["positions"] = o3d.core.Tensor([[0, 0, 0],
                                            [0, 0, 1],
                                            [0, 1, 0],
                                            [0, 1, 1]], dtype_f, device)
mesh.triangle["indices"] = o3d.core.Tensor([[0, 1, 2],
                                            [0, 2, 3]]], dtype_i, device)

# Common attributes: vertex["colors"]  , vertex["normals"]
#                    triangle["colors"], triangle["normals"]
# Common attributes are used in built-in triangle mesh operations. The
# spellings must be correct. For example, if "normal" is used instead of
# "normals", some internal operations that expects "normals" will not work.
# "normals" and "colors" must have shape (N, 3) and must be on the same
# device as the triangle mesh.
mesh.vertex["normals"] = o3c.core.Tensor([[0, 0, 1],
                                          [0, 1, 0],
                                          [1, 0, 0],
                                          [1, 1, 1]], dtype_f, device)
mesh.vertex["colors"] = o3c.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)
mesh.triangle["normals"] = o3c.core.Tensor(...)
mesh.triangle["colors"] = o3c.core.Tensor(...)

# User-defined attributes
# You can also attach custom attributes. The value tensor must be on the
# same device as the triangle mesh. The are no restrictions on the shape and
# dtype, e.g.,
pcd.vertex["labels"] = o3c.core.Tensor(...)
pcd.triangle["features"] = o3c.core.Tensor(...)
__init__(*args, **kwargs)

Overloaded function.

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

Construct an empty trianglemesh on the provided device (default: ‘CPU:0’).

  1. __init__(self: open3d.cpu.pybind.t.geometry.TriangleMesh, vertex_positions: open3d.cpu.pybind.core.Tensor, triangle_indices: open3d.cpu.pybind.core.Tensor) -> None

clear(self)

Clear all elements in the geometry.

Returns

open3d.t.geometry.Geometry

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

Returns copy of the triangle mesh on the same device.

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

Transfer the triangle mesh to CPU. If the triangle mesh is already on CPU, no copy will be performed.

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

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

static from_legacy(mesh_legacy: open3d.cpu.pybind.geometry.TriangleMesh, vertex_dtype: open3d.cpu.pybind.core.Dtype = Float32, triangle_dtype: open3d.cpu.pybind.core.Dtype = Int64, device: open3d.cpu.pybind.core.Device = CPU:0) → open3d.cpu.pybind.t.geometry.TriangleMesh

Create a TriangleMesh from a legacy Open3D TriangleMesh.

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

Returns the center for point coordinates.

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

Returns the max bound for point coordinates.

get_min_bound(self: open3d.cpu.pybind.t.geometry.TriangleMesh) → 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: open3d.cpu.pybind.t.geometry.TriangleMesh, R: open3d.cpu.pybind.core.Tensor, center: open3d.cpu.pybind.core.Tensor) → open3d.cpu.pybind.t.geometry.TriangleMesh

Rotate points and normals (if exist).

scale(self: open3d.cpu.pybind.t.geometry.TriangleMesh, scale: float, center: open3d.cpu.pybind.core.Tensor) → open3d.cpu.pybind.t.geometry.TriangleMesh

Scale points.

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

Transfer the triangle mesh to a specified device.

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

Convert to a legacy Open3D TriangleMesh.

transform(self: open3d.cpu.pybind.t.geometry.TriangleMesh, transformation: open3d.cpu.pybind.core.Tensor) → open3d.cpu.pybind.t.geometry.TriangleMesh

Transforms the points and normals (if exist).

translate(self: open3d.cpu.pybind.t.geometry.TriangleMesh, translation: open3d.cpu.pybind.core.Tensor, relative: bool = True) → open3d.cpu.pybind.t.geometry.TriangleMesh

Translates points.

property material
property triangle
property vertex