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.0.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.0-cp312-abi3-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.12+Windows x86-64

pymeshfix-0.18.0-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.0-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.0-cp312-abi3-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

pymeshfix-0.18.0-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.0-cp311-cp311-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.11Windows x86-64

pymeshfix-0.18.0-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.0-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.0-cp311-cp311-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

pymeshfix-0.18.0-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.0-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.0-cp310-cp310-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pymeshfix-0.18.0-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.0.tar.gz.

File metadata

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

File hashes

Hashes for pymeshfix-0.18.0.tar.gz
Algorithm Hash digest
SHA256 c92dcccba6921fed6bdab0b6b8d232f4167407e7acbba959895c8340be7cf3a6
MD5 3bfbf52e562d82e6c9e53f7749ef78f2
BLAKE2b-256 52e01bcf152040239f78c215dbabfb2f773570bf8b1660c39f1441b3bd31ef86

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0.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.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.18.0-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.7

File hashes

Hashes for pymeshfix-0.18.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e66a3c45b2364097c5ef8e1039d01077856aa6ff831e433806451471d6f073a8
MD5 83ef9993b4b365bc34f758d299188a15
BLAKE2b-256 521ad3bb42b886419209b45f18ccba3c434ef988050b5ec0579a06d9200d133b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d99c508b9fcd39732d7b617994ccb9a0eda4c5c329639bd9d02bd988b0d5288
MD5 8ee244a844ab926c19289399b05d5502
BLAKE2b-256 02cff5c895d01457ba3aa218ff2408ae4d1b0cbff7efd891ce671cf6ac51cbd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 821991d8b3f6bf58fb3eeeadd8599bd69d3e6cee4191e137b90a0587894f96a9
MD5 0481128bbaf5cf39feb39b2fd70e8a86
BLAKE2b-256 a262edba76fc9d6d71acad881a3c9250594c71fa04ffd156a486ffc42a117bb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fa0905d6256c4694af38d7e8baa304e3f54c0553781758dfe63ca6a55cbd72ea
MD5 4535bd19cf3f37a548ad772bf3f7fe98
BLAKE2b-256 d45c3fd4f42e985eb53a603f03c717071f61deeaadc0bbe42433187947d517dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp312-abi3-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp312-abi3-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 36685ac6a54226b7198f8b56e35f22f87771e7281d6aea865955c54ba8cac244
MD5 e4b5978560f4380c4da4858fce953055
BLAKE2b-256 bb95f1ee0461611b44e2266e597216e8b49a5d56876b452bbf823ff12c024bdc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.18.0-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.7

File hashes

Hashes for pymeshfix-0.18.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bf211b61ed2bacd992f201785e2a68b7ebbbdf3317493d96760f507f228e90da
MD5 3dd19a769f9c80f226ff42229b4e4bb9
BLAKE2b-256 edde198df8b0552f7d76ced16b783fdf5577de066652631096ec80ee8ac248f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 92cdef424baa2723576b3dfe7634391e64c045596577cb0bedf8a1851c328b5e
MD5 b423497f9246c6e793f7c4dbe04c498c
BLAKE2b-256 f29a2bdfd2e91d4d93764948332065debfc6f26b4e56bb1b9130a8ce9b0ff445

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5e903861238b77ef347498f9bebc48b7000d6edc3eae2fb2a69987ca1ad8f2dc
MD5 0561a000f1782d1ba3ae7157b98ec50c
BLAKE2b-256 1ce9a46cf59984798bc4077842b865d51d015e0d07a81657b446a30fe284c55f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eab9bb4b6abf4793b9d79e640501cc6b9b15a943526733f0c351c73581ca1f3d
MD5 2aec0947df12f0cd9f13c33ca670268e
BLAKE2b-256 ca942d535847ff4fe87c30c2c10046e2045394c60dbf973cc29359fdf9b621a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp311-cp311-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 500594e804660baa4185514fae9bbf408479750c9021fd0dc5c9c6b2214c88c2
MD5 0ca9c42b82f68025feded31c98fd02ba
BLAKE2b-256 75e8e88782afe4813e6318b4de64fcbf0e46901f49baf4070bc5b4a6e2f09504

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.18.0-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.7

File hashes

Hashes for pymeshfix-0.18.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 08ee77429c9e0e668bc6957fe3c9134f8aea4440c24415f15a06b50a966c51ce
MD5 aa8d14916446710d7ded182fcfa43c59
BLAKE2b-256 31d7423b0a2713fa3f0e15331f99348db68e3bac30eefa5feea07588a0aa8255

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 addf90dc0ea5b12c195a1a5d12ff31818c0b6e78b220c9e69fc59fe5ed0dabdc
MD5 a6aa7ca898bcf24c37cb92cda82479f7
BLAKE2b-256 3e84e29010be8cbabe7aefa7c542831cb7bc48041374ec8cd94b307cffa59889

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 13d9e5a1438cd64bc78df912cf5d4f850111291e0e039e964faf8373824f6e30
MD5 32d922ac5b619c64e54c858e29529e09
BLAKE2b-256 dd4d60039124bd7d1529c2b39335e51bfac988bd2c9eb227f928cb157be4298e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 44b76dc6d51c20498bc6d7098b2f5e0e251292235178d61b8a3cd6cc4f9882de
MD5 d4d18fabb7d684fdc5ddd81e58fb8087
BLAKE2b-256 748bb8663752322d7b0526c65ed26b21c4e166c4bf7ea5440a16b8196bbe212d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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.0-cp310-cp310-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.18.0-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a0ad262c6aa461020df3ff8b68bcfd177b7571e9659b5dc97e4b4ec3a8be3d1f
MD5 5e0f1b78553b55dad209fc0147471a2a
BLAKE2b-256 c3ae9404af5cb65a48103e6a7a182bddd0e015c18964da1883b03cd17b8f4e6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymeshfix-0.18.0-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