项目作者: lycantropos

项目描述 :
Searching line segments & polygon edges intersections (correct Bentley-Ottmann & Shamos-Hoey algorithms implementation)
高级语言: Python
项目地址: git://github.com/lycantropos/bentley_ottmann.git
创建时间: 2020-01-18T13:02:54Z
项目社区:https://github.com/lycantropos/bentley_ottmann

开源协议:MIT License

下载


bentley_ottmann





In what follows python is an alias for python3.7 or pypy3.7
or any later version (python3.8, pypy3.8 and so on).

Installation

Install the latest pip & setuptools packages versions

  1. python -m pip install --upgrade pip setuptools

User

Download and install the latest stable version from PyPI repository

  1. python -m pip install --upgrade bentley_ottmann

Developer

Download the latest version from GitHub repository

  1. git clone https://github.com/lycantropos/bentley_ottmann.git
  2. cd bentley_ottmann

Install dependencies

  1. python -m pip install -r requirements.txt

Install

  1. python setup.py install

Usage

With segments

  1. >>> from ground.base import get_context
  2. >>> context = get_context()
  3. >>> Point, Segment = context.point_cls, context.segment_cls
  4. >>> unit_segments = [Segment(Point(0, 0), Point(1, 0)),
  5. ... Segment(Point(0, 0), Point(0, 1))]

we can check if they intersect

  1. >>> from bentley_ottmann.planar import segments_intersect
  2. >>> segments_intersect(unit_segments)
  3. True

With contours

  1. >>> Contour = context.contour_cls
  2. >>> triangle = Contour([Point(0, 0), Point(1, 0), Point(0, 1)])
  3. >>> degenerate_triangle = Contour([Point(0, 0), Point(2, 0), Point(1, 0)])

we can check if they are self-intersecting or not

  1. >>> from bentley_ottmann.planar import contour_self_intersects
  2. >>> contour_self_intersects(triangle)
  3. False
  4. >>> contour_self_intersects(degenerate_triangle)
  5. True

Development

Bumping version

Preparation

Install
bump2version.

Pre-release

Choose which version number category to bump following semver
specification
.

Test bumping version

  1. bump2version --dry-run --verbose $CATEGORY

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

Bump version

  1. bump2version --verbose $CATEGORY

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

Release

Test bumping version

  1. bump2version --dry-run --verbose release

Bump version

  1. bump2version --verbose release

This will set version to major.minor.patch.

Running tests

Install dependencies

  1. python -m pip install -r requirements-tests.txt

Plain

  1. pytest

Inside Docker container:

  • with CPython
    1. docker-compose --file docker-compose.cpython.yml up
  • with PyPy
    1. docker-compose --file docker-compose.pypy.yml up

Bash script:

  • with CPython

    1. ./run-tests.sh

    or

    1. ./run-tests.sh cpython
  • with PyPy

    1. ./run-tests.sh pypy

PowerShell script:

  • with CPython
    1. .\run-tests.ps1
    or
    1. .\run-tests.ps1 cpython
  • with PyPy
    1. .\run-tests.ps1 pypy