Skip to content
forked from heitzmann/gdstk

Gdstk (GDSII Tool Kit) is a C++/Python library for creation and manipulation of GDSII and OASIS files.

License

Notifications You must be signed in to change notification settings

hezq12358/gdstk

 
 

Repository files navigation

GDSTK README

Boost Software License - Version 1.0 Tests Runner Publish Docs Downloads

Gdstk (GDSII Tool Kit) is a C++ library for creation and manipulation of GDSII and OASIS files. It is also available as a Python module meant to be a successor to Gdspy.

Key features for the creation of complex CAD layouts are included:

  • Boolean operations on polygons (AND, OR, NOT, XOR) based on clipping algorithm
  • Polygon offset (inward and outward rescaling of polygons)
  • Efficient point-in-polygon solutions for large array sets

Typical applications of Gdstk are in the fields of electronic chip design, planar lightwave circuit design, and mechanical engineering.

Documentation

The complete documentation is available here.

The source files can be found in the docs directory.

Installation

C++ library only

The C++ library is meant to be used by including it in your own source code.

If you prefer to install a static library, the included CMakeLists.txt should be a good starting option (use -DCMAKE_INSTALL_PREFIX=path to control the installation path):

cmake -S . -B build
cmake --build build --target install

The library depends on zlib.

Python wrapper

The Python module can be installed via Conda (recommended) or compiled directly from source. It depends on:

Conda

Windows users are suggested to install via Conda using the available conda-forge recipe. The recipe works on MacOS and Linux as well.

To install in a new Conda environment:

# Create a new conda environment named gdstk
conda create -n gdstk -c conda-forge --strict-channel-priority
# Activate the new environment
conda activate gdstk
# Install gdstk
conda install gdstk

To use an existing environment, make sure it is configured to prioritize the conda-forge channel:

# Configure the conda-forge channel
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
# Install gdstk
conda install gdstk

From source

The module must be linked aginst zlib. The included CMakeLists.txt file can be used as a guide.

Installation from source should follow the usual method (there is no need to compile the static library beforehand):

python setup.py install

Support

Help support Gdstk development by donating via PayPal

Benchmarks

The benchmarks directory contains a few tests to compare the performance gain of the Python interface versus Gdspy. They are only for reference; the real improvement is heavily dependent on the type of layout and features used. If maximal performance is important, the library should be used directly from C++, without the Python interface.

Timing results were obtained with Python 3.9 on an Intel Core i7-3820. They represent the best average time to run each function out of 16 sets of 8 runs each.

Benchmark Gdspy 1.6.9 Gdstk 0.8.0 Gain
10k_rectangles 212 ms 6.96 ms 30.4
1k_circles 555 ms 355 ms 1.57
boolean-offset 361 μs 63.4 μs 5.69
bounding_box 77.4 ms 228 μs 339
curves 2.96 ms 54.6 μs 54.3
flatten 990 μs 12.7 μs 78
flexpath 5.55 ms 25.6 μs 217
flexpath-param 6.43 ms 1.26 ms 5.12
fracture 1.45 ms 839 μs 1.73
inside 209 μs 40.3 μs 5.19
read_gds 6.09 ms 121 μs 50.5
read_rawcells 615 μs 62.3 μs 9.88
robustpath 358 μs 15.9 μs 22.5

Memory usage per object for 100000 objects:

Object Gdspy 1.6.9 Gdstk 0.8.0 Reduction
Rectangle 558 B 234 B 58%
Circle (r = 10) 1.69 kB 1.27 kB 24%
FlexPath segment 1.5 kB 440 B 71%
FlexPath arc 2.28 kB 1.49 kB 34%
RobustPath segment 2.86 kB 919 B 69%
RobustPath arc 2.63 kB 919 B 66%
Label 412 B 219 B 47%
Reference 154 B 184 B -19%
Reference (array) 186 B 187 B -0%
Cell 430 B 231 B 46%

About

Gdstk (GDSII Tool Kit) is a C++/Python library for creation and manipulation of GDSII and OASIS files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 53.5%
  • C 43.2%
  • Python 3.2%
  • CMake 0.1%