trimesh.repair module

repair.py

Fill holes and fix winding and normals of meshes.

Functions

broken_faces(mesh[, color])

Return the index of faces in the mesh which break the watertight status of the mesh.

fill_holes(mesh)

Fill single- triangle holes on triangular meshes by adding new triangles to fill the holes.

fix_inversion(mesh[, multibody])

Check to see if a mesh has normals pointing “out.”

fix_normals(mesh[, multibody])

Fix the winding and direction of a mesh face and face normals in-place.

fix_winding(mesh)

Traverse and change mesh faces in-place to make sure winding is correct, with edges on adjacent faces in opposite directions.

trimesh.repair.broken_faces(mesh, color=None)

Return the index of faces in the mesh which break the watertight status of the mesh.

Parameters
  • mesh (Trimesh object) –

  • color ((4,) uint8, will set broken faces to this color) – None, will not alter mesh colors

Returns

broken

Return type

(n, ) int, indexes of mesh.faces

trimesh.repair.fill_holes(mesh)

Fill single- triangle holes on triangular meshes by adding new triangles to fill the holes. New triangles will have proper winding and normals, and if face colors exist the color of the last face will be assigned to the new triangles.

Parameters

mesh (trimesh.Trimesh) – Mesh will be repaired in- place

trimesh.repair.fix_inversion(mesh, multibody=False)

Check to see if a mesh has normals pointing “out.”

Parameters
  • mesh (Trimesh object) –

  • multibody (bool, if True will try to fix normals on every body) –

  • Alters

  • -------------

  • mesh.face (may reverse faces) –

trimesh.repair.fix_normals(mesh, multibody=False)

Fix the winding and direction of a mesh face and face normals in-place.

Really only meaningful on watertight meshes but will orient all faces and winding in a uniform way for non-watertight face patches as well.

Parameters
  • mesh (trimesh.Trimesh) – Mesh to fix normals on

  • multibody (bool) – if True try to correct normals direction on every body rather than just one

  • Alters

  • --------------

  • mesh.faces – Will flip columns on inverted faces

trimesh.repair.fix_winding(mesh)

Traverse and change mesh faces in-place to make sure winding is correct, with edges on adjacent faces in opposite directions.

Parameters
  • mesh (Trimesh object) –

  • Alters

  • -------------

  • mesh.face (will reverse columns of certain faces) –