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.

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.17.1.tar.gz (1.5 MB view details)

Uploaded Source

Built Distributions

pymeshfix-0.17.1-cp313-cp313-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13 Windows x86-64

pymeshfix-0.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

pymeshfix-0.17.1-cp313-cp313-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.13 macOS 11.0+ ARM64

pymeshfix-0.17.1-cp313-cp313-macosx_10_13_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13 macOS 10.13+ x86-64

pymeshfix-0.17.1-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12 Windows x86-64

pymeshfix-0.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pymeshfix-0.17.1-cp312-cp312-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pymeshfix-0.17.1-cp312-cp312-macosx_10_13_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12 macOS 10.13+ x86-64

pymeshfix-0.17.1-cp311-cp311-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11 Windows x86-64

pymeshfix-0.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pymeshfix-0.17.1-cp311-cp311-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pymeshfix-0.17.1-cp311-cp311-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pymeshfix-0.17.1-cp310-cp310-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pymeshfix-0.17.1-cp310-cp310-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pymeshfix-0.17.1-cp310-cp310-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pymeshfix-0.17.1-cp39-cp39-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pymeshfix-0.17.1-cp39-cp39-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pymeshfix-0.17.1-cp39-cp39-macosx_10_9_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pymeshfix-0.17.1.tar.gz
Algorithm Hash digest
SHA256 96c22ff578ce56f16a4b9bb9cfe6deb196d94044a17fe4815b74e962f64f236a
MD5 169488c68c3f81b5d7ea41402575a72f
BLAKE2b-256 1ac525d819749a15693496bf8a19afacb5c56e2bd85082ac6197821f9e08cc10

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 02d93b6f79197986cb734d5a72cb0f6ca0131d286a2b814a93c0ea50f550b1d6
MD5 0ea4364627972321ce29c5c89dc5263e
BLAKE2b-256 46440d0588c315d6dfd63421e0e97b2996e3c29c7770cdde890969e8aec09f16

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0b18dd9ae4f780215a1ef3301608d080ce147a0f2e2ef780a8e44844a893c4e5
MD5 53772e937bff0783a3c4d06d3f93b2b8
BLAKE2b-256 db11049cd97adc2446831427a430cd48538f5c2a249164db0cc3b651e34e52a4

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c925b7b22fad70c6bd3fd670b69ada3f9587750d6bf33d8d3ad84368d54a256
MD5 3752efc998fcd1fe60ee12e8136b058f
BLAKE2b-256 e8462d085815fb1cdcb8c410db0899ee92513d9f93f06340086512caef9e72d9

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0487ae95778eb4a12451164ae45cfbdf93c53d91f481e169ff0cb7a49133ea3a
MD5 db502a9e5c2d0ca42b552f3b9bf6659b
BLAKE2b-256 b441c1e0b973453a292f281724fcd875a8111504f6cf18f8f864f619a906de01

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5ec0ee862791aac36cf7819dfb815abb6afa19b04403ab7b53932f06adaa3830
MD5 fdfa4e7d27ec50e9caa3840a33f1b220
BLAKE2b-256 ccc703e8f4706c55afe241beafe78a9adf10171007cae54abc57c9325930b0ab

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8bc91563f2e62a93646bbe5618ee4a1602e55d02017e26e3e595aba1bd3c8bac
MD5 73feb8a43f3372a48318ed526ed5f1d5
BLAKE2b-256 6d25b2b9d042399c967e6f1a8137f0c06bff1e5800f74d15b9f765768ffef0b0

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 691e7a2807a2ee4ca32e9e28237ce24f6be5216b97dc110a5c20601680f2d0d1
MD5 0f7879021a803fc60b24817009156dc9
BLAKE2b-256 c358f4809933fd286678315b64cafe3ca3c4e6ddad983d8043e76db5cf759a5d

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b14254355791d1bb4252d18c9646d4a7fa3c103a6399641bcf25a4c58e251e6f
MD5 30a2beb9c81d920b2b7c4613069b725e
BLAKE2b-256 74b8f2b343ae38bd4b49333837ce3d86af7cbce50f21cfe4da2278ec9d0aedb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 35c34168364d3592017768b35140a873755fd241d80ff480671cdeb2884d14bf
MD5 3984c2dc4529085468bc08cc8da2f7be
BLAKE2b-256 37ac97442327fc00d5ce6f642eb89f65a7ad2d7b2620bc362107da081c79d4ed

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 03e0e13cee1c9c45f83e48443aacaca10e19d23e5853cb9479f15ce80672bd17
MD5 6afcb36e6f119c5f5e86bd9712b53093
BLAKE2b-256 8773ff72ec1a2b07e69a7681ddb0d92b8b7aaae5da755f7388652785262d63d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33c55fa6aa67c782778690d5707725534af2b267fc6e4edfe047ead6ad4e2a41
MD5 67d2f94d36c394498d78c8f9fa004b17
BLAKE2b-256 7eecf3e1370b16a1dfae66da52f06ad818e7f35c03d297c6708d08accefd1af0

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e84afcc7cc4e6c3e6d388ed368a1cf11788e02e504e83b782c7992ac09269832
MD5 374705bd27070cc50a7d08bd78e7e760
BLAKE2b-256 3431c4a486fef7fd2e89e30ba2915917ede7ad13653665d098b59f49b2e078d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8623c6e436b36bdde1222a864582fde4d076a1ac8675dfb9c14c19f6c0355404
MD5 551c70f4f4a05c380029069c23905a38
BLAKE2b-256 6617ca5de23d48eb24b8949b037b8218dc502d9b3e57edb15570824e748f4766

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 783241103812d16e87843dfb3d19b8a5bcda637efd64f2797c29c13de89f9f08
MD5 32a7996d0a72ccebaf6a233ef584722a
BLAKE2b-256 ab58aaf1e3ad9cadb338650fe1c3cf587ea224c81100794d63999aaf1e74e805

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c6178d5fb3f611965c312be31d7a23e14116b178030f146dbfdc6994a35665b6
MD5 d9996b087e738200b7482db6c779a3b9
BLAKE2b-256 02fbc3b73623eb7752cdf06ce5456b542e0902bea64e4298c595c7c007f8f9a8

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0c0721e1745b7e5ee9a383ae232e44b9db21ab840e44091c3c90b6dba98772bf
MD5 1894487d5a065e6770c9ea9cf867cdc7
BLAKE2b-256 c6d1aa664804c67cdba59aa7fa427f4fd33b8621a05c0374fe7931dd91ea849b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8d4ea09fc72d2e19493171b98046efe690db2b05661081a4941c8379982a9e1d
MD5 4d2fbaa3a78747787b17c5cd88a00f79
BLAKE2b-256 d98e2c7f6432a5fa57b4ad7e8dc2330e5bbbf3585358bc35e20d3e34abcbeed8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a83acfd17fc39fedcdfa848b0876e283e53e4b225d99ef9d7fa8a7e1d2c5d912
MD5 76a9c85930374701d4121fdd8912c4bd
BLAKE2b-256 624cf654b8a2144a2174c70bba77e8373ceeca09606690348db50c324ccbec2e

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 862d9f707ab76b020338042150211f42647e78fb31a9b3f539977aa9f9a5accc
MD5 72a0e4a2f6acab706ef8afc85eafc875
BLAKE2b-256 e2eb2621bd365f9430ef2cd88fc9e3e73f3fe932119b2fa06a907ec922b7f332

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 270572c2b5b839a4c0bf6f7898b9d4abc3e37e9c99ad7e332b76ef617351418a
MD5 2eed1c4cc37b2a936143e81469bc39eb
BLAKE2b-256 d612343cb59d53e1be697495aea132079666f4b5eb7929a7d895e7d80ca7ffc3

See more details on using hashes here.

Supported by

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