** Next:** The !polyfix Command: Fix
** Up:** Layout Editing
** Previous:** The !split Command: Atomize
** Contents**
** Index**

##

The **!manh** Command: Convert to Manhattan Polygons

Syntax: `!manh` *min_box_size* [*mode*]

This command applies to selected polygons. It will convert each
polygon to a Manhattan approximation, meaning that all sides will be
horizontal or vertical.
The first argument is the size, in microns, of the minimum box
width/height used to approximate non-Manhattan parts of the polygon.

The second argument is an integer that provides a choice of
algorithms. If this argument is not given, a zero value is
understood. Presently, there are two Manhattanizing algorithms
available, specified if *mode* is zero or nonzero.

When *mode* is zero (or not given), the operation works as
follows. First, a polygon is decomposed into trapezoids, each of
which is subdivided horizontally if necessary so that it can be
further split vertically into rectangular and right-triangular pieces.
The triangular pieces are divided, recursively, into a rectangular and
two residual right-triangular pieces. All of the rectangular pieces
whose height and width are *min_box_size* or larger are kept,
and reassembled into a new Manhattan polygon.

In this mode, the rectangular elements can have arbitrary size,
(though sufficiently large), and there is no restriction on coordinate
locations.

When *mode* is nonzero, a different approach is taken. First, a
polygon is decomposed into a collection of trapezoids, and each
trapezoid is processed. For each trapezoid, all coordinates are moved
to a "grid" of size *min_box_size*. If either side is
non-Manhattan, Bresenham's method is used to scan the trapezoid
vertically, creating a new Manhattan trapezoid for each "scan line"
(grid point) where the width changes. The collection of trapezoids
produced is reassembled into a new Manhattan polygon.

In this mode, all coordinates are moved to the grid, thus all the
rectangular elements used to build the trapezoid have height and width
an integer multiple of *min_box_size*.

** Next:** The !polyfix Command: Fix
** Up:** Layout Editing
** Previous:** The !split Command: Atomize
** Contents**
** Index**
Stephen R. Whiteley
2017-03-22