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.0-cp312-cp312-win_amd64.whl (111.5 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

pyfqmr-0.2.0-cp312-cp312-win32.whl (96.2 kB view hashes)

Uploaded CPython 3.12 Windows x86

pyfqmr-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (875.3 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (860.4 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (128.8 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pyfqmr-0.2.0-cp312-cp312-macosx_10_9_x86_64.whl (136.7 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

pyfqmr-0.2.0-cp311-cp311-win_amd64.whl (97.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

pyfqmr-0.2.0-cp311-cp311-win32.whl (86.0 kB view hashes)

Uploaded CPython 3.11 Windows x86

pyfqmr-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (811.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (798.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (114.2 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pyfqmr-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl (128.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pyfqmr-0.2.0-cp310-cp310-win_amd64.whl (98.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

pyfqmr-0.2.0-cp310-cp310-win32.whl (86.5 kB view hashes)

Uploaded CPython 3.10 Windows x86

pyfqmr-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (790.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (775.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (115.5 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyfqmr-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl (128.6 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pyfqmr-0.2.0-cp39-cp39-win_amd64.whl (99.7 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyfqmr-0.2.0-cp39-cp39-win32.whl (86.9 kB view hashes)

Uploaded CPython 3.9 Windows x86

pyfqmr-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (805.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (790.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.0-cp39-cp39-macosx_11_0_arm64.whl (116.8 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pyfqmr-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl (130.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pyfqmr-0.2.0-cp38-cp38-win_amd64.whl (99.8 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyfqmr-0.2.0-cp38-cp38-win32.whl (86.9 kB view hashes)

Uploaded CPython 3.8 Windows x86

pyfqmr-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (804.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyfqmr-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (788.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.0-cp38-cp38-macosx_11_0_arm64.whl (114.0 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pyfqmr-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl (128.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pyfqmr-0.2.0-cp37-cp37m-win_amd64.whl (98.8 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

pyfqmr-0.2.0-cp37-cp37m-win32.whl (85.8 kB view hashes)

Uploaded CPython 3.7m Windows x86

pyfqmr-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (772.0 kB view hashes)

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

pyfqmr-0.2.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (756.3 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

pyfqmr-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl (128.2 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