Skip to main content

Repairs triangular meshes

Project description

https://travis-ci.org/pyvista/pymeshfix.svg?branch=master https://img.shields.io/pypi/v/pymeshfix.svg?logo=python&logoColor=white

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.

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

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 Distribution

pymeshfix-0.13.3.tar.gz (1.3 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.13.3-cp37-cp37m-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.7mWindows x86-64

pymeshfix-0.13.3-cp37-cp37m-manylinux1_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.7m

pymeshfix-0.13.3-cp37-cp37m-macosx_10_6_intel.whl (1.6 MB view details)

Uploaded CPython 3.7mmacOS 10.6+ Intel (x86-64, i386)

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

Uploaded CPython 3.6mWindows x86-64

pymeshfix-0.13.3-cp36-cp36m-manylinux1_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.6m

pymeshfix-0.13.3-cp36-cp36m-macosx_10_6_intel.whl (1.6 MB view details)

Uploaded CPython 3.6mmacOS 10.6+ Intel (x86-64, i386)

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

Uploaded CPython 3.5mWindows x86-64

pymeshfix-0.13.3-cp35-cp35m-manylinux1_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.5m

pymeshfix-0.13.3-cp35-cp35m-macosx_10_6_intel.whl (1.6 MB view details)

Uploaded CPython 3.5mmacOS 10.6+ Intel (x86-64, i386)

pymeshfix-0.13.3-cp27-cp27mu-manylinux1_x86_64.whl (2.1 MB view details)

Uploaded CPython 2.7mu

pymeshfix-0.13.3-cp27-cp27m-manylinux1_x86_64.whl (2.1 MB view details)

Uploaded CPython 2.7m

pymeshfix-0.13.3-cp27-cp27m-macosx_10_6_intel.whl (1.7 MB view details)

Uploaded CPython 2.7mmacOS 10.6+ Intel (x86-64, i386)

File details

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

File metadata

  • Download URL: pymeshfix-0.13.3.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for pymeshfix-0.13.3.tar.gz
Algorithm Hash digest
SHA256 a85634672fdc19f32f1b8e6daa7d6005c05dd9ba585a6fbf43a6bfbb70e4923a
MD5 192b49bb214739db875889d19ea97e72
BLAKE2b-256 b030905756976c9a3cc3432b89020ee4618727bbe0bfa26e42e3268ddae1097f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymeshfix-0.13.3-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/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.5.4

File hashes

Hashes for pymeshfix-0.13.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 6797188eb3b71754fd9484195f0ccd2c1935a704c927bde3b7247c84abb4b9fa
MD5 5fc86ff0e61baf31f48eaaae3197517b
BLAKE2b-256 f6f9ac351d336da124a393b2b6bb4e85a4d98ebd645d8cb4819add64a8e76040

See more details on using hashes here.

File details

Details for the file pymeshfix-0.13.3-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.13.3-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for pymeshfix-0.13.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bc227ef2593038ac27824a319cf59da1f5722d60367c0f43ad4d111383155d3b
MD5 a6d2faa4cca87697f156085d356fb16e
BLAKE2b-256 839d03df70ed1a1db6ae7930d1451a6038908b2715b14fb9d8cf3e24db880e6e

See more details on using hashes here.

File details

Details for the file pymeshfix-0.13.3-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: pymeshfix-0.13.3-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.7m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for pymeshfix-0.13.3-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 3c2c0bccc8fc6f0f6184e9f62c7d9ce98c88804b8c65c95aa6534c622fcf9774
MD5 e7486dbd9810a2d348cc5893d52868fb
BLAKE2b-256 dad74a3379729846609f740c74c3acad5673741cd03f612438ed49492ada8212

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymeshfix-0.13.3-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/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.5.4

File hashes

Hashes for pymeshfix-0.13.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 8434fe303e9401b73b7bfddf3fcd503f15341ee44459f084821343449e2b10e1
MD5 9a95bb472c96053dca78387b8b13bfaf
BLAKE2b-256 408b1056f502f0942581875c961e43cb0eb667f1216a9e55059a10729a46aaf5

See more details on using hashes here.

File details

Details for the file pymeshfix-0.13.3-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.13.3-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for pymeshfix-0.13.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6f09f669eb5b8fbc2d2a4ddd992094e64916e6f4e6c2ccb703d3d3f73b985c72
MD5 2aac00d51d3c995ed6c2ddd0c1384073
BLAKE2b-256 f6102a1b2d65bc0ec73dd9bdc8a26ba29e4758e6aa4d2878583446a3bd1e4d05

See more details on using hashes here.

File details

Details for the file pymeshfix-0.13.3-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: pymeshfix-0.13.3-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.6m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for pymeshfix-0.13.3-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 b86eb25be3a1b5acc9589e543ae06bc190df00400944123760d3b7f1360d44ab
MD5 ac34042345f10fabdade2d70b3d25ad4
BLAKE2b-256 f1fa73f29d853873d590f16e8a7def0430a9b1f4ad9b638ea75a5d90ad61ac4e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymeshfix-0.13.3-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.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.5.4

File hashes

Hashes for pymeshfix-0.13.3-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 fe49129e8a99c4b2d3eea9b946c504c4b4023c1dcc8d3eacfe69816b0a20ac36
MD5 09476258c41445d97f3b9115735a12ce
BLAKE2b-256 a5b8ea15146852516bd269ea228d065160b3e6034c6c9294fc89bd99735792b7

See more details on using hashes here.

File details

Details for the file pymeshfix-0.13.3-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.13.3-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for pymeshfix-0.13.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 17b311b10dbe3a3625f7af79335a235f51b139f280edc530c8d4beecdb8fe4c7
MD5 8f8f26d5a895dc4ba348529c5a9a631b
BLAKE2b-256 736dd19b92ab0382bf50417aff13621cbc7c7007c10c15c0e076284523eef7a5

See more details on using hashes here.

File details

Details for the file pymeshfix-0.13.3-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

  • Download URL: pymeshfix-0.13.3-cp35-cp35m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.5m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for pymeshfix-0.13.3-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 a0a8662fb196b590e7f0a79c39421a61ca4edb94fcd43bb64167294c381c1702
MD5 ed91ad107422225be2a4e051524d2d0a
BLAKE2b-256 3a78ba9e630ce26a8ff7786dc0cd0fd20076ebb2b00539aa4b3a1174bbef42dd

See more details on using hashes here.

File details

Details for the file pymeshfix-0.13.3-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.13.3-cp27-cp27mu-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for pymeshfix-0.13.3-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 67415510d6c58885ebc77fb34259913e981b7adb671a787a8235724b4e5a9313
MD5 f19abbb5f39db36740c3df04cfb7f9cc
BLAKE2b-256 e06e7f9f24a16b64ce9695a7a1c2c007f9bb1f59ec757ab990d66cf152160ad1

See more details on using hashes here.

File details

Details for the file pymeshfix-0.13.3-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pymeshfix-0.13.3-cp27-cp27m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for pymeshfix-0.13.3-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 feff20eb8b7387236379741b453957cb357b1d12fcd0ac41ee4000900980f325
MD5 8e8801c75f486263588fc35f0add40c8
BLAKE2b-256 b2f053c81b0b1a74c75407420046f520b513cb824513006bf4ed8638b08229eb

See more details on using hashes here.

File details

Details for the file pymeshfix-0.13.3-cp27-cp27m-macosx_10_6_intel.whl.

File metadata

  • Download URL: pymeshfix-0.13.3-cp27-cp27m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 2.7m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for pymeshfix-0.13.3-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 034d47cfac2390a7fba926d5ecb42c827e343e6568f3ce55798fa2aa3151a872
MD5 fb2abaa18ad2a254925bc7f098cfc493
BLAKE2b-256 c8223a699671bb7880a01d1ff29e97490a424f43faeb44b2c00278c583f13373

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