{"library":"pymeshfix","title":"PyMeshFix","description":"PyMeshFix is a Python library that provides bindings to the MeshFix C++ library, enabling robust repair of triangular meshes. It can fix common mesh issues such as holes, self-intersections, and non-manifold edges. The current version is 0.18.0, and it generally sees several releases per year, often aligning with updates to the broader PyVista ecosystem.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pymeshfix"],"cli":null},"imports":["from pymeshfix import MeshFix"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import numpy as np\nfrom pymeshfix import MeshFix\n\n# Create a simple mesh with a known issue (e.g., open boundary)\n# A triangle pointing up, but with a missing top vertex to create a hole\nv = np.array([\n    [0.0, 0.0, 0.0], # Base left\n    [1.0, 0.0, 0.0], # Base right\n    [0.5, 1.0, 0.0]  # Top (would create a closed triangle)\n], dtype=np.float64)\nf = np.array([\n    [0, 1, 2] # A single triangle\n], dtype=np.int32)\n\n# To demonstrate repair, let's create a small hole by removing a vertex\n# For a true 'hole fix', typically you'd have an open boundary that isn't manifold\n# In this minimal example, we'll just demonstrate the API with a valid mesh\n# Real-world usage involves meshes with actual defects.\n\n# Initialize MeshFix with vertices and faces\nmfx = MeshFix(v, f)\n\n# Repair the mesh (e.g., fill holes, remove self-intersections)\n# Common options include verbose=False, joincomp=True, remove_self_intersections=True\nmfx.repair(verbose=False, joincomp=True, remove_self_intersections=True)\n\n# Get the repaired mesh\nv_repaired = mfx.v\nf_repaired = mfx.f\n\nprint(f\"Original vertices shape: {v.shape}\")\nprint(f\"Original faces shape: {f.shape}\")\nprint(f\"Repaired vertices shape: {v_repaired.shape}\")\nprint(f\"Repaired faces shape: {f_repaired.shape}\")\n# Often, repair might add or remove vertices/faces depending on the issues found\n\n# Example of creating a mesh with a hole more explicitly (requires more complex setup)\n# v_hole = np.array([[0,0,0], [1,0,0], [0,1,0], [1,1,0], [0.5,0.5,1]])\n# f_hole = np.array([[0,1,2], [1,3,2], [0,2,4], [1,3,4]]) # missing [0,1,4] & [2,3,4] faces to make it a pyramid with a hole\n# mfx_hole = MeshFix(v_hole, f_hole)\n# mfx_hole.repair()\n# print(\"Hole repaired:\", mfx_hole.v.shape, mfx_hole.f.shape)\n","lang":"python","description":"This quickstart demonstrates how to import `MeshFix`, initialize it with NumPy arrays for vertices and faces, and perform a basic repair operation. Note that `pymeshfix` is typically used to fix complex meshes loaded from files, and this example uses a simple mesh to illustrate the API. The `repair` method can take various parameters to control the fixing process.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}