KLayout 0.29.8 (2024-11-26 926dac96c) [master]

Layer Boolean Operations

KLayout now comes with a set of boolean operations. These operations are available in the "Layers" submenu of the "Edit" menu ("Boolean Operations" and "Merge" functions). A dialog will open that allows specification of mode, input layer(s), output layer and certain other options.

In addition, a MERGE operation is provided, which is a single-layer operation that joins (merges) all shapes on the layer. As a special feature, this operation allows selecting a minimum overlap count: 0 means that output is produced when at least one shape is present. 1 means that two shapes have to overlap to produce an output and so on. This does not apply for single polygons: self-overlaps of polygons are not detected in this mode.

All operations can be performed in three hierarchical modes:

For the first two modes, the source and target layout can be different, provided that all layouts are loaded into the same view. This allows combining layers of different layouts. For example to compare them using a XOR function.

As a special feature, KLayout's boolean implementation allows choosing how "kissing corner" situations are resolved. KLayout allows two modes:

The following screenshots illustrate the maximum coherence (left) and minimum coherence (right) modes for a XOR operation between two rectangles.

The boolean operations are currently implemented flat and based on a full-level edge representation. This means, that the complete layer is flattened (if "flat" mode is requested) and converted into a set of edges which the processor runs on. This will lead to huge resource requirements for very large layouts and is not recommended for such applications currently.

The boolean processor is based on an iterative approach to cover grid snap effects which makes it highly accurate but somewhat slower than a single-pass scanline implementation. Performance penalty is about 2x (two times slower) compared to an efficiently implemented single-pass algorithm.