Skip to main content

pode

Summary

pode is a Python library that implements an algorithm of Hert, S. and Lumelsky, V., 1998 for a polygon decomposition into separate parts depending on the area requirements.

Main features are

  • all calculations are robust for floating point numbers & precise for integral numbers (like int)
  • support for partition of convex/nonconvex polygons with/without holes
  • support for anchored partition, free partition, and a mixture of both where anchored polygon partition requires the resulting polygon parts to contain specified points called "anchors" or "sites", and free partition does not have any constraints on the resulting geometries.
  • most of the code is covered with property-based tests.

In what follows

  • python is an alias for python3.8 or any later version (python3.9 and so on).

Installation

Install the latest pip & setuptools packages versions:

python -m pip install --upgrade pip setuptools

User

Download and install the latest stable version from PyPI repository:

python -m pip install --upgrade pode

Developer

Download the latest version from GitHub repository

git clone https://github.com/LostFan123/pode.git
cd pode

Install dependencies:

poetry install

Usage

>>> from pode import divide, Contour, Point, Polygon, Requirement
>>> contour = Contour([Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)])
>>> polygon = Polygon(contour)
>>> requirements = [Requirement(0.5), Requirement(0.5, point=Point(1, 1))]
>>> parts = divide(polygon, requirements)
>>> parts[0].area == parts[1].area < polygon.area
True
>>> Point(1, 1) in parts[1]
True

Currently, the algorithm uses constrained Delaunay triangulation to form convex parts which are used internally for a convex-polygon partition. This triangulation, however, affects the resulting partition. The resulting parts can have zigzag pattern separating different parts. In this way, the solution can be far from being optimal in sense of the number of sides of the resulting polygons. Alternatively, we implemented a helper function that would join neighboring triangles if they form a larger convex part. It can be imported as from pode import joined_constrained_delaunay_triangles and used as divide(polygon, requirements, joined_constrained_delaunay_triangles). But, in the future, a better algorithm should be implemented, like Greene, D.H., 1983 or Chazelle, B. and Dobkin, D., 1979.

Development

Bumping version

Preparation

Install bump-my-version.

Pre-release

Choose which version number category to bump following semver specification.

Test bumping version

bump-my-version bump --dry-run --verbose $CATEGORY

where $CATEGORY is the target version number category name, possible values are patch/minor/major.

Bump version

bump-my-version bump --verbose $CATEGORY

This will set version to major.minor.patch-alpha.

Release

Test bumping version

bump-my-version bump --dry-run --verbose release

Bump version

bump-my-version bump --verbose release

This will set version to major.minor.patch.

Notes

To avoid inconsistency between branches and pull requests, bumping version should be merged into master branch as separate pull request.

Running tests

Plain:

pytest

Inside Docker container:

docker-compose --file docker-compose.cpython.yml up

Bash script (e.g. can be used in Git hooks):

./run-tests.sh

or

./run-tests.sh cpython

PowerShell script (e.g. can be used in Git hooks):

.\run-tests.ps1

or

.\run-tests.ps1 cpython

Metadata

Release files for pode 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pode 0.4.3
File Size Uploaded
pode-0.4.3.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pode 0.4.3
File Interpreter ABI Platform
pode-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 28.6 kB

Release files / pode-0.4.3.tar.gz

Download URL pode-0.4.3.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1acb7a542430f4be33185aecf283b5171ec81974dc35ddfbd53243ef4d0582c1
BLAKE2b-256 checksum
How to use checksums
3c90403796db72674d8c7eac9fb16183e2ba4faa80c38ef5a9253bc15aa32b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / pode-0.4.3-py3-none-any.whl

Download URL pode-0.4.3-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3dd20a17f6caf96d0c6a72b9166d7edba408c8f58333df093bbb357ac867392a
BLAKE2b-256 checksum
How to use checksums
a5e8ad9c959a63de63727540ce2da470d91e5d065e8ec7cdbe9f7ed3b8618d19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.4.3 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

1 release file

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page