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.2.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.17.2-cp311-abi3-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.11+Windows x86-64

pymeshfix-0.17.2-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pymeshfix-0.17.2-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11+macOS 11.0+ ARM64

pymeshfix-0.17.2-cp311-abi3-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11+macOS 10.9+ x86-64

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

Uploaded CPython 3.10Windows x86-64

pymeshfix-0.17.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pymeshfix-0.17.2-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

pymeshfix-0.17.2-cp310-cp310-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

pymeshfix-0.17.2-cp39-cp39-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.9Windows x86-64

pymeshfix-0.17.2-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pymeshfix-0.17.2-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

pymeshfix-0.17.2-cp39-cp39-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pymeshfix-0.17.2.tar.gz
Algorithm Hash digest
SHA256 d87c8bc51f85d9f45353a434d52f5041c5b8e65b533b338d7e04889254da6543
MD5 44625c13fd91697613dc9488916b463d
BLAKE2b-256 6a084c2f6391fe3ed013aa0ceefae0bd729cde7bad3095b729bdf93f7d2d2aad

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.2-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: pymeshfix-0.17.2-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymeshfix-0.17.2-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 40cc8003f1d422dfc8f640b6934a21c4d80a6761f168b16367db582ab3f6efd5
MD5 47fd1d0495d3e12894af5126940895eb
BLAKE2b-256 e4af85b7c477cbdc094cb3d77787351af1baf7e37db5cd07d5dfeb6bffbf6453

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.2-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ad53f1d21e4611c4f430e1127331e875e296a5c22b5278d12ff3379e840d9490
MD5 c5f57c99557b5725d77c44debbce659c
BLAKE2b-256 af15896c602c95330c19f58daf3d49d99586957912a88036362e9003da60c833

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.2-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e4942c78addd1ded91f577e30443b25aa6898bd7f638f4e0a4faac004bb3c52b
MD5 a73b4bd27d1d8068dcae26d7e23d7e82
BLAKE2b-256 480486735a7e4e6d8ebddbd66ad383ea147efcac4477a2c6c224ceea3506e41d

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.2-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 150d2a7161d424de17ae66631759f670351c3dc879f2737a0c3cab5d434a77af
MD5 b28bf0248806f591187a84c1452ce212
BLAKE2b-256 6719135387044bac9381954aac8028aec8e780ec500de19875c22bfa1b05fe69

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.2-cp311-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp311-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 703c25043ec43732f0fbf490e6d95ec9c63267cd9e2ccf8b4e0754e5c0cd8420
MD5 1154f7066f774068cc5860fbda2f0d8c
BLAKE2b-256 40f810f2296bf7fb529a02da4e4ee70202d43d5f75fb85e948dc9205d21de7ae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymeshfix-0.17.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymeshfix-0.17.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c159a57c121eabd53cce6fd2c9803e4296bee99581bb1a2540d0b16746b9e905
MD5 b2fc8501e240f234822574e8fb0f7cf0
BLAKE2b-256 fd250165a9c2aa2894a6c1aa4a2f7f5d141fd1208c69661819844ae37bebc693

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 912abb70cce8499bce19561210fde8e76597e50abca7e44f7f8c2b7f3c23e3da
MD5 2774853889a2a3db6c5bcf4a11f7ff7e
BLAKE2b-256 343b217cee83f645c06719410cf9f7586e7b031166bb42a8ee0f50a237fc827d

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.2-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 14321dc61a77cfa8b8320f32124356838b6627b7a1cbe21e55a17fdb24655d99
MD5 c957cae60538572c9151073e581f274d
BLAKE2b-256 77183cfaf0d972ef24ff9bbfd046606649e3e3ed30c82381953f0e2c0785b26c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5abef8cffdbd777ba2ba036fa759a03f0656eec7e7f7265f73ed7c71b8baa93d
MD5 a8f764be43e3f38de5cb1eb7ba785dc7
BLAKE2b-256 0fad3b292c4f5b11e648973f846670d97216db14bc4dc2045c43978d2caa642f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6bbe1f642cacb7bc03120f77f051c9c886c5fb4fa185373058e34bde8d03714d
MD5 4d2b56207505f58f3135fa0c58fc8938
BLAKE2b-256 3f5a3c944f099992ac885f3b4afe01592eeec9f734a6e591fa73a1dedc2f5a3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymeshfix-0.17.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymeshfix-0.17.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3e2bb0ea7b1e2cc37bc013e4838d42d816f98dd4133e08f8265e964de5e21885
MD5 6cfd395fc100bca41753a83033c963df
BLAKE2b-256 a05546519e479858116b869c9b1ceb30a9ac4fca3aed74971691909d9689a98e

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.2-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b63d845e21bf42145d47abb08cf4601030bd23f9ccc7c5fd9507be0ac15f62b1
MD5 2d224ac20925d330abdf6c71cffc3a84
BLAKE2b-256 32ac8bac7459e917f1a2a603b568e300ee77c1cde0bf49ceb5b5bea9b9001372

See more details on using hashes here.

File details

Details for the file pymeshfix-0.17.2-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 327fe5c9265195e67c8ea39f4db61696d5768a5fa0e9f6de46c8f7896eecfc4c
MD5 3230222d11521d656468105494e7d21e
BLAKE2b-256 1a12e2fc2156e62d73c13305db3dcef5f4028a94ca05df5f5796a692bf49de68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b8f8c393f352ebc803c8abf5dc1c173c54dcf64b82c0b34d2ee7c60dbdac4e06
MD5 cd70e7fab63f9db05da1cfe4789b6b92
BLAKE2b-256 f9872254050fde542f3247e113467a4dcdc755cdb3ee0e17ece174f7219b0c75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymeshfix-0.17.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3a496e96e5f5fd25c08bf40bcf2a772c0d8c4d1326eae6472836ef7579fc617e
MD5 a39d1ecea19101f023d5a5134868c4d0
BLAKE2b-256 eaec9bdf1925dba96ef454b2bd2480177f5af68c4da08e013e13c11068e3298c

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