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 Distributions

pyfqmr-0.2.1-cp312-cp312-win_amd64.whl (112.0 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

pyfqmr-0.2.1-cp312-cp312-win32.whl (96.7 kB view hashes)

Uploaded CPython 3.12 Windows x86

pyfqmr-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (874.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (857.6 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.1-cp312-cp312-macosx_11_0_arm64.whl (127.8 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pyfqmr-0.2.1-cp312-cp312-macosx_10_9_x86_64.whl (138.2 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

pyfqmr-0.2.1-cp311-cp311-win_amd64.whl (112.2 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

pyfqmr-0.2.1-cp311-cp311-win32.whl (96.7 kB view hashes)

Uploaded CPython 3.11 Windows x86

pyfqmr-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (875.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (864.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.1-cp311-cp311-macosx_11_0_arm64.whl (127.1 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pyfqmr-0.2.1-cp311-cp311-macosx_10_9_x86_64.whl (137.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pyfqmr-0.2.1-cp310-cp310-win_amd64.whl (112.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

pyfqmr-0.2.1-cp310-cp310-win32.whl (97.0 kB view hashes)

Uploaded CPython 3.10 Windows x86

pyfqmr-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (837.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (824.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.1-cp310-cp310-macosx_11_0_arm64.whl (127.2 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyfqmr-0.2.1-cp310-cp310-macosx_10_9_x86_64.whl (137.0 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pyfqmr-0.2.1-cp39-cp39-win_amd64.whl (112.7 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyfqmr-0.2.1-cp39-cp39-win32.whl (97.6 kB view hashes)

Uploaded CPython 3.9 Windows x86

pyfqmr-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (838.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (827.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.1-cp39-cp39-macosx_11_0_arm64.whl (127.7 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pyfqmr-0.2.1-cp39-cp39-macosx_10_9_x86_64.whl (137.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pyfqmr-0.2.1-cp38-cp38-win_amd64.whl (112.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyfqmr-0.2.1-cp38-cp38-win32.whl (97.2 kB view hashes)

Uploaded CPython 3.8 Windows x86

pyfqmr-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (846.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (834.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.1-cp38-cp38-macosx_11_0_arm64.whl (127.4 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pyfqmr-0.2.1-cp38-cp38-macosx_10_9_x86_64.whl (137.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pyfqmr-0.2.1-cp37-cp37m-win_amd64.whl (112.2 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

pyfqmr-0.2.1-cp37-cp37m-win32.whl (97.0 kB view hashes)

Uploaded CPython 3.7m Windows x86

pyfqmr-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (808.3 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (793.7 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.1-cp37-cp37m-macosx_10_9_x86_64.whl (136.6 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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