Skip to main content

Implementation of an algorithm for a polygon decomposition by Hert, S. and Lumelsky, V., 1998

Project description

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:

python setup.py 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)
assert parts[0].area == parts[1].area < polygon.area
assert Point(1, 1) in parts[1]

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 bump2version.

Pre-release

Choose which version number category to bump following semver specification.

Test bumping version

bump2version --dry-run --verbose $CATEGORY

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

Bump version

bump2version --verbose $CATEGORY

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

Release

Test bumping version

bump2version --dry-run --verbose release

Bump version

bump2version --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:

python setup.py test

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

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

pode-0.2.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

pode-0.2.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file pode-0.2.0.tar.gz.

File metadata

  • Download URL: pode-0.2.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.5

File hashes

Hashes for pode-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d9348c2328d3527fdf02a433d1e8b0d83973ea00e7560daf0e1820d49a7e977f
MD5 9f4e734fd7465fd7aa8091a548835a1b
BLAKE2b-256 d9f4a4a23909df7b194ddf57ebb921df7a92762cb3502da372e029f25835ff4c

See more details on using hashes here.

File details

Details for the file pode-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pode-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.5

File hashes

Hashes for pode-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d073638334d3991e50ffdcbceead0f0857361908a1eac35809a64b6e0be5232d
MD5 6a596dadc2f7bfcbf3f03ee809a9d146
BLAKE2b-256 0c2dca96e32e8c2b22a170cfd10888e0b918812e86fb5ea23caf9a5c538caff2

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