This is a python wrapping of the Fast-Quadric-Mesh-Simplification Library. Having arrived at the same problem as the original author, but needing a Python library, this project seeks to extend the work of the original library while adding integration to Python and the PyVista project.
Basic Usage
The basic interface is quite straightforward and can work directly with arrays of points and triangles:
points = [[ 0.5, -0.5, 0.0],
[ 0.0, -0.5, 0.0],
[-0.5, -0.5, 0.0],
[ 0.5, 0.0, 0.0],
[ 0.0, 0.0, 0.0],
[-0.5, 0.0, 0.0],
[ 0.5, 0.5, 0.0],
[ 0.0, 0.5, 0.0],
[-0.5, 0.5, 0.0]]
faces = [[0, 1, 3],
[4, 3, 1],
[1, 2, 4],
[5, 4, 2],
[3, 4, 6],
[7, 6, 4],
[4, 5, 7],
[8, 7, 5]]
points_out, faces_out = fast_simplification.simplify(points, faces, 0.5)
Advanced Usage
This library supports direct integration with VTK through PyVista to provide a simplistic interface to the library. As this library provides a 4-5x improvement to the VTK decimation algorithms.
>>> from pyvista import examples
>>> mesh = examples.download_nefertiti()
>>> out = fast_simplification.simplify_mesh(mesh, target_reduction=0.9)
Compare with built-in VTK/PyVista methods:
>>> fas_sim = fast_simplification.simplify_mesh(mesh, target_reduction=0.9)
>>> dec_std = mesh.decimate(0.9) # vtkQuadricDecimation
>>> dec_pro = mesh.decimate_pro(0.9) # vtkDecimatePro
>>> pv.set_plot_theme('document')
>>> pl = pv.Plotter(shape=(2, 2), window_size=(1000, 1000))
>>> pl.add_text('Original', 'upper_right', color='w')
>>> pl.add_mesh(mesh, show_edges=True)
>>> pl.camera_position = cpos
>>> pl.subplot(0, 1)
>>> pl.add_text(
... 'Fast-Quadric-Mesh-Simplification\n~2.2 seconds', 'upper_right', color='w'
... )
>>> pl.add_mesh(fas_sim, show_edges=True)
>>> pl.camera_position = cpos
>>> pl.subplot(1, 0)
>>> pl.add_mesh(dec_std, show_edges=True)
>>> pl.add_text(
... 'vtkQuadricDecimation\n~9.5 seconds', 'upper_right', color='w'
... )
>>> pl.camera_position = cpos
>>> pl.subplot(1, 1)
>>> pl.add_mesh(dec_pro, show_edges=True)
>>> pl.add_text(
... 'vtkDecimatePro\n11.4~ seconds', 'upper_right', color='w'
... )
>>> pl.camera_position = cpos
>>> pl.show()
Comparison to other libraries
The pyfqmr library wraps the same header file as this library and has similar capabilities. In this library, the decision was made to write the Cython layer on top of an additional C++ layer rather than directly interfacing with wrapper from Cython. This results in a mild performance improvement.
Reusing the example above:
Set up a timing function.
>>> import pyfqmr
>>> vertices = mesh.points
>>> faces = mesh.faces.reshape(-1, 4)[:, 1:]
>>> def time_pyfqmr():
... mesh_simplifier = pyfqmr.Simplify()
... mesh_simplifier.setMesh(vertices, faces)
... mesh_simplifier.simplify_mesh(
... target_count=out.n_faces, aggressiveness=7, verbose=0
... )
... vertices_out, faces_out, normals_out = mesh_simplifier.getMesh()
... return vertices_out, faces_out, normals_out
Now, time it and compare with the non-VTK API of this library:
>>> timeit time_pyfqmr()
2.75 s ± 5.35 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
>>> timeit vout, fout = fast_simplification.simplify(vertices, faces, 0.9)
2.05 s ± 3.18 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
Additionally, the fast-simplification library has direct plugins to the pyvista library, making it easy to read and write meshes:
>>> import pyvista
>>> import fast_simplification
>>> mesh = pyvista.read('my_mesh.stl')
>>> simple = fast_simplification.simplify_mesh(mesh)
>>> simple.save('my_simple_mesh.stl')
Since both libraries are based on the same core C++ code, feel free to use whichever gives you the best performance and interoperability.
Release files for fast-simplification 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fast_simplification-0.1.0.tar.gz | 90.7 kB | Details |
Built distributions (wheels)
Total release size: 5.1 MB
Release files / fast_simplification-0.1.0.tar.gz
| Download URL | fast_simplification-0.1.0.tar.gz |
|---|---|
| Size | 90.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da64a836abe0558cf70ace96f6e1ce4050768110d55459df4b93aa7a392f00e4
|
|
BLAKE2b-256 checksum How to use checksums |
3c72c774e85be2445d5d63af0f17fb08cac46a2e4b335bcfcf60a956614d3983
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.16
|
Release files / fast_simplification-0.1.0-cp311-cp311-win_amd64.whl
| Download URL | fast_simplification-0.1.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 87.2 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
baa6a13d08feb77d41b20d1a6989c5794891348b56d792f7ec91161cc654463f
|
|
BLAKE2b-256 checksum How to use checksums |
866360b0f172c89d989466a51ced9ef9623247be3b2793e732930d5be848b5a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | fast_simplification-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 674.5 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
49de805ab1a6c0bba060ba454b3f3f9b05cda1b2a1bfb6c48722caaaa721e887
|
|
BLAKE2b-256 checksum How to use checksums |
46eab825f1343c2afbcebcaaf441a42905882b3f6003abeb34e9f55215a66666
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | fast_simplification-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 103.4 kB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
937a5d13b18e2e553b0dd45f96bc3158c4f708a8756a8547d7ac2e28a707c578
|
|
BLAKE2b-256 checksum How to use checksums |
d7c14f493c33569d49b16bbeb263be58f813dab62d6a46e650cc40267499a9af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp311-cp311-macosx_10_9_universal2.whl
| Download URL | fast_simplification-0.1.0-cp311-cp311-macosx_10_9_universal2.whl |
|---|---|
| Size | 188.8 kB |
| Tags | CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
3f75d3c3c360e4af098b9fffcd2e0a8fa1d70f798301934a8cd6bab20cdfd0de
|
|
BLAKE2b-256 checksum How to use checksums |
240a08555fa301f28c12ac1fabea7b986e99d57f18b24a22c5d51b2725448e6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp310-cp310-win_amd64.whl
| Download URL | fast_simplification-0.1.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 87.9 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
239a0ac1fb4fcb3266f9b72d6c746496d4b3eaf6df7b441f34b8f816c66aaf38
|
|
BLAKE2b-256 checksum How to use checksums |
9cf9633d841f1c8871781adb8f50ab9ac7c8d3a1149421b20e5a67c3269f2953
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | fast_simplification-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 650.2 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
3090f174a9c90eeff35b1d944d6eb7ea24ada1e8c068174a4c91dafec32db00f
|
|
BLAKE2b-256 checksum How to use checksums |
9c107fcd9b96fc76cb2a73d0170ab3d593ee807264c67c7880db0ddfceb43d03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | fast_simplification-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl |
|---|---|
| Size | 105.1 kB |
| Tags | CPython 3.10 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
35b67409c819958ae6d5157d48eae38d65bc5275d9bd05c30ab43ed2d869c0d6
|
|
BLAKE2b-256 checksum How to use checksums |
3fa51ddd1c6cc23b0d43da33aa6ab42e30cfab86d5abfe009eb40fe39e7ea238
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp310-cp310-macosx_10_9_universal2.whl
| Download URL | fast_simplification-0.1.0-cp310-cp310-macosx_10_9_universal2.whl |
|---|---|
| Size | 192.2 kB |
| Tags | CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
7cce0f0f0fc55acd2becb20c308efd7bf89e65c8175db60b6d78cfc395d5abde
|
|
BLAKE2b-256 checksum How to use checksums |
1fb325113e297f6823b6a21a5cd43ae7a9449b62a799e913db46c6e394f374bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp39-cp39-win_amd64.whl
| Download URL | fast_simplification-0.1.0-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 89.2 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
728c2fc27c9cd8b33c79bd1690cb267f461d9601e8c43b16c408e4e3c0236b1c
|
|
BLAKE2b-256 checksum How to use checksums |
0e2066fcb31f29129a08ae6fcdd063b59978e4aaaeb352e10ace33bff726909c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | fast_simplification-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 659.5 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
f0f5d19fae32858d33adca2844f65470504358ee45b09ef02a601462d14349d6
|
|
BLAKE2b-256 checksum How to use checksums |
de7d96230bae8b1b7312800b9e217f97cd1079deea0f5ae10637876012359ff5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl
| Download URL | fast_simplification-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl |
|---|---|
| Size | 106.0 kB |
| Tags | CPython 3.9 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
8cf8dd091865a964087a4a118d34cae5fb7bfb12220d9b6145945445b1ff719c
|
|
BLAKE2b-256 checksum How to use checksums |
75f2ac833c55d5afb4cd58302c1ed384cb2e79b2c7802d02f73ef2b937774385
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp39-cp39-macosx_10_9_universal2.whl
| Download URL | fast_simplification-0.1.0-cp39-cp39-macosx_10_9_universal2.whl |
|---|---|
| Size | 193.7 kB |
| Tags | CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
51c933b9fe696bc07fe6dce0868b9dd899348a03ab220c199e441e8be1d3e7d3
|
|
BLAKE2b-256 checksum How to use checksums |
94ee42a954a142ec1422e3764c53d5c8339a321497a08d5ea35f1ea43af96cf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp38-cp38-win_amd64.whl
| Download URL | fast_simplification-0.1.0-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 89.3 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fa5e8e623d6b8d2828947b66dba208d7db6bc466bceb255b49f8355bec53660c
|
|
BLAKE2b-256 checksum How to use checksums |
af2ae5a75370b4f5b7f37d810efb5a68238ab5589d0ad05c7173213c831d41bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | fast_simplification-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 659.4 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
66aca7cc5b1f1187acd49c9da4946c9613d3b4694c9727fd825cc701124d297f
|
|
BLAKE2b-256 checksum How to use checksums |
5865051933b892ecf6527d08bf34081fbe642a5d619b441615046b29a0804c5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl
| Download URL | fast_simplification-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl |
|---|---|
| Size | 104.0 kB |
| Tags | CPython 3.8 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
00d93dc7008abf5655e6419ff2cc2150aeb0d8b3a7b15efa1fa49f36fd7fcca1
|
|
BLAKE2b-256 checksum How to use checksums |
52841144194ca72faf1113f3d3a0762ed1e9a63bb4b7a7e02fc00614807b9155
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp38-cp38-macosx_10_9_universal2.whl
| Download URL | fast_simplification-0.1.0-cp38-cp38-macosx_10_9_universal2.whl |
|---|---|
| Size | 189.7 kB |
| Tags | CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
a07da4f126e2d8e57b072ff7ae4f0bd94f09ada479677459395da2a29d962b4b
|
|
BLAKE2b-256 checksum How to use checksums |
c0abcf7dbc639a88aaa19a10945f3a66066cbc05b70379793fe4c24e38c948cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp37-cp37m-win_amd64.whl
| Download URL | fast_simplification-0.1.0-cp37-cp37m-win_amd64.whl |
|---|---|
| Size | 88.7 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6ddaa6ce5b92d34974a54a9b1e49b5a37d279a26c1ad713efb42390b5d76610b
|
|
BLAKE2b-256 checksum How to use checksums |
5b370131ba0076d42e693bf1ba47b2395844b5247471e1117bbbf4d46ffba6bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | fast_simplification-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 627.1 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
9771f8916ca3918396a1ce005a2fb3300b821b6a0f9e5453e4eddca10e06cb88
|
|
BLAKE2b-256 checksum How to use checksums |
e3d86c7b090929123dcf267982b9e7bea13268c2e6f6244d0ee3c192d9a4d49c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / fast_simplification-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
| Download URL | fast_simplification-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 104.3 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
30cfb6f22df0f8edfb873076d0b71dacc06731fb0dc5d3a71be735f88fb9726b
|
|
BLAKE2b-256 checksum How to use checksums |
934b1b6807fedb2c035be0f9a266bd1ca48da814ecdb1fc75a6618e0bc3bbbe2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|