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.2.tar.gz (31.3 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.2-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.2-cp314-cp314-macosx_15_0_arm64.whl (882.2 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

diode-1.1.2-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.2-cp313-cp313-macosx_15_0_arm64.whl (881.7 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

diode-1.1.2-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.2-cp312-cp312-macosx_15_0_arm64.whl (881.8 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

diode-1.1.2-cp39-cp39-macosx_15_0_arm64.whl (880.1 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for diode-1.1.2.tar.gz
Algorithm Hash digest
SHA256 4fcb2ca63a6e05de309e885b2a4cfd5b0ea86d624c7b25fe63231d570069489b
MD5 1344f23b9f6ce28aa80f84349d8257bb
BLAKE2b-256 7b029b57b3793188c0f0b478d5829bbb237cded43867dd5a934867e142d229b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diode-1.1.2-cp314-cp314-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 d6627c0666b7bfcefc47c66945182f6e12b2fdc255fe034c02457c17132c8351
MD5 eaa6a05e4f909cb28453534e9874eadd
BLAKE2b-256 1da678b9a73a628d0d59afc9a80fb380e188203e7476c1c2dc44bdf650554cbd

See more details on using hashes here.

File details

Details for the file diode-1.1.2-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for diode-1.1.2-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5154a69f4a3aa491f0d3c3da45181a109dab333e872a3e96dac25cab7adc4cfa
MD5 cf3060a0c29be81cbeb6a1e2a2f3a6e0
BLAKE2b-256 338c62dea50c021149ed38ea4581a8c32ab135f76bde67ab98f06b58345624ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diode-1.1.2-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 2193bc1fbf25d09b4a4c9ac93d3e4f0bc20088acc8b3b65ab80710a336ba10f5
MD5 c8eda1ed265122ce9415e009790603c0
BLAKE2b-256 ac79fe0526c462d17dd7208b101662895b1bd2d1e21e3d37ee9df3d79f0f1de3

See more details on using hashes here.

File details

Details for the file diode-1.1.2-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for diode-1.1.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f2178b6db85c47e0f59a2007d4ae9465faf0d80bf3b67ff6376398d215577739
MD5 6a995c3db76a881f445b0dfc69139925
BLAKE2b-256 89f2ce90ccc78bc590282f6e751a62340cf77233f26d134b2893bd832237a9e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diode-1.1.2-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 8e030f7ec72e590e37197bec4c2c91f0303afc3934d84609736bf04ee47a78a6
MD5 121aea879f5368adf1bb632df8e615d7
BLAKE2b-256 e8ba79616000582fd1f2bab13fcdb7dfe173407f783a02cfda7f0c4b5737d194

See more details on using hashes here.

File details

Details for the file diode-1.1.2-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for diode-1.1.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1dd16eef354c66d6dd19b5ce5370e37455a55ae7c560f1abbe07290d82c8a536
MD5 5d34e3a13e98c376c402407e5ccb298c
BLAKE2b-256 62a5d469e6b748213e6fb27e10d95b05e3a23ba9801ba4e29ef8ba03e5bc251b

See more details on using hashes here.

File details

Details for the file diode-1.1.2-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

  • Download URL: diode-1.1.2-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

Hashes for diode-1.1.2-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c9037a06f586326d7f7f3ba442227f65636795e69e0fb18ae9ec64d3607a28f7
MD5 eb07a2915000d2e3f71826d049b3de7d
BLAKE2b-256 243b37f5439bd6737e3f07140aa36cc01a8611e3ca030666b93aeabf65672427

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