differt_core.geometry.TriangleMesh#

class TriangleMesh#

Bases: object

A lower-level mesh made of triangles.

This class should not be used directly, prefer its higher-level version differt.geometry.TriangleMesh instead.

Attributes

face_colors

The array of face colors.

face_materials

The array of face materials.

material_names

List of material names.

object_bounds

The array of object indices.

triangles

The array of triangle indices.

vertices

The array of triangle vertices.

Methods

append(other)

Move all the elements of other into self and update object_bounds.

load_obj(filename)

Load a triangle mesh from a Wavefront .obj file.

load_ply(filename)

Load a triangle mesh from a Stanford PLY .ply file.

Detailed documentation

append(other)#

Move all the elements of other into self and update object_bounds.

After calling this method, other will be empty.

Parameters:

other (TriangleMesh) – The mesh to be appended to self.

face_colors#

The array of face colors.

The array contains the face colors, as RGB triplets, with a black color used as defaults (if some faces have a color). This attribute is None if all face colors are unset.

Type:

Float[np.ndarray, 'num_vertices 3'] | None

face_materials#

The array of face materials.

The array contains the material indices, with a special placeholder value of -1. To obtain the name of the material, see material_names. This attribute is None if all face materials are unset.

Type:

Int[np.ndarray, 'num_vertices'] | None

classmethod load_obj(filename)#

Load a triangle mesh from a Wavefront .obj file.

Currently, only vertices and triangles are loaded. Triangle normals are ignored because they are computed with differt.geometry.TriangleMesh.normals using JAX so that they can be differentiated with respect to triangle vertices.

Parameters:

file (str) – The path to the Wavefront .obj file.

Returns:

The corresponding mesh containing only triangles.

Return type:

TriangleMesh

classmethod load_ply(filename)#

Load a triangle mesh from a Stanford PLY .ply file.

Currently, only vertices and triangles are loaded. Triangle normals are ignored because they are computed with differt.geometry.TriangleMesh.normals using JAX so that they can be differentiated with respect to triangle vertices.

Parameters:

file (str) – The path to the Stanford PLY .ply file.

Returns:

The corresponding mesh containing only triangles.

Return type:

TriangleMesh

material_names#

List of material names.

Type:

list[str]

object_bounds#

The array of object indices.

If the present mesh contains multiple objects, usually as a result of appending multiple meshes together, this array contains start and end indices for each sub mesh.

Type:

Int[np.ndarray, 'num_objects 2'] | None

triangles#

The array of triangle indices.

Type:

Int[np.ndarray, 'num_triangles 3']

vertices#

The array of triangle vertices.

Type:

Float[np.ndarray, 'num_vertices 3']