mesh.Mesh.fix_triangle_mesh#

Mesh.fix_triangle_mesh(remove_duplicate=True, remove_degenerate=True, fuse=True, compact=True, fix_normals=True, remove_non_manifold=True, fill_holes=True)#

Repair and clean a triangle mesh by performing a sequence fixes.

The method applies a configurable pipeline of mesh-repair operations to improve manifoldness, remove redundant or degenerate geometry, fill small gaps, and ensure consistent face normals. The returned mesh is typically better suited for numerical analysis or export. However, a final check with check_triangle_mesh() is recommended.

Parameters#

remove_duplicatebool

Remove duplicate faces. See remove_duplicate().

remove_degeneratebool

Remove zero-area or collapsed triangles. See remove_degenerate().

fusebool

Merge vertices that lie within a numerical tolerance of one another. See fuse()

compactbool, default=True

Remove unreferenced vertices and compact the connectivity arrays. See compact().

fix_normalsbool

Ensure consistent orientation of face normals.

remove_non_manifoldbool

Attempt to remove non-manifold edges.

fill_holesbool

Fill single triangle holes in the surface.

Returns#

Mesh

A repaired mesh with improved topology and geometry.

Notes#

A final check with check_triangle_mesh() is recommended. It can, for example, occur that non-manifold edges are re-introduced by the hole-filling step.

Examples#

>>> from hellotriangle import shapes
>>> sphere = shapes.sphere()
>>> sphere_with_hole = sphere.remove_selected([0])
>>> print(sphere_with_hole.check_triangle_mesh())
(True, True, False, 1, 2)
>>> sphere_fixed = sphere_with_hole.fix_triangle_mesh()
>>> print(sphere_fixed.check_triangle_mesh())
(True, True, True, 2, 2)