Skip to main content

Repair triangular meshes using MeshFix

Project description

Python/Cython wrapper of Marco Attene’s wonderful, award-winning MeshFix software. This module brings the speed of C++ with the portability and ease of installation of Python.

This software takes as input a polygon mesh and produces a copy of the input where all the occurrences of a specific set of “defects” are corrected. MeshFix has been designed to correct typical flaws present in raw digitized mesh models, thus it might fail or produce coarse results if run on other sorts of input meshes (e.g. tessellated CAD models).

The input is assumed to represent a single closed solid object, thus the output will be a single watertight triangle mesh bounding a polyhedron. All the singularities, self-intersections and degenerate elements are removed from the input, while regions of the surface without defects are left unmodified.

Uses MeshFix v2.1 with several quality of life fixes.

Installation

From PyPI

pip install pymeshfix

From source at GitHub

git clone https://github.com/pyvista/pymeshfix
cd pymeshfix
pip install .

Dependencies

Requires numpy and optionally pyvista.

If you’d like to install PyVista, you can install it with:

pip install pymeshfix[extras]

Install PyVista to allow you to plot directly from pymeshfix.

Examples

Test installation with the following from Python:

from pymeshfix import examples

# Test of pymeshfix without VTK module
examples.native()

# Performs same mesh repair while leveraging VTK's plotting/mesh loading
examples.with_vtk()

Easy Example

This example uses the Cython wrapper directly. No bells or whistles here:

import pymeshfix

# Read mesh from infile and output cleaned mesh to outfile
pymeshfix.clean_from_file(infile, outfile)

This example assumes the user has vertex and faces arrays in Python.

import pymeshfix

# Generate vertex and face arrays of cleaned mesh
# where v and f are numpy arrays
vclean, fclean = pymeshfix.clean_from_arrays(v, f)

Complete Examples with and without VTK

One of the main reasons to bring MeshFix to Python is to allow the library to communicate to other Python libraries without having to use files. Therefore, this example assumes that you have a mesh within memory and wish to repair it using MeshFix.

import pymeshfix

# Create object from vertex and face arrays
meshfix = pymeshfix.MeshFix(v, f)

# Plot input
meshfix.plot()

# Repair input mesh
meshfix.repair()

# Access the repaired mesh with vtk
mesh = meshfix.mesh

# Or, access the resulting arrays directly from the object
meshfix.points # numpy np.float64 array
meshfix.faces # numpy np.int32 array

# View the repaired mesh (requires pyvista)
meshfix.plot()

# Save the mesh
meshfix.write('out.ply')

Alternatively, the user could use the Cython wrapper of MeshFix directly if vtk is unavailable or they wish to have more control over the cleaning algorithm.

import pymeshfix

# Create TMesh object
tin = pymeshfix.PyTMesh()

tin.LoadFile(infile)
# tin.load_array(v, f) # or read arrays from memory

# Attempt to join nearby components
# tin.join_closest_components()

# Fill holes
tin.fill_small_boundaries()
print(f'There are {tin.boundaries()} boundaries')

# Clean (removes self intersections)
tin.clean(max_iters=10, inner_loops=3)

# Check mesh for holes again
print(f'There are {tin.boundaries()} boundaries')

# Clean again if necessary...

# Output mesh
tin.save_file(outfile)

 # or return numpy arrays
vclean, fclean = tin.return_arrays()

Algorithm and Citation Policy

To better understand how the algorithm works, please refer to the following paper:

M. Attene. A lightweight approach to repairing digitized polygon meshes. The Visual Computer, 2010. (c) Springer. DOI: 10.1007/s00371-010-0416-3

This software is based on ideas published therein. If you use MeshFix for research purposes you should cite the above paper in your published results. MeshFix cannot be used for commercial purposes without a proper licensing contract.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymeshfix-0.18.1.tar.gz (1.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pymeshfix-0.18.1-cp312-abi3-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.12+Windows x86-64

pymeshfix-0.18.1-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pymeshfix-0.18.1-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

pymeshfix-0.18.1-cp312-abi3-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

pymeshfix-0.18.1-cp312-abi3-macosx_10_13_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12+macOS 10.13+ x86-64

pymeshfix-0.18.1-cp311-cp311-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.11Windows x86-64

pymeshfix-0.18.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pymeshfix-0.18.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

pymeshfix-0.18.1-cp311-cp311-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pymeshfix-0.18.1-cp311-cp311-macosx_10_13_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

pymeshfix-0.18.1-cp310-cp310-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.10Windows x86-64

pymeshfix-0.18.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pymeshfix-0.18.1-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

pymeshfix-0.18.1-cp310-cp310-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pymeshfix-0.18.1-cp310-cp310-macosx_10_13_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

Details for the file pymeshfix-0.18.1.tar.gz.

File metadata

  • Download URL: pymeshfix-0.18.1.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymeshfix-0.18.1.tar.gz
Algorithm Hash digest
SHA256 c3386a123e3ecfcff59f229a4fc620ae0e03fa9c7fec025fbd2885349fa8fa3f
MD5 a24a540872d9573a5b704ae76671a338
BLAKE2b-256 fcd8c5124ee26c10bd2d77333eb5a8cddc89cb45ced9f1b173235e13ecfa6ebd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1.tar.gz:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.18.1-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymeshfix-0.18.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e926773ff90131884b26b9f925fd6f6f6d2f35c53828b8abc49512dcef00bd47
MD5 402545de243d5dbd811b7003bb96cdee
BLAKE2b-256 117907d46f90f6244edd872d95f94ae550c6af3870733fe6fd9c2a9808b02f2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp312-abi3-win_amd64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 109956a0a3e0ac81ae7c76322c0224ac5a641e914a83a1a9904c75b40c916f74
MD5 a46c0119e8fbb8433d670ec5024c9d90
BLAKE2b-256 ef2d31c8fcd0dea754f4b9272be0984d6669a7d60b43db5ca33c4757b2adb262

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 829fbb193dbcca117ab45fda72dfe95f18f27c09f85a21a42f33f88ace40f52a
MD5 49a078e2d549f9b403197258868d6f6a
BLAKE2b-256 9d61110d7a502290bcc317ebd6acfe3f2fc1064cd23175989022189ef8d5df68

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e451cade1c29974467a73eb5c1a216dce07114a27783eb83f681d572316dcbde
MD5 fde4eb8440e2f342dd0ea4b45e376774
BLAKE2b-256 5e1149d95279878c6f2f9297229db4663e94af1b6c2dc6c2140764739b023e57

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp312-abi3-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp312-abi3-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 365a937ce9ff3888ed994d158bdf9b9069db8d0b9684c32d3dd1056526f04980
MD5 ef00d700e239d04432c5b91f5f16df60
BLAKE2b-256 273fc0acb23cb004270b6bd27116306bd2b775ce2c865f452b6451f168ee78d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp312-abi3-macosx_10_13_x86_64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.18.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymeshfix-0.18.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1875a3239104ba1ae23b2631948fc7fbf9b40a0f4016d9d79e15fca1e8323c81
MD5 372c16404dbca434003bc70ecd52787f
BLAKE2b-256 bf8781129d21fa76ab554f0ec71e2e4cfff6807b3d62f6275b120a75a464a40f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp311-cp311-win_amd64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 134351b50821f0b3c1ed238fc9821b1d290e9eb6856c0d360e3dfda9974eae8d
MD5 808771b8ffe1a244983c2dcf16fc1b6a
BLAKE2b-256 13ea453089cbc7fb643eb19a34688f040ba2501ce0e275ad47bff7649844e70b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3e407e7bf162eae1e335a791b2c848692ff66139987b0f68ac2f91b7d195729c
MD5 4474b0c7c09fdc7e2099fe36bc99b3ca
BLAKE2b-256 b06cb9e50e216d1707132e73149edbadf8edeabe1a9706d9056c8cd5c5ef2f34

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d34935de7d5f4d5bde0e91571b1382646d3ca3cc723db02b782c99ab56955243
MD5 9c9a5f8b017f52c16ccfbca8b307b842
BLAKE2b-256 6880c99302664846235757d5ee9f9eb32165543624631e14cf8a5032a792ac92

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp311-cp311-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 397dc58fad3ed24c6e3ac4f9f186a156386e8349b1e88f9b5f7440a4c1528856
MD5 a6ade05ba9ffbd5d4660644bb38ddcb7
BLAKE2b-256 fa0f5d047bb33587255a7809dbe1eed243dc482a25c61a7d9c723a999b5d72f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp311-cp311-macosx_10_13_x86_64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.18.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymeshfix-0.18.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 db90969bd6f6e3932d1fed61891852dd9662a6e2097694431518bc5f51a02cf7
MD5 d8efce769117fba7c43989ad6edd5054
BLAKE2b-256 656ac8c6e2971ffc072972945a65d2092c082753cc55767e9f6b638ad8ca8f78

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp310-cp310-win_amd64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 583aaaaf345c0b38c6f0d0200e315adefb66f415531e5c20a8ea4fc34a48b60b
MD5 af8d5a066e00d69188ea57138f48cb43
BLAKE2b-256 feb18f86a36020a93a33a2ee819b6bc535687b2b6e4e516002e4420bac761544

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 df9febfa49dbfbb31a3f489ae6b8cba4b74f4cb8c522a24507da1e7bf9022d19
MD5 77e1a962dba3b232b19f7e78143f10b0
BLAKE2b-256 6e2a6609c64423586fa5473227e989368149ce82e7ff4dcfc52d645f96127bc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4363384cdfdd9d65119d596f864355ff66d6ea50bb77afb8329c3ba02f3b7f1c
MD5 ef67daaab6a7016f3f38fa76aab31f72
BLAKE2b-256 e1bc5fcbe25fe34a7bbf405f1020cb72f2e774a5e366b2c5c691f373f0393205

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymeshfix-0.18.1-cp310-cp310-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 95f0406c42807973c96b8e2a153ad0b9738bf5ec67ba8f9fbb62ad87f70e371f
MD5 3191ac1b4490850a61e46eb572a537a5
BLAKE2b-256 efc85e2caf3faa974390067bc41ef05b610cf8be73a6e414fc5f4fbe36fafd91

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.1-cp310-cp310-macosx_10_13_x86_64.whl:

Publisher: build-and-deploy.yml on pyvista/pymeshfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page