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 = o3d.core.Tensor([[0, 0, 1],
                                          [0, 1, 0],
                                          [1, 0, 0],
                                          [1, 1, 1]], dtype_f, device)
mesh.vertex.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)
mesh.triangle.normals = o3d.core.Tensor(...)
mesh.triangle.colors = o3d.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 = o3d.core.Tensor(...)
pcd.triangle.features = o3d.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

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

Copy constructor

bake_triangle_attr_textures(self: open3d.cpu.pybind.t.geometry.TriangleMesh, size: int, triangle_attr: Set[str], margin: float = 2.0, fill: float = 0.0, update_material: bool = True) Dict[str, open3d.cpu.pybind.core.Tensor]#

Bake triangle attributes into textures.

This function assumes a triangle attribute with name ‘texture_uvs’.

This function always uses the CPU device.

Parameters:
  • size (int) – The width and height of the texture in pixels. Only square textures are supported.

  • triangle_attr (set) – The vertex attributes for which textures should be generated.

  • margin (float) – The margin in pixels. The recommended value is 2. The margin are additional pixels around the UV islands to avoid discontinuities.

  • fill (float) – The value used for filling texels outside the UV islands.

  • update_material (bool) – If true updates the material of the mesh. Baking a vertex attribute with the name ‘albedo’ will become the albedo texture in the material. Existing textures in the material will be overwritten.

Returns:

A dictionary of tensors that store the baked textures.

Example

We generate a texture visualizing the index of the triangle to which the texel belongs to:

import open3d as o3d
from matplotlib import pyplot as plt

box = o3d.geometry.TriangleMesh.create_box(create_uv_map=True)
box = o3d.t.geometry.TriangleMesh.from_legacy(box)
# Creates a triangle attribute 'albedo' which is the triangle index
# multiplied by (255//12).
box.triangle['albedo'] = (255//12)*np.arange(box.triangle.indices.shape[0], dtype=np.uint8)

# Initialize material and bake the 'albedo' triangle attribute to a
# texture. The texture will be automatically added to the material of
# the object.
box.material.set_default_properties()
texture_tensors = box.bake_triangle_attr_textures(128, {'albedo'})

# Shows the textured cube.
o3d.visualization.draw([box])

# Plot the tensor with the texture.
plt.imshow(texture_tensors['albedo'].numpy())
bake_vertex_attr_textures(self: open3d.cpu.pybind.t.geometry.TriangleMesh, size: int, vertex_attr: Set[str], margin: float = 2.0, fill: float = 0.0, update_material: bool = True) Dict[str, open3d.cpu.pybind.core.Tensor]#

Bake vertex attributes into textures.

This function assumes a triangle attribute with name ‘texture_uvs’. Only float type attributes can be baked to textures.

This function always uses the CPU device.

Parameters:
  • size (int) – The width and height of the texture in pixels. Only square textures are supported.

  • vertex_attr (set) – The vertex attributes for which textures should be generated.

  • margin (float) – The margin in pixels. The recommended value is 2. The margin are additional pixels around the UV islands to avoid discontinuities.

  • fill (float) – The value used for filling texels outside the UV islands.

  • update_material (bool) – If true updates the material of the mesh. Baking a vertex attribute with the name ‘albedo’ will become the albedo texture in the material. Existing textures in the material will be overwritten.

Returns:

A dictionary of tensors that store the baked textures.

Example

We generate a texture storing the xyz coordinates for each texel:

import open3d as o3d
from matplotlib import pyplot as plt

box = o3d.geometry.TriangleMesh.create_box(create_uv_map=True)
box = o3d.t.geometry.TriangleMesh.from_legacy(box)
box.vertex['albedo'] = box.vertex.positions

# Initialize material and bake the 'albedo' vertex attribute to a
# texture. The texture will be automatically added to the material of
# the object.
box.material.set_default_properties()
texture_tensors = box.bake_vertex_attr_textures(128, {'albedo'})

# Shows the textured cube.
o3d.visualization.draw([box])

# Plot the tensor with the texture.
plt.imshow(texture_tensors['albedo'].numpy())
boolean_difference(self: open3d.cpu.pybind.t.geometry.TriangleMesh, mesh: open3d.cpu.pybind.t.geometry.TriangleMesh, tolerance: float = 1e-06) open3d.cpu.pybind.t.geometry.TriangleMesh#

Computes the mesh that encompasses the volume after subtracting the volume of the second operand. Both meshes should be manifold.

This function always uses the CPU device.

Parameters:
  • mesh (open3d.t.geometry.TriangleMesh) – This is the second operand for the boolean operation.

  • tolerance (float) – Threshold which determines when point distances are considered to be 0.

Returns:

The mesh describing the difference volume.

Example

This subtracts the sphere from the cube volume:

box = o3d.geometry.TriangleMesh.create_box()
box = o3d.t.geometry.TriangleMesh.from_legacy(box)
sphere = o3d.geometry.TriangleMesh.create_sphere(0.8)
sphere = o3d.t.geometry.TriangleMesh.from_legacy(sphere)

ans = box.boolean_difference(sphere)

o3d.visualization.draw([{'name': 'difference', 'geometry': ans}])
boolean_intersection(self: open3d.cpu.pybind.t.geometry.TriangleMesh, mesh: open3d.cpu.pybind.t.geometry.TriangleMesh, tolerance: float = 1e-06) open3d.cpu.pybind.t.geometry.TriangleMesh#

Computes the mesh that encompasses the intersection of the volumes of two meshes. Both meshes should be manifold.

This function always uses the CPU device.

Parameters:
  • mesh (open3d.t.geometry.TriangleMesh) – This is the second operand for the boolean operation.

  • tolerance (float) – Threshold which determines when point distances are considered to be 0.

Returns:

The mesh describing the intersection volume.

Example

This copmutes the intersection of a sphere and a cube:

box = o3d.geometry.TriangleMesh.create_box()
box = o3d.t.geometry.TriangleMesh.from_legacy(box)
sphere = o3d.geometry.TriangleMesh.create_sphere(0.8)
sphere = o3d.t.geometry.TriangleMesh.from_legacy(sphere)

ans = box.boolean_intersection(sphere)

o3d.visualization.draw([{'name': 'intersection', 'geometry': ans}])
boolean_union(self: open3d.cpu.pybind.t.geometry.TriangleMesh, mesh: open3d.cpu.pybind.t.geometry.TriangleMesh, tolerance: float = 1e-06) open3d.cpu.pybind.t.geometry.TriangleMesh#

Computes the mesh that encompasses the union of the volumes of two meshes. Both meshes should be manifold.

This function always uses the CPU device.

Parameters:
  • mesh (open3d.t.geometry.TriangleMesh) – This is the second operand for the boolean operation.

  • tolerance (float) – Threshold which determines when point distances are considered to be 0.

Returns:

The mesh describing the union volume.

Example

This copmutes the union of a sphere and a cube:

box = o3d.geometry.TriangleMesh.create_box()
box = o3d.t.geometry.TriangleMesh.from_legacy(box)
sphere = o3d.geometry.TriangleMesh.create_sphere(0.8)
sphere = o3d.t.geometry.TriangleMesh.from_legacy(sphere)

ans = box.boolean_union(sphere)

o3d.visualization.draw([{'name': 'union', 'geometry': ans}])
clear(self)#

Clear all elements in the geometry.

Returns:

open3d.t.geometry.Geometry

clip_plane(self: open3d.cpu.pybind.t.geometry.TriangleMesh, point: open3d.cpu.pybind.core.Tensor, normal: open3d.cpu.pybind.core.Tensor) open3d.cpu.pybind.t.geometry.TriangleMesh#

Returns a new triangle mesh clipped with the plane.

This method clips the triangle mesh with the specified plane. Parts of the mesh on the positive side of the plane will be kept and triangles intersected by the plane will be cut.

Parameters:
  • point (open3d.core.Tensor) – A point on the plane.

  • normal (open3d.core.Tensor) – The normal of the plane. The normal points to the positive side of the plane for which the geometry will be kept.

Returns:

New triangle mesh clipped with the plane.

This example shows how to create a hemisphere from a sphere:

import open3d as o3d

sphere = o3d.t.geometry.TriangleMesh.from_legacy(o3d.geometry.TriangleMesh.create_sphere())
hemisphere = sphere.clip_plane(point=[0,0,0], normal=[1,0,0])

o3d.visualization.draw(hemisphere)
clone(self: open3d.cpu.pybind.t.geometry.TriangleMesh) open3d.cpu.pybind.t.geometry.TriangleMesh#

Returns copy of the triangle mesh on the same device.

compute_convex_hull(self: open3d.cpu.pybind.t.geometry.TriangleMesh, joggle_inputs: bool = False) open3d.cpu.pybind.t.geometry.TriangleMesh#

Compute the convex hull of a point cloud using qhull. This runs on the CPU.

Parameters:

joggle_inputs (bool with default False) – Handle precision problems by randomly perturbing the input data. Set to True if perturbing the input iis acceptable but you need convex simplicial output. If False, neighboring facets may be merged in case of precision problems. See `QHull docs <http://www.qhull.org/html/qh-impre.htm#joggle`__ for more details.

Returns:

TriangleMesh representing the convexh hull. This contains an extra vertex property “point_indices” that contains the index of the corresponding vertex in the original mesh.

Example

We will load the Stanford Bunny dataset, compute and display it’s convex hull:

bunny = o3d.data.BunnyMesh()
mesh = o3d.t.geometry.TriangleMesh.from_legacy(o3d.io.read_triangle_mesh(bunny.path))
hull = mesh.compute_convex_hull()
o3d.visualization.draw([{'name': 'bunny', 'geometry': mesh}, {'name': 'convex hull', 'geometry': hull}])
compute_triangle_normals(self: open3d.cpu.pybind.t.geometry.TriangleMesh, normalized: bool = True) open3d.cpu.pybind.t.geometry.TriangleMesh#

Function to compute triangle normals, usually called before rendering.

compute_uvatlas(self: open3d.cpu.pybind.t.geometry.TriangleMesh, size: int = 512, gutter: float = 1.0, max_stretch: float = 0.1666666716337204, parallel_partitions: int = 1, nthreads: int = 0) Tuple[float, int, int]#

Creates an UV atlas and adds it as triangle attr ‘texture_uvs’ to the mesh.

Input meshes must be manifold for this method to work. The algorithm is based on: Zhou et al, “Iso-charts: Stretch-driven Mesh Parameterization using Spectral

Analysis”, Eurographics Symposium on Geometry Processing (2004)

Sander et al. “Signal-Specialized Parametrization” Europgraphics 2002 This function always uses the CPU device.

Parameters:
  • size (int) – The target size of the texture (size x size). The uv coordinates will still be in the range [0..1] but parameters like gutter use pixels as units.

  • gutter (float) – This is the space around the uv islands in pixels.

  • max_stretch (float) – The maximum amount of stretching allowed. The parameter range is [0..1] with 0 meaning no stretch allowed.

  • parallel_partitions (int) – The approximate number of partitions created before computing the UV atlas for parallelizing the computation. Parallelization can be enabled with values > 1. Note that parallelization increases the number of UV islands and can lead to results with lower quality.

  • nthreads (int) – The number of threads used when parallel_partitions is > 1. Set to 0 for automatic number of thread detection.

Returns:

This function creates a face attribute “texture_uvs” and returns a tuple with (max stretch, num_charts, num_partitions) storing the actual amount of stretch, the number of created charts, and the number of parallel partitions created.

Example

This code creates a uv map for the Stanford Bunny mesh:

import open3d as o3d
bunny = o3d.data.BunnyMesh()
mesh = o3d.t.geometry.TriangleMesh.from_legacy(o3d.io.read_triangle_mesh(bunny.path))
mesh.compute_uvatlas()

# Add a wood texture and visualize
texture_data = o3d.data.WoodTexture()
mesh.material.material_name = 'defaultLit'
mesh.material.texture_maps['albedo'] = o3d.t.io.read_image(texture_data.albedo_texture_path)
o3d.visualization.draw(mesh)
compute_vertex_normals(self: open3d.cpu.pybind.t.geometry.TriangleMesh, normalized: bool = True) open3d.cpu.pybind.t.geometry.TriangleMesh#

Function to compute vertex normals, usually called before rendering.

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.

static create_arrow(cylinder_radius=1.0, cone_radius=1.5, cylinder_height=5.0, cone_height=4.0, resolution=20, cylinder_split=4, cone_split=1, float_dtype=Float32, int_dtype=Int64, device=CPU:0)#

Create a arrow mesh.

Parameters:
  • cylinder_radius (float, optional, default=1.0) – The radius of the cylinder.

  • cone_radius (float, optional, default=1.5) – The radius of the cone.

  • cylinder_height (float, optional, default=5.0) – The height of the cylinder. The cylinder is from (0, 0, 0) to (0, 0, cylinder_height)

  • cone_height (float, optional, default=4.0) – The height of the cone. The axis of the cone will be from (0, 0, cylinder_height) to (0, 0, cylinder_height + cone_height)

  • resolution (int, optional, default=20) – The cone will be split into resolution segments.

  • cylinder_split (int, optional, default=4) – The cylinder_height will be split into cylinder_split segments.

  • cone_split (int, optional, default=1) – The cone_height will be split into cone_split segments.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create octahedron.

  • optional – 0): Device of the create octahedron.

  • default=CPU – 0): Device of the create octahedron.

Returns:

open3d.t.geometry.TriangleMesh

static create_box(height=1.0, depth=1.0, float_dtype=Float32, int_dtype=Int64, device=CPU:0)#
Parameters:
  • height (float, optional, default=1.0) – y-directional length.

  • depth (float, optional, default=1.0) – z-directional length.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create mesh.

  • optional – 0): Device of the create mesh.

  • default=CPU – 0): Device of the create mesh.

Returns:

open3d.t.geometry.TriangleMesh

static create_cone(radius=1.0, height=2.0, resolution=20, split=1, float_dtype=Float32, int_dtype=Int64, device=CPU:0)#

Create a cone mesh.

Parameters:
  • radius (float, optional, default=1.0) – The radius of the cone.

  • height (float, optional, default=2.0) – The height of the cone. The axis of the cone will be from (0, 0, 0) to (0, 0, height).

  • resolution (int, optional, default=20) – The circle will be split into resolution segments

  • split (int, optional, default=1) – The height will be split into split segments.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create octahedron.

  • optional – 0): Device of the create octahedron.

  • default=CPU – 0): Device of the create octahedron.

Returns:

open3d.t.geometry.TriangleMesh

static create_coordinate_frame(size=1.0, origin=array([0., 0., 0.]), float_dtype=Float32, int_dtype=Int64, device=CPU:0)#

Create a coordinate frame mesh.

Parameters:
  • size (float, optional, default=1.0) – The size of the coordinate frame.

  • origin (numpy.ndarray[numpy.float64[3, 1]], optional, default=array([0., 0., 0.])) – The origin of the coordinate frame.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create octahedron.

  • optional – 0): Device of the create octahedron.

  • default=CPU – 0): Device of the create octahedron.

Returns:

open3d.t.geometry.TriangleMesh

static create_cylinder(radius=1.0, height=2.0, resolution=20, split=4, float_dtype=Float32, int_dtype=Int64, device=CPU:0)#

Create a cylinder mesh.

Parameters:
  • radius (float, optional, default=1.0) – The radius of the cylinder.

  • height (float, optional, default=2.0) – The height of the cylinder.The axis of the cylinder will be from (0, 0, -height/2) to (0, 0, height/2).

  • resolution (int, optional, default=20) – The circle will be split into resolution segments

  • split (int, optional, default=4) – The height will be split into split segments.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create octahedron.

  • optional – 0): Device of the create octahedron.

  • default=CPU – 0): Device of the create octahedron.

Returns:

open3d.t.geometry.TriangleMesh

static create_icosahedron(radius=1.0, float_dtype=Float32, int_dtype=Int64, device=CPU:0)#

Create a icosahedron mesh centered at (0, 0, 0).

Parameters:
  • radius (float, optional, default=1.0) – Distance from centroid to mesh vetices.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create octahedron.

  • optional – 0): Device of the create octahedron.

  • default=CPU – 0): Device of the create octahedron.

Returns:

open3d.t.geometry.TriangleMesh

static create_mobius(length_split=70, width_split=15, twists=1, raidus=1, flatness=1, width=1, scale=1, float_dtype=Float32, int_dtype=Int64, device=CPU:0)#

Create a Mobius strip.

Parameters:
  • length_split (int, optional, default=70) – The number of segments along the Mobius strip.

  • width_split (int, optional, default=15) – The number of segments along the width of the Mobius strip.

  • twists (int, optional, default=1) – Number of twists of the Mobius strip.

  • raidus (float, optional, default=1) –

  • flatness (float, optional, default=1) – Controls the flatness/height of the Mobius strip.

  • width (float, optional, default=1) – Width of the Mobius strip.

  • scale (float, optional, default=1) – Scale the complete Mobius strip.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create octahedron.

  • optional – 0): Device of the create octahedron.

  • default=CPU – 0): Device of the create octahedron.

Returns:

open3d.t.geometry.TriangleMesh

static create_octahedron(radius=1.0, float_dtype=Float32, int_dtype=Int64, device=CPU:0)#

Create a octahedron mesh centered at (0, 0, 0).

Parameters:
  • radius (float, optional, default=1.0) – Distance from centroid to mesh vetices.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create octahedron.

  • optional – 0): Device of the create octahedron.

  • default=CPU – 0): Device of the create octahedron.

Returns:

open3d.t.geometry.TriangleMesh

static create_sphere(radius=1.0, resolution=20, float_dtype=Float32, int_dtype=Int64, device=CPU:0)#

Create a sphere mesh centered at (0, 0, 0).

Parameters:
  • radius (float, optional, default=1.0) – The radius of the sphere.

  • resolution (int, optional, default=20) – The resolution of the sphere.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create sphere.

  • optional – 0): Device of the create sphere.

  • default=CPU – 0): Device of the create sphere.

Returns:

open3d.t.geometry.TriangleMesh

static create_tetrahedron(radius=1.0, float_dtype=Float32, int_dtype=Int64, device=CPU:0)#

Create a tetrahedron mesh centered at (0, 0, 0).

Parameters:
  • radius (float, optional, default=1.0) – Distance from centroid to mesh vetices.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create tetrahedron.

  • optional – 0): Device of the create tetrahedron.

  • default=CPU – 0): Device of the create tetrahedron.

Returns:

open3d.t.geometry.TriangleMesh

static create_text(text: str, depth: float = 0.0, float_dtype: open3d.cpu.pybind.core.Dtype = Float32, int_dtype: open3d.cpu.pybind.core.Dtype = Int64, device: open3d.cpu.pybind.core.Device = CPU:0) open3d.cpu.pybind.t.geometry.TriangleMesh#

Create a triangle mesh from a text string.

Parameters:
  • text (str) – The text for generating the mesh. ASCII characters 32-126 are supported (includes alphanumeric characters and punctuation). In addition the line feed ‘n’ is supported to start a new line.

  • depth (float) – The depth of the generated mesh. If depth is 0 then a flat mesh will be generated.

  • float_dtype (o3d.core.Dtype) – Float type for the vertices. Either Float32 or Float64.

  • int_dtype (o3d.core.Dtype) – Int type for the triangle indices. Either Int32 or Int64.

  • device (o3d.core.Device) – The device for the returned mesh.

Returns:

Text as triangle mesh.

Example

This shows how to simplifify the Stanford Bunny mesh:

import open3d as o3d

mesh = o3d.t.geometry.TriangleMesh.create_text('Open3D', depth=1)
o3d.visualization.draw([{'name': 'text', 'geometry': mesh}])
static create_torus(torus_radius=1.0, tube_radius=0.5, radial_resolution=30, tubular_resolution=20, float_dtype=Float32, int_dtype=Int64, device=CPU:0)#

Create a torus mesh.

Parameters:
  • torus_radius (float, optional, default=1.0) – The radius from the center of the torus to the center of the tube.

  • tube_radius (float, optional, default=0.5) – The radius of the torus tube.

  • radial_resolution (int, optional, default=30) – The number of segments along the radial direction.

  • tubular_resolution (int, optional, default=20) – The number of segments along the tubular direction.

  • float_dtype (open3d.core.Dtype, optional, default=Float32) – Float_dtype, Float32 or Float64.

  • int_dtype (open3d.core.Dtype, optional, default=Int64) – Int_dtype, Int32 or Int64.

  • (open3d.core.Device (device) – 0): Device of the create octahedron.

  • optional – 0): Device of the create octahedron.

  • default=CPU – 0): Device of the create octahedron.

Returns:

open3d.t.geometry.TriangleMesh

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.

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

Sweeps the line set along a direction vector. :param vector: The direction vector. :type vector: open3d.core.Tensor :param scale: Scalar factor which essentially scales the direction vector. :type scale: float

Returns:

A triangle mesh with the result of the sweep operation.

Example

This code generates a wedge from a triangle:

import open3d as o3d
triangle = o3d.t.geometry.TriangleMesh([[1.0,1.0,0.0], [0,1,0], [1,0,0]], [[0,1,2]])
wedge = triangle.extrude_linear([0,0,1])
o3d.visualization.draw([{'name': 'wedge', 'geometry': wedge}])
extrude_rotation(self: open3d.cpu.pybind.t.geometry.TriangleMesh, angle: float, axis: open3d.cpu.pybind.core.Tensor, resolution: int = 16, translation: float = 0.0, capping: bool = True) open3d.cpu.pybind.t.geometry.TriangleMesh#

Sweeps the triangle mesh rotationally about an axis. :param angle: The rotation angle in degree. :type angle: float :param axis: The rotation axis. :type axis: open3d.core.Tensor :param resolution: The resolution defines the number of intermediate sweeps

about the rotation axis.

Parameters:

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 with a triangle cross-section:

import open3d as o3d

mesh = o3d.t.geometry.TriangleMesh([[1,1,0], [0.7,1,0], [1,0.7,0]], [[0,1,2]])
spring = mesh.extrude_rotation(3*360, [0,1,0], resolution=3*16, translation=2)
o3d.visualization.draw([{'name': 'spring', 'geometry': spring}])
fill_holes(self: open3d.cpu.pybind.t.geometry.TriangleMesh, hole_size: float = 1000000.0) open3d.cpu.pybind.t.geometry.TriangleMesh#

Fill holes by triangulating boundary edges.

This function always uses the CPU device.

Parameters:

hole_size (float) – This is the approximate threshold for filling holes. The value describes the maximum radius of holes to be filled.

Returns:

New mesh after filling holes.

Example

Fill holes at the bottom of the Stanford Bunny mesh:

bunny = o3d.data.BunnyMesh()
mesh = o3d.t.geometry.TriangleMesh.from_legacy(o3d.io.read_triangle_mesh(bunny.path))
filled = mesh.fill_holes()
o3d.visualization.draw([{'name': 'filled', 'geometry': ans}])
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.

static from_triangle_mesh_model(model: open3d::visualization::rendering::TriangleMeshModel, vertex_dtype: open3d.cpu.pybind.core.Dtype = Float32, triangle_dtype: open3d.cpu.pybind.core.Dtype = Int64, device: open3d.cpu.pybind.core.Device = CPU:0) Dict[str, open3d.cpu.pybind.t.geometry.TriangleMesh]#

Convert a TriangleMeshModel (e.g. as read from a file with open3d.io.read_triangle_mesh_model()) to a dictionary of mesh names to triangle meshes with the specified vertex and triangle dtypes and moved to the specified device. Only a single material per mesh is supported. Materials common to multiple meshes will be duplicated. Textures (as t.geometry.Image) will use shared storage on the CPU (GPU resident images for textures is not yet supported).

Returns:

Dictionary of names to triangle meshes.

Example

flight_helmet = o3d.data.FlightHelmetModel() model = o3d.io.read_triangle_model(flight_helmet.path) mesh_dict = o3d.t.geometry.TriangleMesh.from_triangle_mesh_model(model) o3d.visualization.draw(list({“name”: name, “geometry”: tmesh} for

(name, tmesh) in mesh_dict.items()))

get_axis_aligned_bounding_box(self: open3d.cpu.pybind.t.geometry.TriangleMesh) open3d::t::geometry::AxisAlignedBoundingBox#

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

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.

get_oriented_bounding_box(self: open3d.cpu.pybind.t.geometry.TriangleMesh) open3d::t::geometry::OrientedBoundingBox#

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

get_surface_area(self: open3d.cpu.pybind.t.geometry.TriangleMesh) float#

Computes the surface area of the mesh, i.e., the sum of the individual triangle surfaces.

Example

This computes the surface area of the Stanford Bunny::

bunny = o3d.data.BunnyMesh() mesh = o3d.t.io.read_triangle_mesh(bunny.path) print(‘The surface area is’, mesh.get_surface_area())

Returns:

A scalar describing the surface area of the mesh.

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

normalize_normals(self: open3d.cpu.pybind.t.geometry.TriangleMesh) open3d.cpu.pybind.t.geometry.TriangleMesh#

Normalize both triangle normals and vertex normals to length 1.

pca_partition(self: open3d.cpu.pybind.t.geometry.TriangleMesh, max_faces: int) int#

Partition the mesh by recursively doing PCA.

This function creates a new face attribute with the name “partition_ids” storing the partition id for each face.

Parameters:

max_faces (int) – The maximum allowed number of faces in a partition.

Example

This code partitions a mesh such that each partition contains at most 20k faces:

import open3d as o3d
import numpy as np
bunny = o3d.data.BunnyMesh()
mesh = o3d.t.geometry.TriangleMesh.from_legacy(o3d.io.read_triangle_mesh(bunny.path))
num_partitions = mesh.pca_partition(max_faces=20000)

# print the partition ids and the number of faces for each of them.
print(np.unique(mesh.triangle.partition_ids.numpy(), return_counts=True))
remove_unreferenced_vertices(self: open3d.cpu.pybind.t.geometry.TriangleMesh) open3d.cpu.pybind.t.geometry.TriangleMesh#

Removes unreferenced vertices from the mesh in-place.

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.

select_by_index(self: open3d.cpu.pybind.t.geometry.TriangleMesh, indices: open3d.cpu.pybind.core.Tensor) open3d.cpu.pybind.t.geometry.TriangleMesh#

Returns a new mesh with the vertices selected according to the indices list. If an item from the indices list exceeds the max vertex number of the mesh or has a negative value, it is ignored.

Parameters:
  • indices (open3d.core.Tensor) – An integer list of indices. Duplicates are

  • allowed

  • accepted. (but ignored. Signed and unsigned integral types are) –

Returns:

A new mesh with the selected vertices and faces built from these vertices. If the original mesh is empty, return an empty mesh.

Example

This code selects the top face of a box, which has indices [2, 3, 6, 7]:

import open3d as o3d
import numpy as np
box = o3d.t.geometry.TriangleMesh.create_box()
top_face = box.select_by_index([2, 3, 6, 7])
select_faces_by_mask(self: open3d.cpu.pybind.t.geometry.TriangleMesh, mask: open3d.cpu.pybind.core.Tensor) open3d.cpu.pybind.t.geometry.TriangleMesh#

Returns a new mesh with the faces selected by a boolean mask.

Parameters:

mask (open3d.core.Tensor) – A boolean mask with the shape (N) with N as the number of faces in the mesh.

Returns:

A new mesh with the selected faces. If the original mesh is empty, return an empty mesh.

Example

This code partitions the mesh using PCA and then visualized the individual parts:

import open3d as o3d
import numpy as np
bunny = o3d.data.BunnyMesh()
mesh = o3d.t.geometry.TriangleMesh.from_legacy(o3d.io.read_triangle_mesh(bunny.path))
num_partitions = mesh.pca_partition(max_faces=20000)

parts = []
for i in range(num_partitions):
    mask = mesh.triangle.partition_ids == i
    part = mesh.select_faces_by_mask(mask)
    part.vertex.colors = np.tile(np.random.rand(3), (part.vertex.positions.shape[0],1))
    parts.append(part)

o3d.visualization.draw(parts)
simplify_quadric_decimation(self: open3d.cpu.pybind.t.geometry.TriangleMesh, target_reduction: float, preserve_volume: bool = True) open3d.cpu.pybind.t.geometry.TriangleMesh#

Function to simplify mesh using Quadric Error Metric Decimation by Garland and Heckbert.

This function always uses the CPU device.

Parameters:
  • target_reduction (float) – The factor of triangles to delete, i.e., setting this to 0.9 will return a mesh with about 10% of the original triangle count. It is not guaranteed that the target reduction factor will be reached.

  • preserve_volume (bool) – If set to True this enables volume preservation which reduces the error in triangle normal direction.

Returns:

Simplified TriangleMesh.

Example

This shows how to simplifify the Stanford Bunny mesh:

bunny = o3d.data.BunnyMesh()
mesh = o3d.t.geometry.TriangleMesh.from_legacy(o3d.io.read_triangle_mesh(bunny.path))
simplified = mesh.simplify_quadric_decimation(0.99)
o3d.visualization.draw([{'name': 'bunny', 'geometry': simplified}])
slice_plane(self: open3d.cpu.pybind.t.geometry.TriangleMesh, point: open3d.cpu.pybind.core.Tensor, normal: open3d.cpu.pybind.core.Tensor, contour_values: List[float] = [0.0]) open3d.cpu.pybind.t.geometry.LineSet#

Returns a line set with the contour slices defined by the plane and values.

This method generates slices as LineSet from the mesh at specific contour values with respect to a plane.

Parameters:
  • point (open3d.core.Tensor) – A point on the plane.

  • normal (open3d.core.Tensor) – The normal of the plane.

  • contour_values (list) – A list of contour values at which slices will be generated. The value describes the signed distance to the plane.

Returns:

LineSet with he extracted contours.

This example shows how to create a hemisphere from a sphere:

import open3d as o3d
import numpy as np

bunny = o3d.data.BunnyMesh()
mesh = o3d.t.geometry.TriangleMesh.from_legacy(o3d.io.read_triangle_mesh(bunny.path))
contours = mesh.slice_plane([0,0,0], [0,1,0], np.linspace(0,0.2))
o3d.visualization.draw([{'name': 'bunny', 'geometry': contours}])
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.

to_mitsuba(name, bsdf=None)#

Convert Open3D TriangleMesh to Mitsuba Mesh.

Converts an Open3D TriangleMesh to a Mitsuba Mesh which can be used directly in a Mitsbua scene. The TriangleMesh’s material will be converted to a Mitsuba Principled BSDF and assigned to the Mitsuba Mesh. Optionally, the user may provide a Mitsuba BSDF to be used instead of converting the Open3D material.

Parameters:
  • name (str) – Name for the Mitsuba Mesh. Used by Mitsuba as an identifier

  • bsdf (default None) – If a Mitsuba BSDF is supplied it will be used as

  • Otherwise (the BSDF for the converted mesh.) –

  • material (the TriangleMesh's) –

  • BSDF. (will be converted to Mitsuba Principled) –

Returns:

A Mitsuba Mesh (with associated BSDF) ready for use in a Mitsuba scene.

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 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 material#
property triangle#
property vertex#