4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996 Thomas Nau
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Contact addresses for paper mail and Email:
22 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 * Thomas.Nau@rz.uni-ulm.de
27 /* prototypes for polygon editing routines
35 /* Implementation constants */
37 #define POLY_CIRC_SEGS 40
38 #define POLY_CIRC_SEGS_F ((float)POLY_CIRC_SEGS)
40 /* adjustment to make the segments outline the circle rather than connect
41 * points on the circle: 1 - cos (\alpha / 2) < (\alpha / 2) ^ 2 / 2
43 #define POLY_CIRC_RADIUS_ADJ (1.0 + M_PI / POLY_CIRC_SEGS_F * \
44 M_PI / POLY_CIRC_SEGS_F / 2.0)
46 /* polygon diverges from modelled arc no more than MAX_ARC_DEVIATION * thick */
47 #define POLY_ARC_MAX_DEVIATION 0.02
51 void polygon_init (void);
52 Cardinal
polygon_point_idx (PolygonType
* polygon
, PointType
* point
);
53 Cardinal
polygon_point_contour (PolygonType
* polygon
, Cardinal point
);
54 Cardinal
prev_contour_point (PolygonType
* polygon
, Cardinal point
);
55 Cardinal
next_contour_point (PolygonType
* polygon
, Cardinal point
);
56 Cardinal
GetLowestDistancePolygonPoint (PolygonType
*,
58 bool RemoveExcessPolygonPoints (LayerType
*, PolygonType
*);
59 void GoToPreviousPoint (void);
60 void ClosePolygon (void);
61 void CopyAttachedPolygonToLayer (void);
62 int PolygonHoles (PolygonType
*ptr
, const BoxType
*range
,
63 int (*callback
) (PLINE
*, void *user_data
),
65 int PlowsPolygon (DataType
*, int, void *, void *,
66 int (*callback
) (DataType
*, LayerType
*, PolygonType
*, int, void *, void *, void *),
68 void ComputeNoHoles (PolygonType
*poly
);
69 POLYAREA
* ContourToPoly (PLINE
*);
70 POLYAREA
* PolygonToPoly (PolygonType
*);
71 POLYAREA
* RectPoly (Coord x1
, Coord x2
, Coord y1
, Coord y2
);
72 POLYAREA
* CirclePoly (Coord x
, Coord y
, Coord radius
);
73 POLYAREA
* OctagonPoly(Coord x
, Coord y
, Coord radius
);
74 POLYAREA
* LinePoly(LineType
*l
, Coord thick
);
75 POLYAREA
* ArcPoly(ArcType
*l
, Coord thick
);
76 POLYAREA
* PinPoly(PinType
*l
, Coord thick
, Coord clear
);
77 POLYAREA
* BoxPolyBloated (BoxType
*box
, Coord radius
);
78 void frac_circle (PLINE
*, Coord
, Coord
, Vector
, int);
79 int InitClip(DataType
*d
, LayerType
*l
, PolygonType
*p
);
80 void RestoreToPolygon(DataType
*, int, void *, void *);
81 void ClearFromPolygon(DataType
*, int, void *, void *);
83 bool IsPointInPolygon (Coord
, Coord
, Coord
, PolygonType
*);
84 bool IsPointInPolygonIgnoreHoles (Coord
, Coord
, PolygonType
*);
85 bool IsRectangleInPolygon (Coord
, Coord
, Coord
, Coord
, PolygonType
*);
86 bool isects (POLYAREA
*, PolygonType
*, bool);
87 bool MorphPolygon (LayerType
*, PolygonType
*);
88 void NoHolesPolygonDicer (PolygonType
*p
, const BoxType
*clip
,
89 void (*emit
) (PLINE
*, void *), void *user_data
);
90 void PolyToPolygonsOnLayer (DataType
*, LayerType
*, POLYAREA
*, FlagType
);