alpha shape generator using CGAL
Project description
DioDe uses CGAL to generate alpha shapes filtrations in a format that Dionysus understands. DioDe is not integrated into Dionysus because of licensing restrictions (Dionysus is under BSD, DioDe is under GPL because of its dependence on CGAL). It supports both ordinary and weighted alpha shapes.
Dependencies:
Get, Build, Install
The simplest way to install Diode as a Python package:
pip install --verbose diode
or from this repository directly:
pip install --verbose git+https://github.com/mrzv/diode.git
Alternatively, you can clone and build everything by hand. To get Diode, either clone its repository:
git clone https://github.com/mrzv/diode.git
or download it as a Zip archive.
To build the project:
mkdir build cd build cmake .. make
To use the Python bindings, either launch Python from .../build/bindings/python or add this directory to your PYTHONPATH variable, by adding:
export PYTHONPATH=.../build/bindings/python:$PYTHONPATH
to your ~/.bashrc or ~/.zshrc.
Usage
NB: a remark below about using exact computation. This issue is especially important when working with degenerate point sets (e.g., repeated copies of a fundamental domain in a periodic point set).
See examples/generate_alpha_shape.cpp and examples/generate_weighted_alpha_shape.cpp for C++ examples.
In Python, use diode.fill_alpha_shapes(...) and diode.fill_weighted_alpha_shapes(...) to fill a list of simplices, together with their alpha values:
>>> import diode >>> import numpy as np >>> points = np.random.random((100,3)) >>> simplices = diode.fill_alpha_shapes(points) >>> print(simplices) [([13L], 0.0), ([18L], 0.0), ([59L], 0.0), ([10L], 0.0), ([72L], 0.0), ..., ([91L, 4L, 16L, 49L], 546.991052812204), ([49L, 62L], 1933.2257381777533), ([62L, 34L, 49L], 1933.2257381777533), ([62L, 91L, 49L], 1933.2257381777533), ([62L, 91L, 34L, 49L], 1933.2257381777533)] >>> weighted_points = np.random.random((100,4)) >>> simplices2 = diode.fill_weighted_alpha_shapes(weighted_points) >>> print(simplices2) [([24L], -0.987214836816236), ([35L], -0.968749877102265), ([50L], -0.9673151804059413), ([47L], -0.9640549893422644), ([71L], -0.9639978806827709), ([24L, 50L], -0.9540965704765515), ... ([54L, 10L], 29223.611044169364), ([10L, 54L, 43L], 29223.611044169364), ([13L, 10L, 54L], 29223.611044169364), ([13L, 10L, 54L, 43L], 29223.611044169364)]
The list can be passed to Dionysus to initialize a filtration:
>>> import dionysus >>> f = dionysus.Filtration(simplices) >>> print(f) Filtration with 2287 simplices
DioDe also includes diode.fill_periodic_alpha_shapes(...), which generates the alpha shape for a point set on a periodic cube, by default [0,0,0] - [1,1,1]. (In the periodic case, it may happen that CGAL reports each simplex multiple times. However, passing the result to dionysus.Filtration will take care of the duplicates.):
>>> simplices_periodic = diode.fill_periodic_alpha_shapes(points) >>> f_periodic = dionysus.Filtration(simplices_periodic) >>> print(f_periodic) Filtration with 2912 simplices >>> for s in f_periodic: print(s) <0> 0 <1> 0 <2> 0 <3> 0 ... <77,94,97> 0.0704355 <46,77,94,97> 0.0708062 <30,77,94,97> 0.0708474 <18,65,79> 0.0715833 <18,64,65,79> 0.0715833 <18,65,79,99> 0.0725366
When using CGAL version at least 4.11, DioDe includes diode.fill_weighted_periodic_alpha_shapes(...), which generates the alpha shape for a weighted point set on a periodic cube:
>>> weighted_points[:,3] /= 64 >>> simplices_weighted_periodic = diode.fill_weighted_periodic_alpha_shapes(weighted_points)
diode.circumcenter(...) can be used to compute the circumcenter of a tetrahedron in 3D:
>>> tet = np.random.random((4,3)) >>> center = diode.circumcenter(tet) >>> print(center) [-0.00752673 0.14213101 1.0060982 ]
Delaunay combinatorics (no alpha values)
Some consumers only need the simplicial complex (the Delaunay triangulation, which for full-dimensional input is the same simplex set as the alpha complex) and recompute their own filtration values – for example a differentiable Cech-Delaunay filtration that recomputes values as minimum-enclosing-ball radii. For those, diode.fill_delaunay_arrays(...) returns just the combinatorics, skipping all of CGAL’s per-simplex Gabriel/circumradius work (about 1.6x faster than the alpha path in 2D and 4x in 3D):
>>> verts_by_dim = diode.fill_delaunay_arrays(points)
The result is a list of per-dimension NumPy arrays, where verts_by_dim[d] is an (n_d, d+1) int64 array of vertex ids (dimension 0 = vertices, 1 = edges, and so on). diode.fill_delaunay(...) is the equivalent list-of-tuples form. diode.fill_periodic_delaunay_arrays(...) / diode.fill_periodic_delaunay(...) are the periodic counterparts (over the cube [from, to], default the unit cube). All four take the same exact argument as the alpha-shape functions.
Exactness
All functions take an argument exact, set to False by default. The argument determines a choice of the kernel in CGAL (Exact_predicates_inexact_constructions_kernel vs Exact_predicates_exact_constructions_kernel). exact = True guarantees correctness of the output; exact = False is faster, but can sometimes fail (not even produce a simplicial complex). It’s possible to run the two versions adaptively by running the default exact = False version first, and if the result is not a simplicial complex, then run exact = True. This should be the best of both worlds.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file diode-1.2.1.tar.gz.
File metadata
- Download URL: diode-1.2.1.tar.gz
- Upload date:
- Size: 86.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9299e2c6e99c02c5c1e3bd442669f8333bfcc58c7fffe457eb35a3e6444e0913
|
|
| MD5 |
afa6671b4fdc8f81971575befac8edf1
|
|
| BLAKE2b-256 |
0dedcdb0afe3942afca2acd0eab71becb375ac480ba0a5af5bef25f158f34913
|
File details
Details for the file diode-1.2.1-cp314-cp314-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.2.1-cp314-cp314-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.14, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07bb16b28d802c4c29ce40a77da65858c8ef403721761e2d394da98d437593d7
|
|
| MD5 |
f8cbc7b3294a62987fbe5237bd72c581
|
|
| BLAKE2b-256 |
c258f40aa921bd69c5ab778d02e85d30eceb70ed1a7ede4184e23c6989abb12b
|
File details
Details for the file diode-1.2.1-cp314-cp314-macosx_26_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp314-cp314-macosx_26_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.14, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d480933ae483c53bf398a54c147da4849828ff592ee81084482e0ccc92c60c1c
|
|
| MD5 |
332f351b76a40be38b43bb78f2cb354b
|
|
| BLAKE2b-256 |
d0f744e8fc165bbb0980eed80d4451b5db04f72baa74e703b71285e12df24222
|
File details
Details for the file diode-1.2.1-cp314-cp314-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp314-cp314-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.14, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f40e72157d623bb02717d31f2667fe0fad26f9663169bc263d319039cd0685dd
|
|
| MD5 |
98bb36067e53a55dc579aaa033cc291c
|
|
| BLAKE2b-256 |
9c9314a75577062a0cf8c95c098ac54de719398e53615ca3b3de7eb367904740
|
File details
Details for the file diode-1.2.1-cp313-cp313-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.2.1-cp313-cp313-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
734dffead212e67125312292e1e578c3ae7ebd41a0a8af16556e7db15df28885
|
|
| MD5 |
f11d5fd370a97ebdcfbcdc041eaa0700
|
|
| BLAKE2b-256 |
f4a335ba271c70b27d1976707ef8788cf52445517d04fd447849f429c2917806
|
File details
Details for the file diode-1.2.1-cp313-cp313-macosx_26_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp313-cp313-macosx_26_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.13, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7526463c3244021ba004b6cfcb7ea9d2edf7bcaaa5c89395ac742571300f7ca9
|
|
| MD5 |
2a162454f4ab282b57989c8d019534d4
|
|
| BLAKE2b-256 |
14e6ab376aab903ed2e6697aebda916665c4cbbe8fde566d3f40ee9e93750e53
|
File details
Details for the file diode-1.2.1-cp313-cp313-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp313-cp313-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.13, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5a32d9507f71f25b4101fb9062d3580d4bdfa7d97b84e949799beae35d1fd0e
|
|
| MD5 |
4022ab8c817621cec96e82c98e967494
|
|
| BLAKE2b-256 |
4da2fb12cf30b05827aab742b3db11b6f5be870e0c52649d493affac0f144721
|
File details
Details for the file diode-1.2.1-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.2.1-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd60596336661e81ed5e5e22b2d40166b4ea082dd7d29efdb7c86fe4b9d78054
|
|
| MD5 |
92156c56c1582afbd69928fbd75e8863
|
|
| BLAKE2b-256 |
e61ed358c0b72b85e31a96c80555d7c5d5996fbd78ce28f44b0a641a22a41a4e
|
File details
Details for the file diode-1.2.1-cp312-cp312-macosx_26_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp312-cp312-macosx_26_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.12, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64e8ff0359c9e949236d18fa61c367b435a8339dc33c6c944ddbdc694f21dbaa
|
|
| MD5 |
6b08b244fb6e5dc39567e3cee407947e
|
|
| BLAKE2b-256 |
dd9aa7898b09d31546e4ebda4d607a8ab5af535e5c45e8cc6148019dc770e9a4
|
File details
Details for the file diode-1.2.1-cp312-cp312-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp312-cp312-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.12, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d810ac5295810728c03e5acb9c290aa9803307d7a6fb86ba095f1d4085e98c7
|
|
| MD5 |
16393a9690ddf5793d277cb05346470b
|
|
| BLAKE2b-256 |
824c648e7d23036761bcbb5f05535116282d88f9cad2a3b656386a540849fcf2
|
File details
Details for the file diode-1.2.1-cp311-cp311-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.2.1-cp311-cp311-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44537cf21aad5b65a243449ef07f5912d8eb3c581e57f19fe17ff36272020fd7
|
|
| MD5 |
6a9e812876b3164f4f8bcb9f0f27778f
|
|
| BLAKE2b-256 |
c48225678ce46940a9b142df13b87ba5ad75874d7c1d0a4389468ff192ee79e1
|
File details
Details for the file diode-1.2.1-cp311-cp311-macosx_26_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp311-cp311-macosx_26_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.11, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
990435651cc130d89fa51c3202b248ecbc24a55a07d44f5609731d244bb3f345
|
|
| MD5 |
3d17a7b301e893dfccf3cc3384ddf4b2
|
|
| BLAKE2b-256 |
95206effe976b869da03ba9f956f5a70df0a7685feebb2983386360e7d24ead6
|
File details
Details for the file diode-1.2.1-cp311-cp311-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp311-cp311-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.11, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a8a57d3100647c86222ed88982cbceec48446e89aec319466ff41514ca40e5a
|
|
| MD5 |
b6fa3dcc1c3f8ea983547199a7233f26
|
|
| BLAKE2b-256 |
85c86f39e695ac3bf286ddaf51f22d927f77e4a5427e30739700f94fbfb0a10b
|
File details
Details for the file diode-1.2.1-cp310-cp310-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.2.1-cp310-cp310-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60355708791cf4442b9277c423f1e588145344c4a40f67e7802dce5a5431fee8
|
|
| MD5 |
f38295a63ed11afdee2e95ce405115ac
|
|
| BLAKE2b-256 |
792f4d9ada23771ec1ac937df97f7e5218ca22cd63d6eeffac6aa889abe3c2bc
|
File details
Details for the file diode-1.2.1-cp310-cp310-macosx_26_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp310-cp310-macosx_26_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.10, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e654f5685978a59cd5b84a3a62bfe17c994bcf340ffb5bb5143ee01b70dd34f
|
|
| MD5 |
6d1abc7a4cbd931f2419bd0a58ddb07c
|
|
| BLAKE2b-256 |
d7dec200e78fef74680eab3da3e8e382b1400e06e9010cebe65a2e99f4f912f5
|
File details
Details for the file diode-1.2.1-cp310-cp310-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp310-cp310-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.10, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77f02a624b0705312cb16c066abc1eb7009735b75248859002ab65092c9f1d14
|
|
| MD5 |
2830f0f183b3e531ba34ae48761fcebf
|
|
| BLAKE2b-256 |
ee1e45a120e32b77047edec4ddeb75c649578b1956c1dfe8d31df059356447dd
|
File details
Details for the file diode-1.2.1-cp39-cp39-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.2.1-cp39-cp39-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.9, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab8a18126b4b679fb03f985ad7691c02a3e24310cc0d0d53327bb6a9f623b9af
|
|
| MD5 |
f48ded38aa159001dd071fbfd6e54977
|
|
| BLAKE2b-256 |
eb6968c9f443eb15d1a1241c184ce864c89468472b2096028a6032e028181382
|
File details
Details for the file diode-1.2.1-cp39-cp39-macosx_26_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp39-cp39-macosx_26_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.9, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1efb8b4bdd1a602030178b9f345d46331160b0b34f418d297a757df4b640f8e3
|
|
| MD5 |
024cee7b2269223a6f9fa45ed8c0d18f
|
|
| BLAKE2b-256 |
564758247430928a98026e7e87d723e92c9f6707b54c640a2da79d34274cbb80
|
File details
Details for the file diode-1.2.1-cp39-cp39-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.2.1-cp39-cp39-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.9, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cb919f54649cfb8b039f031431356694189eb231f969452d758125e0c6b9b19
|
|
| MD5 |
020838c2fb52c1530aa541cc92bcd8b7
|
|
| BLAKE2b-256 |
06f4879af5a26a459a4e28609ed4bb17f3adb420bc47fd4718e09573d3c5efcd
|