4 * \brief Prototypes for polygon editing routines.
8 * <h1><b>Copyright.</b></h1>\n
10 * PCB, interactive printed circuit board design
12 * Copyright (C) 1994,1995,1996 Thomas Nau
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 * Contact addresses for paper mail and Email:
30 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
32 * Thomas.Nau@rz.uni-ulm.de
40 /* Implementation constants */
42 #define POLY_CIRC_SEGS 40 //24 //20 //8 //40
43 #define POLY_CIRC_SEGS_D ((double)POLY_CIRC_SEGS)
48 * IT BREAKS THE CIRCULARITY OF CIRULAR CONTORS, AS THE FIRST
49 * FIRST VERTEX ADDED BY CirclePoly IS NOT RADIUS ADJUSTED.
51 * IT BREAKS CIRCULARITY OF ALIGMENT BETWEEN A LINE AND ITS END-CAPS,
52 * LEADING TO MORE COMPLEX CONTOURS FOR COMMON LINE-LINE INTERSECTIONS,
53 * SUCH AS 90 AND 45 DEGREE ANGLES
55 * IT WAS INTENDED TO AVOID DRC ERRORS WITH "TOO-CLOSE" FEATURES,
56 * BUT COULD OTHERWISE CAUSE THEM FOR "TOO THIN" FEATURES - INSIDE/OUTSIDE
57 * CONTOUR APPROXIMATION NEEDS TO BE CONTROLED DEPENDING ON THE REQUIREMENT
60 * \brief Adjustment to make the segments outline the circle rather than
61 * connect points on the circle:
62 * \f$ 1 - cos ( \frac {\alpha} {2} ) < \frac { ( \frac {\alpha} {2} ) ^ 2 } {2} \f$
64 #define POLY_CIRC_RADIUS_ADJ (1.0 + M_PI / POLY_CIRC_SEGS_D * \
65 M_PI / POLY_CIRC_SEGS_D / 2.0)
67 #define POLY_CIRC_RADIUS_ADJ 1.0
71 * \brief Polygon diverges from modelled arc no more than
72 * MAX_ARC_DEVIATION * thick.
74 #define POLY_ARC_MAX_DEVIATION 0.02
78 void polygon_init (void);
79 Cardinal
polygon_point_idx (PolygonType
* polygon
, PointType
* point
);
80 Cardinal
polygon_point_contour (PolygonType
* polygon
, Cardinal point
);
81 Cardinal
prev_contour_point (PolygonType
* polygon
, Cardinal point
);
82 Cardinal
next_contour_point (PolygonType
* polygon
, Cardinal point
);
83 Cardinal
GetLowestDistancePolygonPoint (PolygonType
*,
85 bool RemoveExcessPolygonPoints (LayerType
*, PolygonType
*);
86 void GoToPreviousPoint (void);
87 void ClosePolygon (void);
88 void CopyAttachedPolygonToLayer (void);
89 int PolygonHoles (PolygonType
*ptr
, const BoxType
*range
,
90 int (*callback
) (PLINE
*, void *user_data
),
92 int PlowsPolygon (DataType
*, int, void *, void *,
93 int (*callback
) (DataType
*, LayerType
*, PolygonType
*, int, void *, void *, void *),
95 void ComputeNoHoles (PolygonType
*poly
);
96 POLYAREA
* ContourToPoly (PLINE
*);
97 POLYAREA
* PolygonToPoly (PolygonType
*);
98 POLYAREA
* RectPoly (Coord x1
, Coord x2
, Coord y1
, Coord y2
);
99 POLYAREA
* CirclePoly (Coord x
, Coord y
, Coord radius
, char *name
);
100 POLYAREA
* OctagonPoly(Coord x
, Coord y
, Coord radius
);
101 POLYAREA
* LinePoly(LineType
*l
, Coord thick
, char *name
);
102 POLYAREA
* ArcPoly(ArcType
*l
, Coord thick
, char *name
);
103 POLYAREA
* PinPoly(PinType
*l
, Coord thick
);
104 POLYAREA
* BoxPolyBloated (BoxType
*box
, Coord radius
);
105 POLYAREA
* PadPoly (PadType
*pad
, Coord size
);
106 void frac_circle (PLINE
*, Coord
, Coord
, Vector
, int);
107 void frac_circle2 (PLINE
*, Coord
, Coord
, Vector
, int);
108 int InitClip(DataType
*d
, LayerType
*l
, PolygonType
*p
);
109 void RestoreToPolygon(DataType
*, int, void *, void *);
110 void ClearFromPolygon(DataType
*, int, void *, void *);
112 bool IsPointInPolygon (Coord
, Coord
, Coord
, PolygonType
*);
113 bool IsPointInPolygonIgnoreHoles (Coord
, Coord
, PolygonType
*);
114 bool IsRectangleInPolygon (Coord
, Coord
, Coord
, Coord
, PolygonType
*);
115 bool isects (POLYAREA
*, PolygonType
*, bool);
116 bool MorphPolygon (LayerType
*, PolygonType
*);
117 void NoHolesPolygonDicer (PolygonType
*p
, const BoxType
*clip
,
118 void (*emit
) (PLINE
*, void *), void *user_data
);
119 void PolyToPolygonsOnLayer (DataType
*, LayerType
*, POLYAREA
*, FlagType
);
120 POLYAREA
*board_outline_poly (bool include_holes
);