Index: polygon.html =================================================================== --- polygon.html (revision 10112) +++ polygon.html (revision 10113) @@ -1,5 +1,5 @@

different faces of a polygon

- +

In pcb-rnd polygons have three possible appearance:

+

The as-drawn version

+

+The as-drawn version is a list of points (corners), as drawn +by the user. The points are stored in an array of x;y coordinates. +There is a single, continous, dynamically allocated array for all points, +including the outer contour and the holes. +

+The points are stored in the Points[] field. The HoleIndex[] +field lists the starting index of each hole. For example a +rectangular polygon with 2 triangle holes is stored as: +

+ +
index 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. +
Points[] value c1 c2 c3 c4 h1.1 h1.2 h1.3 h2.1 h2.2 h2.3 +
part of outer contour hole 1 hole 2 +
+

+The array length of Points[] is 10, the length of the correspoding HoleIndex[] is 2. +The values of HoleIndex[] is {4, 7}, indicating that the corners of first hole +starts at 4 while the corners of the second hole starts at 7. +

+If HoldeIndex[] is NULL, there are no holes and all points are part of the +outer contour. The Outer contour must contain at least 3 points. +

+The as-drawn version always contains the contour of a single island +and 0 or more holes - none of them can intersect or touch any contour or +hole of the same polygon. This also means a contour or hole can not be +self-intersecting. +

+The as-drawn version is stored to make editing possible. It is +not affected by other objects (e.g. clearances) or flags of the polygon. +The as-drawn points exist and are stored even if they are not visible +(clipped). + + +

The clipped version

+

+The polygon is clipped by an object if both the polygon and the object have +the correspoding 'clear' flag set. A clipped polygon typically has a much +more complex shape than the as-drawn polygon, due to the clearance cutouts +(not to be confused with user drawn holes). The clipped polygon is the actual +"in-copper" shape of the polygon. +

+In some cases the clearance cutouts slice the polygon in multiple components +or in other word islands. If the polygon is full (set by +a polygon flag), all islands are kept, else only the largest island is kept. +(Note: the find code handles all islands of a full polygon as one polygon: it +indicates connection between them even if there is no connection, which makes +full polygons dangerous on copper layers.) +

+The clipped polygon is stored in the polyarea field Clipped. It is a doubly +linked circular list (link fields are .f for forward and .b for backward). Each +item on the list is an island of the polygon. If Clipped is NULL, the +polygon clipping is not yet compiled for the given polygon; call pcb_poly_init_clip(). +

+Each island is a polyarea, which consists of an outer contour and 0 or more +holes - all correspoding to the actual cutouts created by user-drawn polygon +holes and/or clearance cutouts. These contours are stored in a singly linked +list of plines. The first element of the list is the pline for the outer +contour and always exists. The next 0 or more plines, using the .next field +of the pline, are the contours of the cutouts (holes). +

+A pline consists of a circular, doubly linked list of points; traversing using +the .next field, the points are ordered in counter-clockwise. + +

The no-holes version

+

+Some export plugins (and/or export formats) don't support holes in polygons. +The no-hole version of the polygon is stored in the .NoHoles filed and is +a list of islands, each specified with an outer countour that are crafted +to include the holes. This is done by slicing an island at each hole. +TODO: check how it looks, include image + + +

How to code with polygons

+

Iterators: looping on clipped polygon geometry

The following code prints all contours and holes of a polygon, using loops