trimesh.smoothing module

trimesh.smoothing.dilate_slope(vertices, faces, normals, v, eps)

Get de derivate of dilation scalar by the volume variation by finite differences Thus, Vertices += vertex_normals*dilate_slope*(Initial_Volume - Srinked_Volume) Parameters

meshtrimesh.Trimesh

Input geometry

vertices: mesh.vertices faces: mesh.faces normals: array

vertices normals

dilate_slope: float

derivative

trimesh.smoothing.filter_humphrey(mesh, alpha=0.1, beta=0.5, iterations=10, laplacian_operator=None)

Smooth a mesh in-place using laplacian smoothing and Humphrey filtering. Articles “Improved Laplacian Smoothing of Noisy Surface Meshes” J. Vollmer, R. Mencl, and H. Muller :param mesh: Mesh to be smoothed in place :type mesh: trimesh.Trimesh :param alpha: Controls shrinkage, range is 0.0 - 1.0

If 0.0, not considered If 1.0, no smoothing

Parameters:
  • beta (float) – Controls how aggressive smoothing is If 0.0, no smoothing If 1.0, full aggressiveness

  • iterations (int) – Number of passes to run filter

  • laplacian_operator (None or scipy.sparse.coo.coo_matrix) – Sparse matrix laplacian operator Will be autogenerated if None

trimesh.smoothing.filter_laplacian(mesh, lamb=0.5, iterations=10, implicit_time_integration=False, volume_constraint=True, laplacian_operator=None)

Smooth a mesh in-place using laplacian smoothing. Articles 1 - “Improved Laplacian Smoothing of Noisy Surface Meshes”

  1. Vollmer, R. Mencl, and H. Muller

2 - “Implicit Fairing of Irregular Meshes using Diffusion

and Curvature Flow”. M. Desbrun, M. Meyer, P. Schroder, A.H.B. Caltech

Parameters:
  • mesh (trimesh.Trimesh)

  • place (Mesh to be smoothed in)

  • lamb (float)

  • constant (Diffusion speed)

  • 0.0 (If >)

  • diffusion (no)

  • 0.0

  • occurs (diffusion)

  • implicit_time_integration (boolean)

  • False (if) – -lamb <= 1.0 - Stability Limit (Article 1)

  • True (if) – -lamb no limit (Article 2)

  • iterations (int)

  • filter (Number of passes to run)

  • laplacian_operator (None or scipy.sparse.coo.coo_matrix)

  • operator (Sparse matrix laplacian)

  • None (Will be autogenerated if)

trimesh.smoothing.filter_mut_dif_laplacian(mesh, lamb=0.5, iterations=10, volume_constraint=True, laplacian_operator=None)

Smooth a mesh in-place using laplacian smoothing using a mutable diffusion laplacian.

Articles

Barroqueiro, B., Andrade-Campos, A., Dias-de-Oliveira, J., and Valente, R. (January 21, 2021). “Bridging between topology optimization and additive

manufacturing via Laplacian smoothing.” ASME. J. Mech. Des.

Parameters:
  • mesh (trimesh.Trimesh) – Mesh to be smoothed in place

  • lamb (float) – Diffusion speed constant If 0.0, no diffusion If > 0.0, diffusion occurs

  • iterations (int) – Number of passes to run filter

  • laplacian_operator (None or scipy.sparse.coo.coo_matrix) – Sparse matrix laplacian operator Will be autogenerated if None

trimesh.smoothing.filter_taubin(mesh, lamb=0.5, nu=0.5, iterations=10, laplacian_operator=None)

Smooth a mesh in-place using laplacian smoothing and taubin filtering. Articles “Improved Laplacian Smoothing of Noisy Surface Meshes” J. Vollmer, R. Mencl, and H. Muller :param mesh: Mesh to be smoothed in place. :type mesh: trimesh.Trimesh :param lamb: Controls shrinkage, range is 0.0 - 1.0 :type lamb: float :param nu: Controls dilation, range is 0.0 - 1.0

Nu shall be between 0.0 < 1.0/lambda - 1.0/nu < 0.1

Parameters:
  • iterations (int) – Number of passes to run the filter

  • laplacian_operator (None or scipy.sparse.coo.coo_matrix) – Sparse matrix laplacian operator Will be autogenerated if None

trimesh.smoothing.get_vertices_normals(mesh)

Compute Vertex normals using equal weighting of neighbors faces. Parameters

meshtrimesh.Trimesh

Input geometry

vertices_normals: array

Vertices normals

trimesh.smoothing.laplacian_calculation(mesh, equal_weight=True, pinned_vertices=None)

Calculate a sparse matrix for laplacian operations. :param mesh: Input geometry :type mesh: trimesh.Trimesh :param equal_weight: If True, all neighbors will be considered equally

If False, all neighbors will be weighted by inverse distance

Returns:

laplacian – Laplacian operator

Return type:

scipy.sparse.coo.coo_matrix