Data members

isolate int
layer int
orphans int (0=off, 1=on)
pour int (POLYGON_POUR_...)
rank int
spacing int
thermals int (0=off, 1=on)
width int

Loop members

contours() UL_WIRE (see note)
fillings() UL_WIRE
wires() UL_WIRE





The contours() and fillings() loop members loop through the wires that are used to draw the calculated polygon if it is part of a signal and the polygon has been calculated by the RATSNEST command. The wires() loop member always loops through the polygon wires as they were drawn by the user. For an uncalculated signal polygon contours() does the same as wires(), and fillings() does nothing.

Polygon width

When using the fillings() loop member to get the fill wires of a solid polygon, make sure the width of the polygon is not zero (actually it should be quite a bit larger than zero, for example at least the hardware resolution of the output device you are going to draw on). Filling a polygon with zero width may result in enormous amounts of data, since it will be calculated with the smallest editor resolution of 1/10000mm!

Partial polygons

A calculated signal polygon may consist of several distinct parts (called positive polygons), each of which can contain extrusions (negative polygons) resulting from other objects being subtracted from the polygon. Negative polygons can again contain other positive polygons and so on.

The wires looped through by contours() always start with a positive polygon. To find out where one partial polygon ends and the next one begins, simply store the (x1,y1) coordinates of the first wire and check them against (x2,y2) of every following wire. As soon as these are equal, the last wire of a partial polygon has been found. It is also guaranteed that the second point (x2,y2) of one wire is identical to the first point (x1,y1) of the next wire in that partial polygon.

To find out where the "inside" and the "outside" of the polygon lays, take any contour wire and imagine looking from its point (x1,y1) to (x2,y2). The "inside" of the polygon is always on the right side of the wire. Note that if you simply want to draw the polygon you won't need all these details.


board(B) {
  B.signals(S) {
    S.polygons(P) {
      int x0, y0, first = 1;
      P.contours(W) {
        if (first) {
           // a new partial polygon is starting
           x0 = W.x1;
           y0 = W.y1;
        // ...
        // do something with the wire
        // ...
        if (first)
           first = 0;
        else if (W.x2 == x0 && W.y2 == y0) {
           // this was the last wire of the partial polygon,
           // so the next wire (if any) will be the first wire
           // of the next partial polygon
           first = 1;

Index Copyright © 2005 CadSoft Computer GmbH