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
28 /* prototypes for polygon editing routines
31 #ifndef __POLYGON_INCLUDED__
32 #define __POLYGON_INCLUDED__
36 /* Implementation constants */
38 #define POLY_CIRC_SEGS 40
39 #define POLY_CIRC_SEGS_F ((float)POLY_CIRC_SEGS)
41 /* adjustment to make the segments outline the circle rather than connect
42 * points on the circle: 1 - cos (\alpha / 2) < (\alpha / 2) ^ 2 / 2
44 #define POLY_CIRC_RADIUS_ADJ (1.0 + M_PI / POLY_CIRC_SEGS_F * \
45 M_PI / POLY_CIRC_SEGS_F / 2.0)
47 /* polygon diverges from modelled arc no more than MAX_ARC_DEVIATION * thick */
48 #define POLY_ARC_MAX_DEVIATION 0.02
52 void polygon_init (void);
53 Cardinal
polygon_point_idx (PolygonTypePtr polygon
, PointTypePtr point
);
54 Cardinal
polygon_point_contour (PolygonTypePtr polygon
, Cardinal point
);
55 Cardinal
prev_contour_point (PolygonTypePtr polygon
, Cardinal point
);
56 Cardinal
next_contour_point (PolygonTypePtr polygon
, Cardinal point
);
57 Cardinal
GetLowestDistancePolygonPoint (PolygonTypePtr
,
58 LocationType
, LocationType
);
59 bool RemoveExcessPolygonPoints (LayerTypePtr
, PolygonTypePtr
);
60 void GoToPreviousPoint (void);
61 void ClosePolygon (void);
62 void CopyAttachedPolygonToLayer (void);
63 int PolygonHoles (PolygonType
*ptr
, const BoxType
*range
,
64 int (*callback
) (PLINE
*, void *user_data
),
66 int PlowsPolygon (DataType
*, int, void *, void *,
67 int (*callback
) (DataTypePtr
, LayerTypePtr
, PolygonTypePtr
, int, void *, void *));
68 void ComputeNoHoles (PolygonType
*poly
);
69 POLYAREA
* ContourToPoly (PLINE
*);
70 POLYAREA
* PolygonToPoly (PolygonType
*);
71 POLYAREA
* RectPoly (LocationType x1
, LocationType x2
, LocationType y1
, LocationType y2
);
72 POLYAREA
* CirclePoly(LocationType x
, LocationType y
, BDimension radius
);
73 POLYAREA
* OctagonPoly(LocationType x
, LocationType y
, BDimension radius
);
74 POLYAREA
* LinePoly(LineType
*l
, BDimension thick
);
75 POLYAREA
* ArcPoly(ArcType
*l
, BDimension thick
);
76 POLYAREA
* PinPoly(PinType
*l
, BDimension thick
, BDimension clear
);
77 POLYAREA
* BoxPolyBloated (BoxType
*box
, BDimension radius
);
78 void frac_circle (PLINE
*, LocationType
, LocationType
, 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 (LocationType
, LocationType
, BDimension
, PolygonTypePtr
);
84 bool IsPointInPolygonIgnoreHoles (LocationType
, LocationType
, PolygonTypePtr
);
85 bool IsRectangleInPolygon (LocationType
, LocationType
, LocationType
,
86 LocationType
, PolygonTypePtr
);
87 bool isects (POLYAREA
*, PolygonTypePtr
, bool);
88 bool MorphPolygon (LayerTypePtr
, PolygonTypePtr
);
89 void NoHolesPolygonDicer (PolygonType
*p
, const BoxType
*clip
,
90 void (*emit
) (PLINE
*, void *), void *user_data
);
91 void PolyToPolygonsOnLayer (DataType
*, LayerType
*, POLYAREA
*, FlagType
);