next up previous contents index
Next: The !join Command: Join Up: Layout Editing Previous: The !poly2path Command: Polygon   Contents   Index

The !bloat Command: Expand Objects

Syntax: !bloat dimen [mode]
The dimen is a dimension in microns. The command will operate on selected objects, and alter the dimensions according to the dimen given. If the dimen is positive, the parts of edges that do not contact or overlap with a selected object on the same layer will be pushed out by dimen, expanding the objects. If dimen is negative, the reverse occurs: objects will shrink, but adjacent objects will remain touching. Objects may be severed into two or more pieces if the dimen is negative, or may disappear entirely.

Only boxes, wires and polygons are affected. Wires and and possibly boxes become polygons after the operation. An object is deselected if it is modified.

There are a number of operational details and choices available with the mode integer, whose bits represent flags. This value can be given as a decimal integer, or as a hexadecimal number following ``0x''. If the mode argument is missing, a value of 0 is implied.

bits 0-1 (0x1, 0x2)
The two LSBs specify the basic algorithm mode, as described below.

bit 2 (0x4)
When set, the algorithm mode calls the ``old'' bloating algorithms, as used in releases prior to 2.5.67. If this bit is set, all of the other flag bits are ignored.

bit 3 (0x8)
When set, the return is the edge template, and no bloating is done. The edge template is a collection of polygons that cover the edges of objects that would be bloated, as a path, whose width is twice the dimen. When bloating, the edge template is either added to the objects being bloated, or clipped from them, depending on the sign of dimen.

bits 4-7 (0x70)
These three bits specify the corner ``fill-in'' mode, used when constructing the edge template. Consider a vertex and two adjacent edges. Imagine the rectangles formed from these edges by constructing parallel edges plus and minus dimen perpendicular to the edges, and using the four endpoints of the parallel segments to define two rectangles. The two rectangles will overlap, with a notch at the original vertex location. Adding a suitable shape to fill in this notch, thus creating a smooth transition, is the purpose of the corner fill-in.

The corner fill-in shape has three points initially defined, the vertex, and the two projections along the ends of the constructed rectangles. The differences between the fill-in modes is where (or if) we add the fourth point to the fill-in polygon. The choices are as follows:

bits 4-6: 000 (``clip'' mode)
The angle is bisected, and the point added is a distance given by the absolute value of dimen from the vertex, along the bisector. This produces a rounding effect at the corner.

bits 4-6: 001 (``flat'' mode)
No fourth point is added, only a triangle formed by the existing three points is used.

bits 4-6: 010 (``extend'' mode)
The point added is the projected intersection of the outer edges of the two rectangles. For acute angles, the distance to the extended vertex is unconstrained.

bits 4-6: 011 (``extend-1'' mode)
The point added is the projected intersection of the outer edges of the two rectangles. For acute angles, if the corner would extend too far, is is clipped (similar to the "clip" mode).

bits 4-6: 100 (``extend-2'' mode)
This mode is similar to the "extend-1" mode, but provides a different and more aggressive clipping of acute angles.

bits 4-6: 101 (unused)
This code is reserved for expansion, produces no corner fill.

bits 4-6: 110 (unused)
This code is reserved for expansion, produces no corner fill.

bits 4-6: 111 (no fill)
This produces no corner fill.

Small angles will use the ``flat'' corner fill mode to avoid adding unnecessary vertices, in all modes.

bit 7 (0x80)
When using the ``extend'' corner modes, it is possible in certain geometries that the extended corner will occur on the opposite side of an edge rectangle from some other edge, which will produce unexpected features in the bloating result. In order to prevent this, a rather expensive test is performed. Setting this bit will skip the test, speeding up the operation somewhat. In Manhattan geometry, this test can always be skipped.

bit 8 (0x100)
Internally, the grouping operation that is part of the preparation for the edge template generation is skipped. This is an internal artifact, and this flag should not be set. However, if only a single object is being bloated, this flag may provide a slight speed improvement.

bit 9 (0x200)
Internally, clipping/merging of the trapezoid list passed to the bloating function is skipped. This is an internal artifact and this flag should not be set.

bit 10 (0x400)
When this bit is set, a scaling algorithm is applied during the bloating, which very slightly (+/- one internal unit) affects output coordinates. This is the result of a very specialized customer request that output exactly match that from another tool, and is not likely to be generally useful.

The scale fix will provide more accurate bloating when all angles are multiples of 45 degrees. It is not needed for Manhattan geometry, and for angles other than 45 degree multiples, it can actually reduce accuracy. For best accuracy in the all-angle case, the DatabaseResolution variable can be set to a larger value.

bit 11 (0x800)
When this bit is set, the trapezoid collection used to define the edge template will not be clipped and merged before use. This is an internal artifact and this flag should not be set.

bit 12 (0x1000)
When this bit is set, the resulting trapezoid collection produced for the edge template or by the bloating operation will not be joined into polygons.

The basic algorithm for modes 0-2 works as follows:

  1. The collection of objects to bloat is converted to a trapezoid representation.
  2. The resulting trapezoid list is grouped into multiple lists of spatially disjoint lists, where each list is mutually connected and no trapezoid touches or overlaps a trapezoid from another list.
  3. For each list, the line segments representing the trapezoid edges are tabulated.
  4. The edge list is clipped against itself to remove mutually overlapping regions. The remaining edges are the ``external'' edges, where one side is area outside of the trapezoid group.
  5. Each edge is converted to a rectangle that covers the edge and extends + / - the bloat width normal from the edge (note that these rectangles are rotated by an arbitrary angle, depending on the angle of the line segment).
  6. The rectangles are converted to trapezoids. The non-Manhattan rotated rectangles are represented by three trapezoids.
  7. A polygon, implemented as trapezoids, is added at each vertex, to fill in the transition between edge segments. The list of all these trapezoids represents a path along the external edges of the original trapezoid group.
  8. If the bloat value is positive, the edge list is or'ed with the original trapezoid list. If the bloat value is negative, the edge list is clipped from the original trapezoid group. If bit 3 is set, this step is skipped, and the edge list is passed to the next step.
  9. The resulting trapezoid list is merged into polygons, representing the operation result.

bloat mode 0
If a trapezoid group is entirely Manhattan, meaning that all edges are horizontal or vertical, no corner vertex fill-in takes place. Instead, the vertical line segments are extended by the (positive) bloat dimension. Thus, bloated Manhattan objects always remain Manhattan.

Otherwise, the polygon to fill the empty area at a vertex between the segment rectangles is computed, according to the corner fill-in mode. This may add vertices to the resulting figures, giving rounded corners.

bloat mode 1
This mode is faster, but is not recommended for non-Manhattan geometry. The vertical segment ends are extended by the bloat dimension to cover (assumed) Manhattan corners. Non-Manhattan segments are added as a single trapezoid with a width computed from the bloat dimension. Note that this can cause small protrusions and other anomalies to appear after bloating.

bloat mode 2
This is the same as bloat mode 0, however the corners of Manhattan and non-Manhattan objects will be treated the same. The corners of positive-bloated boxes may be rounded, unlike mode 0.

bloat mode 3
This mode uses the DRC sizing functions to perform the bloating operation, with results similar to mode 2. All of the other flags except for bit 3 (edge template) are ignored with this choice. If bit 3 is set, an edge template is created, extending out of the original figure if the bloat value is positive, or inward if the bloat value is negative.

This mode works best if a !join is performed before the bloat. This algorithm is rather compute intensive and slower than the other algorithms. In this algorithm, parts of edges that touch an object on the same layer will not be moved, whether or not the adjacent object was selected. In the other algorithms, unselected objects are completely ignored.

Presently, if bit 2 is set, the ``old'' algorithms will be used. These give results similar to the new algorithms, but are slower.

old mode 0
In the description, we assume that the object is being expanded, i.e., the dimen is greater than zero. For each edge, an extension out of the object normal to the edge is created. For each corner where the edge projections do not overlap, a 4-sided polygon is created. Three of the vertices are the figure corner vertex and the ends of the two adjacent projections. The fourth vertex is placed along the bisector of the angle formed by the other three vertices, a distance dimen from the object corner vertex. All of the projections are joined to the original object to create the expanded object. Note that the corners become rounded, i.e., bloated rectangles become polygons. Figure 19.1 illustrates the algorithm.

Figure 19.1: The default algorithm used in the !bloat command to enlarge an object.

If the dimen is less than zero, the object will be shrunk. In this case, the projections extend into the object, and the new object is formed by clipping these regions from the object.

old mode 1
This algorithm works with a trapezoid decomposition of the objects to be modified. An expansion is very fast, but a shrink requires polarity inversion of the trapezoid list, so is somewhat slower. This algorithm is not really recommended for non-Manhattan geometry, since in working at the trapezoid level without considering adjacency, small artifacts are often introduced at non-Manhattan corners.

The algorithm takes the following steps:

If dimen > 0 (expanding):
  1. Decompose all selected objects on a given layer into a trapezoid list.
  2. Create a second list containing trapezoids derived from the edges of trapezoids in the first list, created to enclose each edge and the surrounding area to + / - dimen normal to the edge.
  3. Merge the two lists and join into polygons.

If dimen < 0 (shrinking):
  1. Decompose all selected objects on a given layer into a trapezoid list.
  2. Invert the list in a rectangle that encloses all trapezoids bloated by dimen.
  3. Create an edge trapezoid list from the inverted list.
  4. Clip out the regions of the original list that overlap trapezoids in the edge list.
  5. Merge the resulting list into polygons.

old mode 2
In this algorithm, for dimen larger than 0, the objects are first joined into maximal polygons, i.e., no two of these polygons abut or overlap. The vertex list of each polygon is used to construct a ``wire'' of width 2*dimen , which is then converted to a polygon representation. The wire polygon covers the edge of the original polygon, extending by dimen inside and outside of the figure. Each polygon becomes the union of the original polygon and its ``wire'' polygon. If dimen is less than zero, the geometry is inverted first as in the previous algorithm. Thus, the edge ``wires'' around the clear areas are found. These are clipped from the dark areas, yielding the final figures. Without the inversion, polygons with holes would not be processed correctly.

Note that bloating modes 1 and 2 will not round the corners, i.e., Manhattan corners remain Manhattan.

next up previous contents index
Next: The !join Command: Join Up: Layout Editing Previous: The !poly2path Command: Polygon   Contents   Index
Stephen R. Whiteley 2022-05-28