Skip to main content

Repairs triangular meshes

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.

C++ source last updated 1 Jul 2020

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 pyvista

If you can’t or don’t want to install vtk, you can install it without pyvista with:

pip install pymeshfix --no-dependencies

You’ll miss out on some of the cool features from pyvista, but it will still function.

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:

from pymeshfix import _meshfix

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

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

from pymeshfix import _meshfix

# Generate vertex and face arrays of cleaned mesh
# where v and f are numpy arrays or python lists
vclean, fclean = _meshfix.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 programs without having to use the hard drive. 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.v # numpy np.float array
meshfix.f # numpy np.int32 array

# View the repaired mesh (requires vtkInterface)
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.

from pymeshfix import _meshfix

# Create TMesh object
tin = _meshfix.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('There are {:d} boundaries'.format(tin.boundaries())

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

# Check mesh for holes again
print('There are {:d} boundaries'.format(tin.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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pymeshfix-0.14.1-cp38-cp38-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.8Windows x86-64

pymeshfix-0.14.1-cp38-cp38-manylinux2010_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

pymeshfix-0.14.1-cp38-cp38-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

pymeshfix-0.14.1-cp37-cp37m-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.7mWindows x86-64

pymeshfix-0.14.1-cp37-cp37m-manylinux2010_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

pymeshfix-0.14.1-cp37-cp37m-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

pymeshfix-0.14.1-cp36-cp36m-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.6mWindows x86-64

pymeshfix-0.14.1-cp36-cp36m-manylinux2010_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

pymeshfix-0.14.1-cp36-cp36m-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

pymeshfix-0.14.1-cp35-cp35m-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.5mWindows x86-64

pymeshfix-0.14.1-cp35-cp35m-manylinux2010_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

File details

Details for the file pymeshfix-0.14.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for pymeshfix-0.14.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 cf49a19fd9acad2902c81ea8ef9053edf5221b7c876d4249f2b76eb90842db81
MD5 bde60fe41b7c04e6efe6c3d9ddce8a21
BLAKE2b-256 b3c2a84aa2970c92569e42190255c1fed45c2247c297405ff99f989a9512684a

See more details on using hashes here.

File details

Details for the file pymeshfix-0.14.1-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for pymeshfix-0.14.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 07b6a016ef1db553941abb96ca606a4ba983812ff131904a7e8aff4ff8a134ba
MD5 5ae78bb479e9654155bdc4d6d7051cd5
BLAKE2b-256 2d6e5e974db96230235b1fcfd9f7e26a161c63c24dfdcd4b1f6641d8c11930fc

See more details on using hashes here.

File details

Details for the file pymeshfix-0.14.1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/2.7.17

File hashes

Hashes for pymeshfix-0.14.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dac18046d1de460c0f6b9f7220ad424a3085526bf6dd3663a5618185e7dbbca9
MD5 d3dee642c73f9c86a029aab1be342307
BLAKE2b-256 3f06e4a4e9e80832956176864966dcac49e52628765dc142e5f8c21cf6212933

See more details on using hashes here.

File details

Details for the file pymeshfix-0.14.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for pymeshfix-0.14.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 09a360610f301c041969f35a9462572c0034b13d2b83f96092251e5aebdb9127
MD5 bed2a44dc9ac561989485cf45beaafef
BLAKE2b-256 9d73e092a2436fbb52e8aece23820f976e3ccd04c28b77b56ec7ce572732c041

See more details on using hashes here.

File details

Details for the file pymeshfix-0.14.1-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for pymeshfix-0.14.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 01dc04f514ebec9904044a66bf16344f4a5db6bb4b3c3a90f3897f073720bdd7
MD5 c35a99ced3192936f7bf3d9198bdd482
BLAKE2b-256 f7926913c23748850471545d81c3836ff6c8c08f3f6aff55806907f4ba8ccf5a

See more details on using hashes here.

File details

Details for the file pymeshfix-0.14.1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/2.7.17

File hashes

Hashes for pymeshfix-0.14.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c9396323ac43db4bd9aab1232f40edd014973f13933f4ae70dd34ffa9cb5825b
MD5 d88ba368ed89b7c66383cfa6065e0c8f
BLAKE2b-256 d056ae9c5e89b0a766d79dbfa9b9e95827f8da79c5c69579d23822286b9392f3

See more details on using hashes here.

File details

Details for the file pymeshfix-0.14.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.8

File hashes

Hashes for pymeshfix-0.14.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 2b4524fc062c2c6cf1111ded56759a2f2393415b5e5ff66d5387e60cc21ce764
MD5 14b49b11a85e712cf81d1c14b8f19a3b
BLAKE2b-256 99f4b7c5da3d068b1ed8e1f8d180518fea81f8814a50c0ec7c34ce65d36a52c6

See more details on using hashes here.

File details

Details for the file pymeshfix-0.14.1-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for pymeshfix-0.14.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d62e02011f5d9d98851e69d9095d19d63afe933b54b693a111be318a631f4c6f
MD5 095ae57dd624afc35f790c27d75c5439
BLAKE2b-256 d226e97c56dd1ac714086f6c7f1d323c3c090ffa493b8f15b5046e8183974981

See more details on using hashes here.

File details

Details for the file pymeshfix-0.14.1-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/2.7.17

File hashes

Hashes for pymeshfix-0.14.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dbd66d588fe04d75b44ef1e0c9fd2764ad0474645fc26f0a7a1ddddf04ce0496
MD5 361a02e85f2959a24b5871ab3077e429
BLAKE2b-256 5649ea78ec81ceb236b0ec8bfa85031ae5a3539be98223d68277d9208b2bdc52

See more details on using hashes here.

File details

Details for the file pymeshfix-0.14.1-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.5.4

File hashes

Hashes for pymeshfix-0.14.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 5636e974a84fa132d116617dc768aabf573f30af137114011e02ffc393b1c863
MD5 5e2813682f28ed55681ce99ea73d76da
BLAKE2b-256 2ef5779da82cdb07a54ed9df3bd2363539266a89c68aaa8ce5cb46473c802290

See more details on using hashes here.

File details

Details for the file pymeshfix-0.14.1-cp35-cp35m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.14.1-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.5.9

File hashes

Hashes for pymeshfix-0.14.1-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 cc00ba66f0d7c8a93cf05088ffdbb55edbc09b00d7935df7505b6679a40f0e30
MD5 042039d6a4a58361261d15d1c9f8edfb
BLAKE2b-256 3867ef0369eaf68ab859c6ebfa1248dc02f61ea734162b26110cde08e1951709

See more details on using hashes here.

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