<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "klayout_doc.dtd">

<!-- generated by /home/matthias/klayout/master/scripts/drc_lvs_doc/extract_doc.rb  -->
<!-- DO NOT EDIT! -->

<doc>
<title>DRC Reference: DRC expressions</title>
<keyword name="DRC"/>
<p>
DRC expression objects represent abstract recipes for the <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> universal DRC function.
For example, when using a universal DRC expression like this:
</p><p>
<pre>
out = in.drc(width &lt; 2.0)
</pre>
</p><p>
"width &lt; 2.0" forms a DRC expression object. DRC expression objects have methods which
manipulate or evaluate the results of this expression. In addition, DRC expressions have a
result type, which is either polygon, edge or edge pair. The result type is defined by the
expression generating it. In the example above, "width &lt; 2.0" is a DRC width check which
renders edge pairs. To obtain polygons from these edge pairs, use the "polygons" method:
</p><p>
<pre>
out = in.drc((width &lt; 2.0).polygons)
</pre>
</p><p>
The following global functions are relevant for the DRC expressions:
</p><p>
<ul>
<li><a href="/about/drc_ref_global.xml#angle">angle</a> </li>
<li><a href="/about/drc_ref_global.xml#area">area</a> </li>
<li><a href="/about/drc_ref_global.xml#area_ratio">area_ratio</a> </li>
<li><a href="/about/drc_ref_global.xml#bbox_aspect_ratio">bbox_aspect_ratio</a> </li>
<li><a href="/about/drc_ref_global.xml#bbox_height">bbox_height</a> </li>
<li><a href="/about/drc_ref_global.xml#bbox_max">bbox_max</a> </li>
<li><a href="/about/drc_ref_global.xml#bbox_min">bbox_min</a> </li>
<li><a href="/about/drc_ref_global.xml#bbox_width">bbox_width</a> </li>
<li><a href="/about/drc_ref_global.xml#corners">corners</a> </li>
<li><a href="/about/drc_ref_global.xml#covering">covering</a> </li>
<li><a href="/about/drc_ref_global.xml#enc">enc</a> </li>
<li><a href="/about/drc_ref_global.xml#enclosing">enclosing</a> </li>
<li><a href="/about/drc_ref_global.xml#extent_refs">extent_refs</a> </li>
<li><a href="/about/drc_ref_global.xml#extents">extents</a> </li>
<li><a href="/about/drc_ref_global.xml#foreign">foreign</a> </li>
<li><a href="/about/drc_ref_global.xml#holes">holes</a> </li>
<li><a href="/about/drc_ref_global.xml#hulls">hulls</a> </li>
<li><a href="/about/drc_ref_global.xml#if_all">if_all</a> </li>
<li><a href="/about/drc_ref_global.xml#if_any">if_any</a> </li>
<li><a href="/about/drc_ref_global.xml#if_none">if_none</a> </li>
<li><a href="/about/drc_ref_global.xml#inside">inside</a> </li>
<li><a href="/about/drc_ref_global.xml#interacting">interacting</a> </li>
<li><a href="/about/drc_ref_global.xml#iso">iso</a> </li>
<li><a href="/about/drc_ref_global.xml#length">length</a> </li>
<li><a href="/about/drc_ref_global.xml#middle">middle</a> </li>
<li><a href="/about/drc_ref_global.xml#notch">notch</a> </li>
<li><a href="/about/drc_ref_global.xml#outside">outside</a> </li>
<li><a href="/about/drc_ref_global.xml#overlap">overlap</a> </li>
<li><a href="/about/drc_ref_global.xml#overlapping">overlapping</a> </li>
<li><a href="/about/drc_ref_global.xml#perimeter">perimeter</a> </li>
<li><a href="/about/drc_ref_global.xml#primary">primary</a> </li>
<li><a href="/about/drc_ref_global.xml#rectangles">rectangles</a> </li>
<li><a href="/about/drc_ref_global.xml#rectilinear">rectilinear</a> </li>
<li><a href="/about/drc_ref_global.xml#relative_height">relative_height</a> </li>
<li><a href="/about/drc_ref_global.xml#rounded_corners">rounded_corners</a> </li>
<li><a href="/about/drc_ref_global.xml#secondary">secondary</a> </li>
<li><a href="/about/drc_ref_global.xml#separation">separation</a> </li>
<li><a href="/about/drc_ref_global.xml#sep">sep</a> </li>
<li><a href="/about/drc_ref_global.xml#sized">sized</a> </li>
<li><a href="/about/drc_ref_global.xml#smoothed">smoothed</a> </li>
<li><a href="/about/drc_ref_global.xml#space">space</a> </li>
<li><a href="/about/drc_ref_global.xml#squares">squares</a> </li>
<li><a href="/about/drc_ref_global.xml#switch">switch</a> </li>
<li><a href="/about/drc_ref_global.xml#width">width</a> </li>
<li><a href="/about/drc_ref_global.xml#with_holes">with_holes</a> </li>
</ul>
</p><p>
The following documentation will list the methods available for DRC expression objects.
</p>
<h2-index/>
<a name="!"/><h2>"!" - Logical not</h2>
<keyword name="!"/>
<p>Usage:</p>
<ul>
<li><tt>! expression</tt></li>
</ul>
<p>
This operator will evaluate the expression after. If this expression renders
an empty result, the operator will return the primary shape. Otherwise it will
return an empty result.
</p><p>
This operator can be used together with predicates such a "rectangles" to 
invert their meaning. For example, this code selects all primary shapes which
are not rectangles:
</p><p>
<pre>
out = in.drc(! rectangles)
out = in.drc(! primary.rectangles)   # equivalent
</pre>
</p>
<a name="&amp;"/><h2>"&amp;" - Boolean AND between the results of two expressions</h2>
<keyword name="&amp;"/>
<p>Usage:</p>
<ul>
<li><tt>expression &amp; expression</tt></li>
</ul>
<p>
The &amp; operator will compute the boolean AND between the results
of two expressions. The expression types need to be edge or polygon.
</p><p>
The following example computes the partial edges where width is less than 
0.3 micrometers and space is less than 0.2 micrometers:
</p><p>
<pre>
out = in.drc((width &lt; 0.3).edges &amp; (space &lt; 0.2).edges)
</pre>
</p>
<a name="+"/><h2>"+" - Boolean OR between the results of two expressions</h2>
<keyword name="+"/>
<p>Usage:</p>
<ul>
<li><tt>expression + expression</tt></li>
</ul>
<p>
The + operator will join the results of two expressions.
</p>
<a name="-"/><h2>"-" - Boolean NOT between the results of two expressions</h2>
<keyword name="-"/>
<p>Usage:</p>
<ul>
<li><tt>expression - expression</tt></li>
</ul>
<p>
The - operator will compute the difference between the results
of two expressions. The NOT operation is defined for polygons,
edges and polygons subtracted from edges (first argument edge,
second argument polygon).
</p><p>
CAUTION: be careful not to take secondary input for the 
first argument. This will not render the desired results.
Remember that the "drc" function will walk over all primary
shapes and present single primaries to the NOT operation together
with the secondaries of that single shape. So when you use
secondary shapes as the first argument, they will not see all
all the primaries required to compute the correct result.
That's also why a XOR operation cannot be provided in the 
context of a generic DRC function.
</p><p>
The following example will produce edge markers where the 
width of is less then 0.3 micron but not inside polygons on 
the "waive" layer:
</p><p>
<pre>
out = in.drc((width &lt; 0.3).edges - secondary(waive))
</pre>
</p>
<a name="angle"/><h2>"angle" - Selects edges based on their angle</h2>
<keyword name="angle"/>
<p>Usage:</p>
<ul>
<li><tt>expression.angle (in condition)</tt></li>
</ul>
<p>
This operation selects edges by their angle, measured against the horizontal 
axis in the mathematical sense. 
</p><p>
For this measurement edges are considered without their direction.
A horizontal edge has an angle of zero degree. A vertical one has
an angle of 90 degrees. The angle range is from -90 (exclusive) to 90 degree (inclusive).
</p><p>
If the input shapes are not polygons or edge pairs, they are converted to edges 
before the angle test is made.
</p><p>
For example, the following code selects all edges from the primary shape which are 45 degree
(up) or -45 degree (down). The "+" operator will join the results:
</p><p>
<pre>
out = in.drc((angle == 45) + (angle == -45)) 
out = in.drc((primary.angle == 45) + (primary.angle == -45))    # equivalent
</pre>
</p><p>
You can avoid using both 45 and -45 degree checks with the 'absolute' option.
With this option, angles are not signed and the value is the absolute angle 
the edge encloses with the x axis:
</p><p>
<pre>
out = in.drc(angle(absolute) == 45)
</pre>
</p><p>
Note that angle checks usually imply the need for rotation variant formation as cells which
are placed non-rotated and rotated by 90 degree cannot be considered identical. This imposes
a performance penalty in hierarchical mode. If possible, consider using <a href="/about/drc_ref_drc.xml#rectilinear">DRC#rectilinear</a> for
example to detect shapes with non-manhattan geometry instead of using angle checks.
</p><p>
The "angle" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to the method call "primary.angle".
</p>
<a name="area"/><h2>"area" - Selects the primary shape if the area is meeting the condition</h2>
<keyword name="area"/>
<p>Usage:</p>
<ul>
<li><tt>expression.area (in condition)</tt></li>
</ul>
<p>
This operation is used in conditions to select shapes based on their area.
It is applicable on polygon expressions. The result will be the input 
polygons if the area condition is met. 
</p><p>
See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> for more details about comparison specs.
</p><p>
The following example will select all polygons with an area less than 2.0 square micrometers:
</p><p>
<pre>
out = in.drc(area &lt; 2.0)
out = in.drc(primary.area &lt; 2.0)   # equivalent
</pre>
</p><p>
The area method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.area".
</p>
<a name="area_ratio"/><h2>"area_ratio" - Selects the input polygon according to its area ratio (bounding box area by polygon area)</h2>
<keyword name="area_ratio"/>
<p>Usage:</p>
<ul>
<li><tt>expression.area_ratio (in condition)</tt></li>
</ul>
<p>
This operation is used in conditions to select shapes based on their area ratio.
The area ratio is the ratio of bounding box vs. polygon area. It's a measure how
"sparse" the polygons are and how good an approximation the bounding box is. 
The value is always larger or equal than 1. Boxes have a value of 1.
</p><p>
This filter is applicable on polygon expressions. The result will be the input 
polygon if the condition is met.
</p><p>
See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> for more details about comparison specs.
</p><p>
The following example will select all polygons whose area ratio is larger than 3:
</p><p>
<pre>
out = in.drc(area_ratio &gt; 3)
out = in.drc(primary.area_ratio &gt; 3)   # equivalent
</pre>
</p><p>
The "area_ratio" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.area_ratio".
</p>
<a name="area_sum"/><h2>"area_sum" - Selects the input polygons if the sum of all areas meets the condition</h2>
<keyword name="area_sum"/>
<p>Usage:</p>
<ul>
<li><tt>expression.area_sum (in condition)</tt></li>
</ul>
<p>
Returns the input polygons if the sum of their areas meets the specified
condition. This condition is evaluated on the total of all shapes generated in one step of the 
"drc" loop. As there is a single primary in each loop iteration, "primary.area_sum" is
equivalent to "primary.area".
</p><p>
See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> for more details about comparison specs.
</p>
<a name="bbox_aspect_ratio"/><h2>"bbox_aspect_ratio" - Selects the input polygon according to the aspect ratio of the bounding box</h2>
<keyword name="bbox_aspect_ratio"/>
<p>Usage:</p>
<ul>
<li><tt>expression.bbox_aspect_ratio (in condition)</tt></li>
</ul>
<p>
This operation is used in conditions to select shapes based on aspect ratios of their bounding boxes.
The aspect ratio is computed by dividing the larger of width and height by the smaller of both.
The aspect ratio is always larger or equal to 1. Square or square-boxed shapes have a
bounding box aspect ratio of 1.
</p><p>
This filter is applicable on polygon expressions. The result will be the input 
polygon if the bounding box condition is met. 
</p><p>
See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> for more details about comparison specs.
</p><p>
The following example will select all polygons whose bounding box aspect ratio is larger than 3:
</p><p>
<pre>
out = in.drc(bbox_aspect_ratio &gt; 3)
out = in.drc(primary.bbox_aspect_ratio &gt; 3)   # equivalent
</pre>
</p><p>
The "bbox_aspect_ratio" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.bbox_aspect_ratio".
</p>
<a name="bbox_height"/><h2>"bbox_height" - Selects the input polygon if its bounding box height is meeting the condition</h2>
<keyword name="bbox_height"/>
<p>Usage:</p>
<ul>
<li><tt>expression.bbox_height (in condition)</tt></li>
</ul>
<p>
This operation acts similar to <a href="/about/drc_ref_drc.xml#bbox_min">DRC#bbox_min</a>, but takes the height of the shape's 
bounding box. In general, it's more advisable to use <a href="/about/drc_ref_drc.xml#bbox_min">DRC#bbox_min</a> or <a href="/about/drc_ref_drc.xml#bbox_max">DRC#bbox_max</a>
because bbox_height implies a certain orientation. This can imply variant formation in 
hierarchical contexts: cells rotated by 90 degree have to be treated differently from
ones not rotated. This usually results in a larger computation effort and larger result files.
</p><p>
The "bbox_height" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.bbox_height".
</p>
<a name="bbox_max"/><h2>"bbox_max" - Selects the input polygon if its bounding box larger dimension is meeting the condition</h2>
<keyword name="bbox_max"/>
<p>Usage:</p>
<ul>
<li><tt>expression.bbox_max (in condition)</tt></li>
</ul>
<p>
This operation acts similar to <a href="/about/drc_ref_drc.xml#bbox_min">DRC#bbox_min</a>, but takes the larger dimension of the shape's 
bounding box.
</p><p>
The "bbox_max" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.bbox_max".
</p>
<a name="bbox_min"/><h2>"bbox_min" - Selects the input polygon if its bounding box smaller dimension is meeting the condition</h2>
<keyword name="bbox_min"/>
<p>Usage:</p>
<ul>
<li><tt>expression.bbox_min (in condition)</tt></li>
</ul>
<p>
This operation is used in conditions to select shapes based on smaller dimension of their bounding boxes.
It is applicable on polygon expressions. The result will be the input 
polygons if the bounding box condition is met. 
</p><p>
See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> for more details about comparison specs.
</p><p>
The following example will select all polygons whose bounding box smaller dimension is larger
than 200 nm:
</p><p>
<pre>
out = in.drc(bbox_min &gt; 200.nm)
out = in.drc(primary.bbox_min &gt; 200.nm)   # equivalent
</pre>
</p><p>
The "bbox_min" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.bbox_min".
</p>
<a name="bbox_width"/><h2>"bbox_width" - Selects the input polygon if its bounding box width is meeting the condition</h2>
<keyword name="bbox_width"/>
<p>Usage:</p>
<ul>
<li><tt>expression.bbox_width (in condition)</tt></li>
</ul>
<p>
This operation acts similar to <a href="/about/drc_ref_drc.xml#bbox_min">DRC#bbox_min</a>, but takes the width of the shape's 
bounding box. In general, it's more advisable to use <a href="/about/drc_ref_drc.xml#bbox_min">DRC#bbox_min</a> or <a href="/about/drc_ref_drc.xml#bbox_max">DRC#bbox_max</a>
because bbox_width implies a certain orientation. This can imply variant formation in 
hierarchical contexts: cells rotated by 90 degree have to be treated differently from
ones not rotated. This usually results in a larger computation effort and larger result files.
</p><p>
The "bbox_width" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.bbox_width".
</p>
<a name="centers"/><h2>"centers" - Returns the part at the center of each edge of the input</h2>
<keyword name="centers"/>
<p>Usage:</p>
<ul>
<li><tt>expression.centers(length)</tt></li>
<li><tt>expression.end_segments(length, fraction)</tt></li>
</ul>
<p>
This method acts on edge expressions and delivers a specific part of each edge.
See <a href="/about/drc_ref_layer.xml#centers">layer#centers</a> for details about this functionality.
</p>
<a name="corners"/><h2>"corners" - Selects corners of polygons</h2>
<keyword name="corners"/>
<p>Usage:</p>
<ul>
<li><tt>expression.corners</tt></li>
<li><tt>expression.corners([ options ])</tt></li>
</ul>
<p>
This operation acts on polygons and selects the corners of the polygons.
It can be put into a condition to select corners by their angles. The angle of
a corner is positive for a turn to the left if walking a polygon clockwise
and negative for the turn to the right. Hence positive angles indicate concave
(inner) corners, negative ones indicate convex (outer) corners.
Angles take values between -180 and 180 degree.
</p><p>
When using "as_dots" for an option, the operation will return single-point edges at
the selected corners. With "as_boxes" (the default), small (2x2 DBU) rectangles will be
produced at each selected corner.
</p><p>
Another option is "absolute" which selects the corners by absolute angle - i.e left
and right turns will both be considered positive angles.
</p><p>
Examples for use of the options are:
</p><p>
<pre>
corners(as_dots)
corners(as_boxes, absolute)
</pre>
</p><p>
The following example selects all corners:
</p><p>
<pre>
out = in.drc(corners)
out = in.drc(primary.corners)    # equivalent
</pre>
</p><p>
The following example selects all inner corners:
</p><p>
<pre>
out = in.drc(corners &gt; 0)
out = in.drc(primary.corners &gt; 0)    # equivalent
</pre>
</p><p>
The "corners" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.corners".
</p>
<a name="count"/><h2>"count" - Selects a expression result based on the number of (local) shapes</h2>
<keyword name="count"/>
<p>Usage:</p>
<ul>
<li><tt>expression.count (in condition)</tt></li>
</ul>
<p>
This operation is used in conditions to select expression results based on their
count. "count" is used as a method on a expression. It will evaluate the expression locally
and return the original result if the shape count in the result is matching the condition.
</p><p>
See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> for more details about comparison specs.
</p><p>
Note that the expression is evaluated locally: for each primary shape, the expression is
evaluated and the count of the resulting edge, edge pair or polygon set is taken.
As the primary input will always have a single item (the local shape), using "count" on
primary does not really make sense. It can be used on derived expressions however.
</p><p>
The following example selects triangles:
</p><p>
<pre>
out = in.drc(if_any(corners.count == 3))
</pre>
</p><p>
Note "if_any" which selects the primary shape if the argument evaluates to a non-empty
result. Without "if_any" three corners are returned for each triangle.
</p>
<a name="covering"/><h2>"covering" - Selects shapes entirely covering other shapes</h2>
<keyword name="covering"/>
<p>Usage:</p>
<ul>
<li><tt>expression.covering(other) (optionally in conditions)</tt></li>
<li><tt>covering(other) (optionally in conditions)</tt></li>
</ul>
<p>
This method represents the selector of primary shapes
which entirely cover shapes from the other layer. This version can be put into
a condition indicating how many shapes of the other layer need to be covered.
Use this variant within <a href="/about/drc_ref_drc.xml">DRC</a> expressions (also see <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a>).
</p><p>
For example, the following statement selects all input shapes which entirely 
cover shapes from the "other" layer:
</p><p>
<pre>
out = in.drc(covering(other))
</pre>
</p><p>
This example selects all input shapes which entire cover shapes from
the other layer and there are more than two shapes from "other" inside
primary shapes:
</p><p>
<pre>
out = in.drc(covering(other) &gt; 2)
</pre>
</p>
<a name="edges"/><h2>"edges" - Converts the input shapes into edges</h2>
<keyword name="edges"/>
<p>Usage:</p>
<ul>
<li><tt>expression.edges</tt></li>
<li><tt>expression.edges(mode)</tt></li>
</ul>
<p>
Polygons will be separated into edges forming their contours. Edge pairs will be 
decomposed into individual edges.
</p><p>
Contrary most other operations, "edges" does not have a plain function equivalent
as this is reserved for the function generating an edges layer.
To generate the edges of the primary shapes, use "primary" explicit as the source
for the edges:
</p><p>
<pre>
out = in.drc(primary.edges)
</pre>
</p><p>
The "mode" argument allows selecting specific edges from polygons.
Allowed values are: "convex", "concave", "step", "step_in" and "step_out".
"step" generates edges only if they provide a step between two other
edges. "step_in" creates edges that make a step towards the inside of
the polygon and "step_out" creates edges that make a step towards the
outside:
</p><p>
<pre>
out = in.drc(primary.edges(convex))
</pre>
</p><p>
In addition, "not_.." variants are available which selects edges
not qualifying for the specific mode:
</p><p>
<pre>
out = in.drc(primary.edges(not_convex))
</pre>
</p><p>
The mode argument is ignored when translating other objects than
polygons.
</p>
<a name="end_segments"/><h2>"end_segments" - Returns the part at the end of each edge of the input</h2>
<keyword name="end_segments"/>
<p>Usage:</p>
<ul>
<li><tt>expression.end_segments(length)</tt></li>
<li><tt>expression.end_segments(length, fraction)</tt></li>
</ul>
<p>
This method acts on edge expressions and delivers a specific part of each edge.
See <a href="/about/drc_ref_layer.xml#end_segments">layer#end_segments</a> for details about this functionality.
</p>
<a name="extended"/><h2>"extended" - Returns polygons describing an area along the edges of the input</h2>
<keyword name="extended"/>
<p>Usage:</p>
<ul>
<li><tt>expression.extended([:begin =&gt; b,] [:end =&gt; e,] [:out =&gt; o,] [:in =&gt; i], [:joined =&gt; true])</tt></li>
<li><tt>expression.extended(b, e, o, i)</tt></li>
</ul>
<p>
This method acts on edge expressions.
It will create a polygon for each edge
tracing the edge with certain offsets to the edge. "o" is the offset applied to the 
outer side of the edge, "i" is the offset applied to the inner side of the edge.
"b" is the offset applied at the beginning and "e" is the offset applied at the end.
</p>
<a name="extended_in"/><h2>"extended_in" - Returns polygons describing an area along the edges of the input</h2>
<keyword name="extended_in"/>
<p>Usage:</p>
<ul>
<li><tt>expression.extended_in(d)</tt></li>
</ul>
<p>
This method acts on edge expressions. Polygons are generated for 
each edge describing the edge drawn with a certain width extending into
the "inside" (the right side when looking from start to end).
This method is basically equivalent to the <a href="#extended">extended</a> method:
"extended(0, 0, 0, dist)".
A version extending to the outside is <a href="#extended_out">extended_out</a>.
</p>
<a name="extended_out"/><h2>"extended_out" - Returns polygons describing an area along the edges of the input</h2>
<keyword name="extended_out"/>
<p>Usage:</p>
<ul>
<li><tt>expression.extended_out(d)</tt></li>
</ul>
<p>
This method acts on edge expressions. Polygons are generated for 
each edge describing the edge drawn with a certain width extending into
the "outside" (the left side when looking from start to end).
This method is basically equivalent to the <a href="#extended">extended</a> method:
"extended(0, 0, dist, 0)".
A version extending to the inside is <a href="#extended_in">extended_in</a>.
</p>
<a name="extent_refs"/><h2>"extent_refs" - Returns partial references to the bounding boxes of the polygons</h2>
<keyword name="extent_refs"/>
<p>Usage:</p>
<ul>
<li><tt>expression.extent_refs([ options ])</tt></li>
</ul>
<p>
The extent_refs operation acts on polygons and has the same effect than <a href="/about/drc_ref_layer.xml#extent_refs">Layer#extent_refs</a>.
It takes the same arguments. It is available as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions or
as plain function, in which case it acts on the primary shapes.
</p>
<a name="extents"/><h2>"extents" - Returns the bounding box of each input object</h2>
<keyword name="extents"/>
<p>Usage:</p>
<ul>
<li><tt>expression.extents([ enlargement ])</tt></li>
</ul>
<p>
This method provides the same functionality as <a href="/about/drc_ref_layer.xml#extents">Layer#extents</a> and takes the same
arguments. It returns the bounding boxes of the input objects. It acts on edge
edge pair and polygon expressions.
</p><p>
The "extents" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.extents".
</p>
<a name="first_edges"/><h2>"first_edges" - Returns the first edges of edge pairs</h2>
<keyword name="first_edges"/>
<p>Usage:</p>
<ul>
<li><tt>expression.first_edges</tt></li>
</ul>
<p>
This method acts on edge pair expressions and returns the first edges of the
edge pairs delivered by the expression.
</p><p>
Some checks deliver symmetric edge pairs (e.g. space, width, etc.) for which the
edges are commutable. "first_edges" will deliver both edges for such edge pairs.
</p>
<a name="holes"/><h2>"holes" - Selects all holes from the input polygons</h2>
<keyword name="holes"/>
<p>Usage:</p>
<ul>
<li><tt>expression.holes</tt></li>
</ul>
<p>
This operation can be used as a plain function in which case it acts on primary
shapes or can be used as method on another DRC expression.
The following example selects all holes with an area larger than 2 square micrometers:
</p><p>
<pre>
out = in.drc(holes.area &gt; 2.um)
out = in.drc(primary.holes.area &gt; 2.um)   # equivalent
</pre>
</p>
<a name="hulls"/><h2>"hulls" - Selects all hulls from the input polygons</h2>
<keyword name="hulls"/>
<p>Usage:</p>
<ul>
<li><tt>expression.hulls</tt></li>
</ul>
<p>
The hulls are the outer contours of the input polygons. By selecting hulls only,
all holes will be closed.
</p><p>
This operation can be used as a plain function in which case it acts on primary
shapes or can be used as method on another DRC expression.
The following example closes all holes:
</p><p>
<pre>
out = in.drc(hulls)
out = in.drc(primary.hulls)   # equivalent
</pre>
</p>
<a name="inside"/><h2>"inside" - Selects shapes entirely inside other shapes</h2>
<keyword name="inside"/>
<p>Usage:</p>
<ul>
<li><tt>expression.inside(other)</tt></li>
<li><tt>inside(other)</tt></li>
</ul>
<p>
This method represents the selector of primary shapes
which are entirely inside shapes from the other layer. 
Use this variant within <a href="/about/drc_ref_drc.xml">DRC</a> expressions (also see <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a>).
</p>
<a name="interacting"/><h2>"interacting" - Selects shapes interacting with other shapes</h2>
<keyword name="interacting"/>
<p>Usage:</p>
<ul>
<li><tt>expression.interacting(other) (optionally in conditions)</tt></li>
<li><tt>interacting(other) (optionally in conditions)</tt></li>
</ul>
<p>
See <a href="#covering">covering</a> for a description of the use cases for this function. 
When using "interacting", shapes are selected when the interact (overlap, touch)
shapes from the other layer.
</p><p>
When using this method with a count, the operation may not render 
the correct results if the other input is not merged. By nature of the
generic DRC feature, only those shapes that interact with the primary shape
will be selected. If the other input is split into multiple polygons,
not all components may be captured and the computed interaction count
may be incorrect.
</p>
<a name="length"/><h2>"length" - Selects edges based on their length</h2>
<keyword name="length"/>
<p>Usage:</p>
<ul>
<li><tt>expression.length (in condition)</tt></li>
</ul>
<p>
This operation will select those edges which are meeting the length
criterion. Non-edge shapes (polygons, edge pairs) will be converted to edges before.
</p><p>
For example, this code selects all edges from the primary shape which are longer or
equal than 1 micrometer:
</p><p>
<pre>
out = in.drc(length &gt;= 1.um) 
out = in.drc(primary.length &gt;= 1.um)   # equivalent
</pre>
</p><p>
The "length" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.length".
</p>
<a name="length_sum"/><h2>"length_sum" - Selects the input edges if the sum of their lengths meets the condition</h2>
<keyword name="length_sum"/>
<p>Usage:</p>
<ul>
<li><tt>expression.length_sum (in condition)</tt></li>
</ul>
<p>
Returns the input edges if the sum of their lengths meets the specified
condition. This condition is evaluated on the total of all edges generated in one step of the 
"drc" loop.
</p><p>
See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> for more details about comparison specs.
</p>
<a name="merged"/><h2>"merged" - Returns the merged input polygons, optionally selecting multi-overlap</h2>
<keyword name="merged"/>
<p>Usage:</p>
<ul>
<li><tt>expression.merged</tt></li>
<li><tt>expression.merged(min_count)</tt></li>
</ul>
<p>
This operation will act on polygons. Without a min_count argument, the merged
polygons will be returned.
</p><p>
With a min_count argument, the result will include only those parts where more
than the given number of polygons overlap. As the primary input is merged already,
it will always contribute as one.
</p><p>
The "merged" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.merged".
</p>
<a name="middle"/><h2>"middle" - Returns the centers of polygon bounding boxes</h2>
<keyword name="middle"/>
<p>Usage:</p>
<ul>
<li><tt>expression.middle([ options ])</tt></li>
</ul>
<p>
The middle operation acts on polygons and has the same effect than <a href="/about/drc_ref_layer.xml#middle">Layer#middle</a>.
It takes the same arguments. It is available as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions or
as plain function, in which case it acts on the primary shapes.
</p>
<a name="outside"/><h2>"outside" - Selects shapes entirely outside other shapes</h2>
<keyword name="outside"/>
<p>Usage:</p>
<ul>
<li><tt>expression.outside(other)</tt></li>
<li><tt>outside(other)</tt></li>
</ul>
<p>
This method represents the selector of primary shapes
which are entirely outside shapes from the other layer. 
Use this variant within <a href="/about/drc_ref_drc.xml">DRC</a> expressions (also see <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a>).
</p>
<a name="overlapping"/><h2>"overlapping" - Selects shapes overlapping with other shapes</h2>
<keyword name="overlapping"/>
<p>Usage:</p>
<ul>
<li><tt>expression.overlapping(other) (optionally in conditions)</tt></li>
<li><tt>overlapping(other) (optionally in conditions)</tt></li>
</ul>
<p>
See <a href="#covering">covering</a> for a description of the use cases for this function. 
When using "overlapping", shapes are selected when the overlap
shapes from the other layer.
</p><p>
When using this method with a count, the operation may not render 
the correct results if the other input is not merged. By nature of the
generic DRC feature, only those shapes that interact with the primary shape
will be selected. If the other input is split into multiple polygons,
not all components may be captured and the computed interaction count
may be incorrect.
</p>
<a name="perimeter"/><h2>"perimeter" - Selects the input polygon if the perimeter is meeting the condition</h2>
<keyword name="perimeter"/>
<p>Usage:</p>
<ul>
<li><tt>expression.perimeter (in condition)</tt></li>
</ul>
<p>
This operation is used in conditions to select shapes based on their perimeter.
It is applicable on polygon expressions. The result will be the input 
polygons if the perimeter condition is met. 
</p><p>
See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> for more details about comparison specs.
</p><p>
The following example will select all polygons with a perimeter less than 10 micrometers:
</p><p>
<pre>
out = in.drc(perimeter &lt; 10.0)
out = in.drc(primary.perimeter &lt; 10.0)   # equivalent
</pre>
</p><p>
The perimeter method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.perimeter".
</p>
<a name="perimeter_sum"/><h2>"perimeter_sum" - Selects the input polygons if the sum of all perimeters meets the condition</h2>
<keyword name="perimeter_sum"/>
<p>Usage:</p>
<ul>
<li><tt>expression.perimeter_sum (in condition)</tt></li>
</ul>
<p>
Returns the input polygons if the sum of their perimeters meets the specified
condition. This condition is evaluated on the total of all shapes generated in one step of the 
"drc" loop. As there is a single primary in each loop iteration, "primary.perimeter_sum" is
equivalent to "primary.perimeter".
</p><p>
See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> for more details about comparison specs.
</p>
<a name="polygons"/><h2>"polygons" - Converts the input shapes into polygons</h2>
<keyword name="polygons"/>
<p>Usage:</p>
<ul>
<li><tt>expression.polygons([ enlargement ])</tt></li>
</ul>
<p>
Generates polygons from the input shapes. Polygons stay polygons. Edges and edge pairs
are converted to polygons. For this, the enlargement parameter will specify the 
edge thickness or augmentation applied to edge pairs. With the default enlargement
of zero edges will not be converted to valid polygons and degenerated edge pairs
will not become valid polygons as well.
</p><p>
Contrary most other operations, "polygons" does not have a plain function equivalent
as this is reserved for the function generating a polygon layer.
</p><p>
This method is useful for generating polygons from DRC violation markers as shown in
the following example:
</p><p>
<pre>
out = in.drc((width &lt; 0.5.um).polygons)
</pre>
</p>
<a name="rectangles"/><h2>"rectangles" - Selects all polygons which are rectangles</h2>
<keyword name="rectangles"/>
<p>Usage:</p>
<ul>
<li><tt>expression.rectangles</tt></li>
</ul>
<p>
This operation can be used as a plain function in which case it acts on primary
shapes or can be used as method on another DRC expression.
The following example selects all rectangles:
</p><p>
<pre>
out = in.drc(rectangles)
out = in.drc(primary.rectangles)    # equivalent
</pre>
</p>
<a name="rectilinear"/><h2>"rectilinear" - Selects all polygons which are rectilinear</h2>
<keyword name="rectilinear"/>
<p>Usage:</p>
<ul>
<li><tt>expression.rectilinear</tt></li>
</ul>
<p>
Rectilinear polygons only have vertical and horizontal edges. Such polygons are also
called manhattan polygons.
</p><p>
This operation can be used as a plain function in which case it acts on primary
shapes or can be used as method on another DRC expression.
The following example selects all manhattan polygons:
</p><p>
<pre>
out = in.drc(rectilinear)
out = in.drc(primary.rectilinear)    # equivalent
</pre>
</p>
<a name="relative_height"/><h2>"relative_height" - Selects the input polygon according to the height vs. width of the bounding box</h2>
<keyword name="relative_height"/>
<p>Usage:</p>
<ul>
<li><tt>expression.relative_height (in condition)</tt></li>
</ul>
<p>
This operation is used in conditions to select shapes based on the ratio of bounding box
height vs. width. The taller the shape, the larger the value. Wide polygons have a value
below 1. A square has a relative height of 1.
</p><p>
This filter is applicable on polygon expressions. The result will be the input 
polygon if the condition is met.
</p><p>
Don't use this method if you can use <a href="#bbox_aspect_ratio">bbox_aspect_ratio</a>, because the latter is
isotropic and can be used hierarchically without generating rotation variants.
</p><p>
See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a> for more details about comparison specs.
</p><p>
The following example will select all polygons whose relative height is larger than 3:
</p><p>
<pre>
out = in.drc(relative_height &gt; 3)
out = in.drc(primary.relative_height &gt; 3)   # equivalent
</pre>
</p><p>
The "relative_height" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.bbox_aspect_ratio".
</p>
<a name="rounded_corners"/><h2>"rounded_corners" - Applies corner rounding</h2>
<keyword name="rounded_corners"/>
<p>Usage:</p>
<ul>
<li><tt>expression.rounded_corners(inner, outer, n)</tt></li>
</ul>
<p>
This operation acts on polygons and applies corner rounding to the given inner
and outer corner radius and the number of points n per full circle. See <a href="/about/drc_ref_layer.xml#rounded_corners">Layer#rounded_corners</a> for more details.
</p><p>
The "rounded_corners" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.rounded_corners".
</p>
<a name="second_edges"/><h2>"second_edges" - Returns the second edges of edge pairs</h2>
<keyword name="second_edges"/>
<p>Usage:</p>
<ul>
<li><tt>expression.second_edges</tt></li>
</ul>
<p>
This method acts on edge pair expressions and returns the second edges of the
edge pairs delivered by the expression.
</p><p>
Some checks deliver symmetric edge pairs (e.g. space, width, etc.) for which the
edges are commutable. "second_edges" will not deliver edges for such edge pairs.
Instead, "first_edges" will deliver both.
</p>
<a name="sized"/><h2>"sized" - Returns the sized version of the input</h2>
<keyword name="sized"/>
<p>Usage:</p>
<ul>
<li><tt>expression.sized(d [, mode])</tt></li>
<li><tt>expression.sized(dx, dy [, mode]))</tt></li>
</ul>
<p>
This method provides the same functionality as <a href="/about/drc_ref_layer.xml#sized">Layer#sized</a> and takes the same
arguments. It acts on polygon expressions.
</p><p>
The "sized" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.sized".
</p>
<a name="smoothed"/><h2>"smoothed" - Applies smoothing</h2>
<keyword name="smoothed"/>
<p>Usage:</p>
<ul>
<li><tt>expression.smoothed(d [, keep_hv ])</tt></li>
</ul>
<p>
This operation acts on polygons and applies polygon smoothing with the tolerance d. 'keep_hv' indicates
whether horizontal and vertical edges are maintained. Default is 'no' which means such edges may be distorted.
See <a href="/about/drc_ref_layer.xml#smoothed">Layer#smoothed</a> for more details.
</p><p>
The "smoothed" method is available as a plain function or as a method on <a href="/about/drc_ref_drc.xml">DRC</a> expressions.
The plain function is equivalent to "primary.smoothed".
</p>
<a name="squares"/><h2>"squares" - Selects all polygons which are squares</h2>
<keyword name="squares"/>
<p>Usage:</p>
<ul>
<li><tt>expression.squares</tt></li>
</ul>
<p>
This operation can be used as a plain function in which case it acts on primary
shapes or can be used as method on another DRC expression.
The following example selects all squares:
</p><p>
<pre>
out = in.drc(squares)
out = in.drc(primary.squares)    # equivalent
</pre>
</p>
<a name="start_segments"/><h2>"start_segments" - Returns the part at the beginning of each edge of the input</h2>
<keyword name="start_segments"/>
<p>Usage:</p>
<ul>
<li><tt>expression.start_segments(length)</tt></li>
<li><tt>expression.start_segments(length, fraction)</tt></li>
</ul>
<p>
This method acts on edge expressions and delivers a specific part of each edge.
See <a href="/about/drc_ref_layer.xml#start_segments">layer#start_segments</a> for details about this functionality.
</p>
<a name="with_holes"/><h2>"with_holes" - Selects all input polygons with the specified number of holes</h2>
<keyword name="with_holes"/>
<p>Usage:</p>
<ul>
<li><tt>expression.with_holes (in condition)</tt></li>
</ul>
<p>
This operation can be used as a plain function in which case it acts on primary
shapes or can be used as method on another DRC expression.
The following example selects all polygons with more than 2 holes:
</p><p>
<pre>
out = in.drc(with_holes &gt; 2)
out = in.drc(primary.with_holes &gt; 2)   # equivalent
</pre>
</p>
<a name="|"/><h2>"|" - Boolean OR between the results of two expressions</h2>
<keyword name="|"/>
<p>Usage:</p>
<ul>
<li><tt>expression | expression</tt></li>
</ul>
<p>
The | operator will compute the boolean OR between the results of 
two expressions. '+' is basically a synonym. Both expressions
must render the same type.
</p>
</doc>
