trimesh.comparison module

comparison.py

Provide methods for quickly hashing and comparing meshes.

Functions

face_ordering(mesh)

Triangles with three different length sides are

identifier_hash(identifier[, sigfig])

Hash an identifier array to a specified number of significant figures.

identifier_simple(mesh)

Return a basic identifier for a mesh, consisting of properties that have been hand tuned to be somewhat robust to rigid transformations and different tesselations.

trimesh.comparison.face_ordering(mesh)

Triangles with three different length sides are ordered in two ways: [small edge, medium edge, large edge] (SML) [small edge, large edge, medium edge] (SLM)

This function returns [-1, 0, 1], depending on whether the triangle is SML or SLM, and 0 if M == L.

The reason this is useful as it as a rare property that is invariant to translation and rotation but changes when a mesh is reflected or inverted. It is NOT invariant to different tesselations of the same surface.

Parameters

mesh (trimesh.Trimesh) – Source geometry to calculate ordering on

Returns

order – Is each face SML (-1), SLM (+1), or M==L (0)

Return type

(len(mesh.faces), ) int

trimesh.comparison.identifier_hash(identifier, sigfig=None)

Hash an identifier array to a specified number of significant figures.

Parameters
  • identifier ((n,) float) – Vector of properties

  • sigfig ((n,) int) – Number of sigfigs per property

Returns

md5 – MD5 hash of identifier

Return type

str

trimesh.comparison.identifier_simple(mesh)

Return a basic identifier for a mesh, consisting of properties that have been hand tuned to be somewhat robust to rigid transformations and different tesselations.

Parameters

mesh (Trimesh object) – Source geometry

Returns

identifier – Identifying values of the mesh

Return type

(6,) float