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:

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 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.float64 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.

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('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.16.1.tar.gz (1.5 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.16.1-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10Windows x86-64

pymeshfix-0.16.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pymeshfix-0.16.1-cp310-cp310-macosx_10_15_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

pymeshfix-0.16.1-cp39-cp39-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9Windows x86-64

pymeshfix-0.16.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pymeshfix-0.16.1-cp39-cp39-macosx_10_15_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

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

Uploaded CPython 3.8Windows x86-64

pymeshfix-0.16.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

pymeshfix-0.16.1-cp38-cp38-macosx_10_14_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

pymeshfix-0.16.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

pymeshfix-0.16.1-cp37-cp37m-macosx_10_15_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

File details

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

File metadata

  • Download URL: pymeshfix-0.16.1.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for pymeshfix-0.16.1.tar.gz
Algorithm Hash digest
SHA256 52a8c1c8076dc29d4412a7283717088f68deda0ce155b7e3100e278434c91612
MD5 654b94d2c5c87b5ff617397ad88bcb3d
BLAKE2b-256 b72f4787495f30bb8a452749517b777a83803f8cd606567016356d6128aaba6f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymeshfix-0.16.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for pymeshfix-0.16.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 85f2efc12164e4d0eaccc4b121e15f7b7795f4d226c7295801613bfa6094ba1b
MD5 54968334d426809887075d445e191a9e
BLAKE2b-256 4fa5353ddcbaaeedf88c9c59f7fed4948c4974c4a8575f3e785a7b44d7ce786c

See more details on using hashes here.

File details

Details for the file pymeshfix-0.16.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.16.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c4dfaaf7b703adfe00cd1f1d113cbb571b1d1d6cc962489945456fbb9610ba1d
MD5 e1d3aad9490747ec7339f70be212ab01
BLAKE2b-256 8ce568981503fe168af8cc259502e3be55df67c665d71e34184d0539ef13241c

See more details on using hashes here.

File details

Details for the file pymeshfix-0.16.1-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.16.1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5a2beb9e4af49b1236e5a326ebe3a5ce6795e0d5a7322ac24ed210713d243c22
MD5 bad0f21416a8959a37313cafaf75c28e
BLAKE2b-256 697fe894dbc1c946c53d08bf382b65b2f6e735d1b849749b87a628bbfc2bf69d

See more details on using hashes here.

File details

Details for the file pymeshfix-0.16.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.16.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for pymeshfix-0.16.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a264dd7ff04cb43cd8cf95b6d853d50021a703f9471262c10714b8a8fc01d759
MD5 317c8e643836a4bf6202eb57c190c6a4
BLAKE2b-256 c461d51865633a9799dbb53e79f5b1e9fd16b1a33675a5d353bdb2526985bdfe

See more details on using hashes here.

File details

Details for the file pymeshfix-0.16.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.16.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f736e8981a6ec17f63b3fd7fafc67c034805d3d7fa1466d6bbc0e61be9299150
MD5 4ed30bae186ce4b3c31eb92f0729e7ca
BLAKE2b-256 f604d8bc98615ec1f57192a39482dee9d992bc71578bf73641f1a1b6f848f74b

See more details on using hashes here.

File details

Details for the file pymeshfix-0.16.1-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.16.1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3a51223d6c862431a156fba0d27ca646d2324b48ecc2d3870e8ddde847db24f7
MD5 b817f2664cdd5b22188cb126b7db5f4c
BLAKE2b-256 62c62b9ad52505eaac3b3fb081046eedf44f547742765e447290ddda45f7201e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymeshfix-0.16.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/4.0.0 CPython/3.8.10

File hashes

Hashes for pymeshfix-0.16.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 645576be9ce3cae66ebe788555a60ec1a9f9b23e51cf9f4117ed8150294464b8
MD5 11fa7b473af16b0731ea7a8873190b25
BLAKE2b-256 a324a94fd102767aa983b973514a119acaf494227c36fe48ef27031f99d17001

See more details on using hashes here.

File details

Details for the file pymeshfix-0.16.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.16.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af9fae97c694797f347bf96c5b4fe9bbfc88ed152143bec2146bde6a2993f939
MD5 c6f99648403b774ea89f6c19dfc11e2d
BLAKE2b-256 ec42c9a7af4ff02f7342168289aba48eb9e06dffa05251121c28ca5250ea9fe7

See more details on using hashes here.

File details

Details for the file pymeshfix-0.16.1-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.16.1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d93eec790fd34f8827c7429ec71ca8bab28aad09c36f37093d94d1151d331ea5
MD5 b020365cf4f79c059946b71e2bf85423
BLAKE2b-256 f077a51cddbc554ebcc861ceb4c51d74438568b599e318c5d1fe19442dfe7da9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymeshfix-0.16.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/4.0.0 CPython/3.7.9

File hashes

Hashes for pymeshfix-0.16.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 7126551df2283db5d7f2a408c944bf59e46d873cb23c1f47671e3a709bce9636
MD5 d1bdde2aecfb7cdcdc08afc8db84b72c
BLAKE2b-256 a2953644ee7a42e006b9753617ee93904ccb85a797ebf406ff13956d06a67314

See more details on using hashes here.

File details

Details for the file pymeshfix-0.16.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.16.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 48eeb8b7dd271b05ec6044f9ba9afc37e1d475500694abc68237acc1f69ea74a
MD5 3e715347fc569c6e899ce9226f2cab45
BLAKE2b-256 54a638a3f4873e3508971dc0d7b69ad9d5701019349e79be9c2b0ed70e45e267

See more details on using hashes here.

File details

Details for the file pymeshfix-0.16.1-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.16.1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c3462cea804a12fd623cd671762271a3355e361783eb600e0eb6a322444899b7
MD5 c96e1f4a461cda13aa2444c14d57dd4e
BLAKE2b-256 2010cc5c91dd9d19397c8e7fb5594b85690095413803961330625df3423f80eb

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