Skip to content

Commit

Permalink
Merge pull request #194 from amccaugh/dev
Browse files Browse the repository at this point in the history
1.7.0
  • Loading branch information
amccaugh authored Apr 9, 2024
2 parents a277c86 + 6779169 commit ee5b61e
Show file tree
Hide file tree
Showing 12 changed files with 551 additions and 2,413 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.0
- uses: pre-commit/action@v3.0.0
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
matplotlib \
scipy \
rectpack \
klayout \
freetype-py \
pytest
pip install -e .
Expand All @@ -32,4 +33,3 @@ jobs:
with:
run: |
pytest
python ./phidl/phidl_tutorial_example.py
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 1.7.0 (April 9, 2024)

Major optimization update!

### New features
- New KLayout-based boolean/offset/outline functions! These are under the name `pg.kl_boolean()`, `pg.kl_offset`, etc. They utilize the excellent KLayout tile processor, which allows breaking down & parallelizing these operations--in a nutshell, these operations should be much, much faster.
- Added `D.simplify()`, which allows you to significantly reduce memory usage of a geometry by discarding unnecessarily-precise points from all polygons within a Device. Uses the very robust Ramer–Douglas–Peucker algorithm for simplification.
- Now `pg.gridsweep()` allows `param_x` or `param_y` to be integers, which creates copies of the same parameters in the x or y direction.

### Bugfixes
- 20x speedup to the internal operation `_merge_nearby_floating_points()` which should significantly speed up large operations (thanks Alex Tait @atait)
- New pre-commit using ruff (thanks Bas Nijholt @basnijholt)
- Grammar fix to documentation (thanks Ashish Panigrahi @paniash)



## 1.6.4 (July 20, 2023)

### New features
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ GDS scripting for Python that's intuitive, fast, and powerful.
- [**Installation / requirements**](#installation--requirements)
- [**Tutorial + examples**](https://phidl.readthedocs.io/en/latest/tutorials.html) (or [try an interactive notebook](https://mybinder.org/v2/gh/amccaugh/phidl/master?filepath=phidl_tutorial_example.ipynb))
- [**Geometry library + function documentation**](https://phidl.readthedocs.io/en/latest/geometry_reference.html)
- [Changelog](https://github.com/amccaugh/phidl/blob/master/CHANGELOG.md) (latest update 1.6.3 on July 20, 2023)
- New `pg.fill_rectangle()` [examples and documentation](https://phidl.readthedocs.io/en/latest/geometry_reference.html#Fill-tool)
- [Changelog](https://github.com/amccaugh/phidl/blob/master/CHANGELOG.md) (latest update 1.7.0 on April 9, 2024)
- New KLayout-based boolean/offset/outline functions! These are under the name `pg.kl_boolean()`, `pg.kl_offset`, `pg.kl_outline()`, `pg.kl_invert()`. They utilize the excellent KLayout tile processor, which allows breaking down & parallelizing these operations--in a nutshell, these operations should be much, much faster, and they also are more robust than the gdspy/clipper implementation.
- To use these new functions, you must first `pip install klayout`


# Citation

Expand Down
23 changes: 23 additions & 0 deletions docs/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,29 @@ set_quickplot_options
Geometry Library
****************



kl_boolean
=======

.. autofunction:: phidl.geometry.kl_boolean

kl_offset
=======

.. autofunction:: phidl.geometry.kl_offset

kl_outline
=======

.. autofunction:: phidl.geometry.kl_outline

kl_invert
=======

.. autofunction:: phidl.geometry.kl_invert


arc
===

Expand Down
25 changes: 23 additions & 2 deletions phidl/device_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

gdspy.library.use_current_library = False

__version__ = "1.6.4"
__version__ = "1.7.0"


# ==============================================================================
Expand Down Expand Up @@ -316,7 +316,8 @@ def _simplify(points, tolerance=0):
"""Ramer–Douglas–Peucker algorithm for line simplification. Takes an
array of points of shape (N,2) and removes excess points in the line. The
remaining points form a identical line to within `tolerance` from the
original"""
original
"""
# From https://github.com/fhirschmann/rdp/issues/7
# originally written by Kirill Konevets https://github.com/kkonevets

Expand Down Expand Up @@ -1838,6 +1839,26 @@ def mirror(self, p1=(0, 1), p2=(0, 0)):
self._bb_valid = False
return self

def simplify(self, tolerance=1e-3):
"""Simplifies every polygon in the Device, without changing
the shape by more than `tolerance` from the original. Uses the
Ramer-Douglas-Peucker algorithm.
Parameters
----------
tolerance : float
Tolerance value for the simplification algorithm. All points that
can be removed without changing the resulting polygon by more than
the value listed here will be removed. Also known as `epsilon` here
https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
"""
referenced_cells = [self]
referenced_cells += list(self.get_dependencies(recursive=True))
for cell in referenced_cells:
for polygon in cell.polygons:
polygon.simplify(tolerance=tolerance)
return self

def hash_geometry(self, precision=1e-4):
"""Computes an SHA1 hash of the geometry in the Device. For each layer,
each polygon is individually hashed and then the polygon hashes are
Expand Down
Loading

0 comments on commit ee5b61e

Please sign in to comment.