Skip to main content

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

diode-1.1.4.tar.gz (55.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

diode-1.1.4-cp314-cp314-manylinux_2_39_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.39+ x86-64

diode-1.1.4-cp314-cp314-macosx_26_0_arm64.whl (919.0 kB view details)

Uploaded CPython 3.14macOS 26.0+ ARM64

diode-1.1.4-cp313-cp313-manylinux_2_39_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

diode-1.1.4-cp313-cp313-macosx_26_0_arm64.whl (918.6 kB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

diode-1.1.4-cp312-cp312-manylinux_2_39_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

diode-1.1.4-cp312-cp312-macosx_26_0_arm64.whl (918.5 kB view details)

Uploaded CPython 3.12macOS 26.0+ ARM64

diode-1.1.4-cp311-cp311-manylinux_2_39_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

diode-1.1.4-cp311-cp311-macosx_26_0_arm64.whl (917.7 kB view details)

Uploaded CPython 3.11macOS 26.0+ ARM64

diode-1.1.4-cp310-cp310-manylinux_2_39_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

diode-1.1.4-cp310-cp310-macosx_26_0_arm64.whl (916.4 kB view details)

Uploaded CPython 3.10macOS 26.0+ ARM64

diode-1.1.4-cp39-cp39-manylinux_2_39_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.39+ x86-64

diode-1.1.4-cp39-cp39-macosx_26_0_arm64.whl (916.7 kB view details)

Uploaded CPython 3.9macOS 26.0+ ARM64

File details

Details for the file diode-1.1.4.tar.gz.

File metadata

  • Download URL: diode-1.1.4.tar.gz
  • Upload date:
  • Size: 55.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for diode-1.1.4.tar.gz
Algorithm Hash digest
SHA256 e3d2d8cee789cf7db5754528d4828a3b3a1c3807d55136368cf716444e284930
MD5 d4bac1c4114b9d27f3ad7ae3fee71971
BLAKE2b-256 540c02e5572b133118942968d76eeb406d35f5220eceed03bf08fbdb8984274c

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp314-cp314-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp314-cp314-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 bb0dc556f26fff72d83f2b5178fb9eeba2135c34f134e18e0491c8555321690f
MD5 02c9b1e5eeae2379a3e882f1e9856f55
BLAKE2b-256 104a1f4de599b6e0590b629f0fe4b030ae38199ddea0567323efdb460235653e

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp314-cp314-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp314-cp314-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 4e803bf157a6ceef076bab122e93fc6ff09353854de79ed1b1bba476d40a1ae4
MD5 0303117bf25fa1a8f6e93a943acb7850
BLAKE2b-256 9cbb3bebfbd4aad87c33128d50df424610fd776421cc90d105ab637c4fc61093

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 410441e70386f7f47e3d74de126d9c8aa4d90169aa3e736e8ac45a19f6b29726
MD5 893c822f65627b71d5714381178270b2
BLAKE2b-256 75dd76c8ab2b59d119722721612ed24b5284fccfe8475a740813ed25c5d584e7

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp313-cp313-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 6fe93645237c9ebf773aada89ccfb546b30487ad36e92ec20da5dd0f800878d9
MD5 9ff2b019ad8513d8f8c8d0f45c3c0267
BLAKE2b-256 7992de3e23cf4870b3b7da1112d0effd15505da75f9810ec254fd0207fec8952

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 ea1c3610ecbc9ffc56dccf26465e4ffe4969086005c4f8935d6e974b493547e1
MD5 9b687b35c1203e0a1c1365bbf38418eb
BLAKE2b-256 5dd04c5fde0f4c9bc4dcb3973cb561d9159c2a962d28ced003e9a6081622aa65

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp312-cp312-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp312-cp312-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 f4c57e88304ca0c31d54ad5f9a1a25968f30a316e62c85c57fd39cf25415c102
MD5 a1005ffdb818ac4930e206e3a9dcebe5
BLAKE2b-256 56e7ebcdac86595ea1b55b76cbe51226dd5cd67a5d8629bf68bdd7dbe6851335

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 e9a9a46ec92323bbca2d7d2a48259b4273dd6b39a3fee0bf7dc09ff0b0326b8e
MD5 a4e7f79b474f28565bfebe250db25c16
BLAKE2b-256 6ab061f7d1308f50059eb0cbc68cddd54a4aca86e8ce03602602a0b81c6cef1a

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp311-cp311-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp311-cp311-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 7d3659b40a0cb79070324452c001ca194f7dc7a22acf0ec0be4e92326200663d
MD5 b4a6bf69227149f3eb050cf29c203bca
BLAKE2b-256 e0c6d0fa8b523aed96de64d915cdcec88a4eca0a3ac9cee7e5aa6bfeb31bebc4

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 bd164c705ec3a57cfb52cb435a8b2c81016503046067b4a777a160b46bf7060b
MD5 d66cce3b761d23c6b9bf4f6f17c05e35
BLAKE2b-256 f098c3739c8aa4bd6c863555f79c01c101069e92757fb9c070a978f913522f38

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp310-cp310-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp310-cp310-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 2640bc5f64a32fd42328939766c59ae6ce0eb8c3c018bb5805ef8226e90c8da4
MD5 366e0883cfc8dfac166dcc93a197edd2
BLAKE2b-256 11809fee1721bdd09e57be3fc40b8894f1fff6e160cc209e4d69a0abfd33389d

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp39-cp39-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for diode-1.1.4-cp39-cp39-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 7a01df5c6a1563cbd7b0d1ff23669df6cb31517b8dd6b17991b55adab66fb6d7
MD5 aebb8938226a15ea06eda9587677b0d2
BLAKE2b-256 06ce9a25a0b752028e836b9a6a19eb4f6e29690cb7e1336482cbe07a4fd756ad

See more details on using hashes here.

File details

Details for the file diode-1.1.4-cp39-cp39-macosx_26_0_arm64.whl.

File metadata

  • Download URL: diode-1.1.4-cp39-cp39-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 916.7 kB
  • Tags: CPython 3.9, macOS 26.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for diode-1.1.4-cp39-cp39-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 d6ef773227549e3a4e1c0cd26978724220932f668bec51de6cd76c8db67e666a
MD5 a800f97db6d3b999ec16becad5a4b1fe
BLAKE2b-256 385c35c34bba87e5680dfd6c3a365ebc696a27513e52c7637e9528880d3e3783

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page