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 ]
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
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.1.3.tar.gz.
File metadata
- Download URL: diode-1.1.3.tar.gz
- Upload date:
- Size: 50.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62e473d9a939d1a16ca3b9a16c85228cf227862e8ea8fee7b5fc456bc0ce8bb3
|
|
| MD5 |
41d0fe1c95446277fc42f35b6b65fc1b
|
|
| BLAKE2b-256 |
c44f894294711af589b08aee9e145e151480f0401b2622c9122cec4e10add0f9
|
File details
Details for the file diode-1.1.3-cp314-cp314-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.1.3-cp314-cp314-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.8 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.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c30b603996352053270d40613a01f9ce588a8a1804c9b077f42d6ce48e73cb0e
|
|
| MD5 |
4369891c9794d359c3aa65a445e49cd4
|
|
| BLAKE2b-256 |
c4e8b726b7ce5662a806c6c2de7ec3c90d34033f202011342ccb7415e2da46c1
|
File details
Details for the file diode-1.1.3-cp314-cp314-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.1.3-cp314-cp314-macosx_15_0_arm64.whl
- Upload date:
- Size: 881.8 kB
- Tags: CPython 3.14, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a11557b3a0f18fac3aa3c278e07ee44554a79154a08c5b0f1dd26429e9dbb9e3
|
|
| MD5 |
1ac221127c0bfbe9c892950e13b6ffdb
|
|
| BLAKE2b-256 |
17a3eda74e6778fabec0e96b8e87e4dce8059331733e76a95a1bc5508a92b779
|
File details
Details for the file diode-1.1.3-cp313-cp313-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.1.3-cp313-cp313-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.8 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.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e9972459a35f0c1126f79b1898765253b7ce5eab956fa015c2e39a64c40334c
|
|
| MD5 |
452973a69637dafb736084c9b821090f
|
|
| BLAKE2b-256 |
4355791c7a142851fd2b4cd79f3518c1f681f62e8532b5510d051a08c2b591c2
|
File details
Details for the file diode-1.1.3-cp313-cp313-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.1.3-cp313-cp313-macosx_15_0_arm64.whl
- Upload date:
- Size: 881.5 kB
- Tags: CPython 3.13, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c72a2c7e7c9d245010a248fd3374b14528d2c51588b4a19c141977a013d25bb
|
|
| MD5 |
9180bfd6b07764596d72c6cf23dad271
|
|
| BLAKE2b-256 |
c4d5e9350006564fc08af6bba6c623d2ea4620a70144a12e81931161ac1d1d88
|
File details
Details for the file diode-1.1.3-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.1.3-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.8 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.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaaa64441ef706283cdab2b7563e20cebeaee4169c5669ed9e49da247427c653
|
|
| MD5 |
fef4116ee9780dc1230b074fd737d70d
|
|
| BLAKE2b-256 |
a07062da5720eaf391bebb4336617736de1e43b7600bf6f02c00b0abbd262bac
|
File details
Details for the file diode-1.1.3-cp312-cp312-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.1.3-cp312-cp312-macosx_15_0_arm64.whl
- Upload date:
- Size: 881.4 kB
- Tags: CPython 3.12, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a81e4a1142f34adb36634daf9a94c6bb3f60e83cab0844579f6851911c3b386e
|
|
| MD5 |
21b10b0879efd200efe9362fa4cbe4bb
|
|
| BLAKE2b-256 |
6faa61a1f95449038f5e7dec7f659481ddec337db4e0e64b701c235a7beb3688
|
File details
Details for the file diode-1.1.3-cp311-cp311-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.1.3-cp311-cp311-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.8 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.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35e8999d499cc2cf27e572853f4d88af6781d46f76faea9822987627561e77bf
|
|
| MD5 |
aefbc40e35a5cb85f2e5f3e37134ad8a
|
|
| BLAKE2b-256 |
0b42198c1ebd5c403fb4d55dd9fa827e0dea28da72ba425764bc96eac07e1f13
|
File details
Details for the file diode-1.1.3-cp311-cp311-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.1.3-cp311-cp311-macosx_15_0_arm64.whl
- Upload date:
- Size: 881.1 kB
- Tags: CPython 3.11, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f524f2fdf135d44598172d043b8a4e7a6c55266d26e2edc4c3eb88b206e02d07
|
|
| MD5 |
9684ebd23fee4a631ea27604839d9cb2
|
|
| BLAKE2b-256 |
4a9816981b82442f0b58b86b5caf5e2a810b8c28e01cb79c85573d1bec814a58
|
File details
Details for the file diode-1.1.3-cp310-cp310-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.1.3-cp310-cp310-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.8 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.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eed097dc9329f75fec84625be42e0aa122ad8f2bf7531c28d85d9be75d3f227c
|
|
| MD5 |
1cf38920cadc44b3d1c5849f01c6fe6a
|
|
| BLAKE2b-256 |
0343d06a60bb88b4a089df6b86eff00be3f64fa5c649bd6e1106ba297686e810
|
File details
Details for the file diode-1.1.3-cp310-cp310-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.1.3-cp310-cp310-macosx_15_0_arm64.whl
- Upload date:
- Size: 880.0 kB
- Tags: CPython 3.10, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e4671135f3988a3e2b1764b986286cf0d3918ec9f0a7c4176208b690a2e4f26
|
|
| MD5 |
899bfd8fe6e828a668e599ce67c79098
|
|
| BLAKE2b-256 |
33182285d202a588584548f26fed12a2e4c337e488ec7387458d5373c859af67
|
File details
Details for the file diode-1.1.3-cp39-cp39-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: diode-1.1.3-cp39-cp39-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.8 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.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c542f1ec2be61063b7d05bcc6b030d40986489620699d54aa6654af40af5e32
|
|
| MD5 |
ac4dcc72602f8bd415dec1f5dbf7b427
|
|
| BLAKE2b-256 |
e59943e4066e0ab6514079042fea06ab1c1d9b8faf28a60d9518f54bc6907eda
|
File details
Details for the file diode-1.1.3-cp39-cp39-macosx_15_0_arm64.whl.
File metadata
- Download URL: diode-1.1.3-cp39-cp39-macosx_15_0_arm64.whl
- Upload date:
- Size: 880.1 kB
- Tags: CPython 3.9, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37eed61b3d4b18517d1775ba4a7c6a45068e7b8da158cc8f1984df3bae591bb0
|
|
| MD5 |
0092ca6a7eca92c581e52a41ca5eb006
|
|
| BLAKE2b-256 |
a344f4ccffa2cf5d3219ab6d861ff90fb5131c92bc20a1f2272fecb7b21f9c0b
|