Skip to main content

cython wrapper around C++ library for fast triangular mesh reduction

Project description

Cython wrapper around sp4acerat’s quadrics mesh reduction algorithm.

Requirements:

  • Numpy

  • Cython (only for compilation, but not needed if installed from PyPI)

Installation :

pyfqmr can be installed via pip :

pip install pyfqmr

Compilation :

Run:

python setup.py install

Usage:

>>> #We assume you have a numpy based mesh processing software
>>> #Where you can get the vertices and faces of the mesh as numpy arrays.
>>> #For example Trimesh or meshio
>>> import pyfqmr
>>> import trimesh as tr
>>> bunny = tr.load_mesh('example/Stanford_Bunny_sample.stl')
>>> #Simplify object
>>> mesh_simplifier = pyfqmr.Simplify()
>>> mesh_simplifier.setMesh(bunny.vertices, bunny.faces)
>>> mesh_simplifier.simplify_mesh(target_count = 1000, aggressiveness=7, preserve_border=True, verbose=10)
iteration 0 - triangles 112402 threshold 2.187e-06
iteration 5 - triangles 62674 threshold 0.00209715
iteration 10 - triangles 21518 threshold 0.0627485
iteration 15 - triangles 9086 threshold 0.61222
iteration 20 - triangles 4692 threshold 3.40483
iteration 25 - triangles 2796 threshold 13.4929
iteration 30 - triangles 1812 threshold 42.6184
iteration 35 - triangles 1262 threshold 114.416
simplified mesh in 0.2518 seconds
>>> vertices, faces, normals = mesh_simplifier.getMesh()

Controlling the reduction algorithm

Parameters of the ‘’’simplify_mesh’’’ method that can be tuned.

  • target_count

    Target number of triangles.

  • update_rate

    Number of iterations between each update.

  • max_iterations

    Maximal number of iterations

  • aggressiveness

    Parameter controlling the growth rate of the threshold at each iteration when lossless is False.

  • preserve_border

    Flag for preserving the vertices situated on open borders. Applies the method described in this issue.

  • alpha

    Parameter for controlling the threshold growth. Exact implication described below.

  • K

    Parameter for controlling the threshold growth. Exact implication described below.

  • lossless

    Flag for using the lossless simplification method. Sets the update rate to 1 .

  • threshold_lossless

    Maximal error after which a vertex is not deleted, only when the lossless flag is set to True.

  • verbose

    Controls verbosity

Implications of the parameters of the threshold growth rate (when not in lossless mode) :

$$threshold = alpha * (iteration + K)^{agressiveness}$$

More information is to be found on Sp4cerat’s repository : Fast-Quadric-Mesh-Simplification

Huge thanks to Sp4cerat for making his code available!

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 Distribution

pyfqmr_withuvs-0.2.1-cp312-cp312-win_amd64.whl (110.2 kB view details)

Uploaded CPython 3.12 Windows x86-64

File details

Details for the file pyfqmr_withuvs-0.2.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyfqmr_withuvs-0.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 83fb989b6d73ce8d4c1efa09ae26f7465181a5a1c50f0732d975c767e0c4a137
MD5 ac45675b5d8e94df6966dc7a613fed74
BLAKE2b-256 a851b78d5914ad2d8178ef83d7ecc54c05eb511d07042ab9d19516aa9e822d6a

See more details on using hashes here.

Supported by

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