pcb 4.1.1
An interactive printed circuit board layout editor.

polygon.h File Reference

Prototypes for polygon editing routines. More...

#include "global.h"
Include dependency graph for polygon.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define POLY_CIRC_SEGS   40
#define POLY_CIRC_SEGS_F   ((float)POLY_CIRC_SEGS)
#define POLY_CIRC_RADIUS_ADJ
 Adjustment to make the segments outline the circle rather than connect points on the circle: $ 1 - cos ( \frac {\alpha} {2} ) < \frac { ( \frac {\alpha} {2} ) ^ 2 } {2} $.
#define POLY_ARC_MAX_DEVIATION   0.02
 Polygon diverges from modelled arc no more than MAX_ARC_DEVIATION * thick.

Functions

void polygon_init (void)
Cardinal polygon_point_idx (PolygonType *polygon, PointType *point)
Cardinal polygon_point_contour (PolygonType *polygon, Cardinal point)
 Find contour number.
Cardinal prev_contour_point (PolygonType *polygon, Cardinal point)
Cardinal next_contour_point (PolygonType *polygon, Cardinal point)
Cardinal GetLowestDistancePolygonPoint (PolygonType *, Coord, Coord)
 
bool RemoveExcessPolygonPoints (LayerType *, PolygonType *)
 Remove redundant polygon points.
void GoToPreviousPoint (void)
 Go back to the previous point of the polygon.
void ClosePolygon (void)
 Close polygon if possible.
void CopyAttachedPolygonToLayer (void)
 Moves the data of the attached (new) polygon to the current layer.
int PolygonHoles (PolygonType *ptr, const BoxType *range, int(*callback)(PLINE *, void *user_data), void *user_data)
int PlowsPolygon (DataType *, int, void *, void *, int(*callback)(DataType *, LayerType *, PolygonType *, int, void *, void *, void *), void *userdata)
void ComputeNoHoles (PolygonType *poly)
POLYAREAContourToPoly (PLINE *)
POLYAREAPolygonToPoly (PolygonType *)
POLYAREARectPoly (Coord x1, Coord x2, Coord y1, Coord y2)
POLYAREACirclePoly (Coord x, Coord y, Coord radius)
 Create a circle approximation from lines.
POLYAREAOctagonPoly (Coord x, Coord y, Coord radius)
POLYAREALinePoly (LineType *l, Coord thick)
POLYAREAArcPoly (ArcType *l, Coord thick)
POLYAREAPinPoly (PinType *l, Coord thick, Coord clear)
 Create a polygon of the pin clearance.
POLYAREABoxPolyBloated (BoxType *box, Coord radius)
void frac_circle (PLINE *, Coord, Coord, Vector, int)
 Add vertices in a fractional-circle starting from v centered at X, Y and going counter-clockwise.
int InitClip (DataType *d, LayerType *l, PolygonType *p)
void RestoreToPolygon (DataType *, int, void *, void *)
void ClearFromPolygon (DataType *, int, void *, void *)
bool IsPointInPolygon (Coord, Coord, Coord, PolygonType *)
bool IsPointInPolygonIgnoreHoles (Coord, Coord, PolygonType *)
bool IsRectangleInPolygon (Coord, Coord, Coord, Coord, PolygonType *)
bool isects (POLYAREA *, PolygonType *, bool)
bool MorphPolygon (LayerType *, PolygonType *)
 Make a polygon split into multiple parts into multiple polygons.
void NoHolesPolygonDicer (PolygonType *p, const BoxType *clip, void(*emit)(PLINE *, void *), void *user_data)
void PolyToPolygonsOnLayer (DataType *, LayerType *, POLYAREA *, FlagType)
 Convert a POLYAREA (and all linked POLYAREA) to raw PCB polygons on the given layer.

Detailed Description

Prototypes for polygon editing routines.


Copyright.


PCB, interactive printed circuit board design

Copyright (C) 1994,1995,1996 Thomas Nau

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Contact addresses for paper mail and Email:

Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany

Thomas.Nau@rz.uni-ulm.de

Definition in file polygon.h.


Define Documentation

#define POLY_ARC_MAX_DEVIATION   0.02

Polygon diverges from modelled arc no more than MAX_ARC_DEVIATION * thick.

Definition at line 57 of file polygon.h.

Referenced by ArcPolyNoIntersect(), and SetArcBoundingBox().

#define POLY_CIRC_RADIUS_ADJ
Value:

Adjustment to make the segments outline the circle rather than connect points on the circle: $ 1 - cos ( \frac {\alpha} {2} ) < \frac { ( \frac {\alpha} {2} ) ^ 2 } {2} $.

Definition at line 50 of file polygon.h.

Referenced by frac_circle(), SetArcBoundingBox(), SetLineBoundingBox(), SetPadBoundingBox(), and SetPinBoundingBox().

#define POLY_CIRC_SEGS   40

Definition at line 42 of file polygon.h.

Referenced by frac_circle().

#define POLY_CIRC_SEGS_F   ((float)POLY_CIRC_SEGS)

Definition at line 43 of file polygon.h.

Referenced by polygon_init().


Function Documentation

POLYAREA* ArcPoly ( ArcType l,
Coord  thick 
)

Definition at line 565 of file polygon.c.

References ArcPolyNoIntersect(), ArcType::Delta, M_PI, MIN_CLEARANCE_BEFORE_BISECT, PBO_UNITE, poly_Boolean_free(), ArcType::StartAngle, and ArcType::Width.

Referenced by IsArcInPolygon(), SubtractArc(), and ThermPoly().

Here is the call graph for this function:

POLYAREA* BoxPolyBloated ( BoxType box,
Coord  radius 
)

Definition at line 799 of file polygon.c.

References RectPoly(), BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.

Referenced by UnsubtractArc(), UnsubtractLine(), UnsubtractPad(), UnsubtractPin(), and UnsubtractText().

Here is the call graph for this function:

POLYAREA* CirclePoly ( Coord  x,
Coord  y,
Coord  radius 
)

Create a circle approximation from lines.

Definition at line 438 of file polygon.c.

References ContourToPoly(), PLINE::cx, PLINE::cy, frac_circle(), PLINE::is_round, poly_NewContour(), PLINE::radius, TRUE, x, and y.

Referenced by IsPointInPolygon(), LinePoly(), PinPoly(), and ThermPoly().

Here is the call graph for this function:

void ClosePolygon ( void  )

Close polygon if possible.

Definition at line 1386 of file polygon.c.

References _, abs, CrosshairType::AttachedPolygon, CopyAttachedPolygonToLayer(), Crosshair, Draw(), Message(), n, PCB, polygon_st::PointN, polygon_st::Points, TEST_FLAG, PointType::X, and PointType::Y.

Referenced by ActionPolygon().

Here is the call graph for this function:

void ComputeNoHoles ( PolygonType poly)

Definition at line 213 of file polygon.c.

References add_noholes_polyarea(), polygon_st::Clipped, polygon_st::NoHoles, NoHolesPolygonDicer(), polygon_st::NoHolesValid, and poly_FreeContours().

Referenced by common_fill_pcb_polygon().

Here is the call graph for this function:

POLYAREA* ContourToPoly ( PLINE )
void CopyAttachedPolygonToLayer ( void  )
void frac_circle ( PLINE c,
Coord  X,
Coord  Y,
Vector  v,
int  fraction 
)

Add vertices in a fractional-circle starting from v centered at X, Y and going counter-clockwise.

Does not include the first point. last argument is 1 for a full circle. 2 for a half circle. or 4 for a quarter circle.

Definition at line 410 of file polygon.c.

References PLINE::head, POLY_CIRC_RADIUS_ADJ, POLY_CIRC_SEGS, poly_CreateNode(), poly_InclVertex(), VNODE::prev, rotate_circle_seg, ROUND, X, and Y.

Referenced by ArcPolyNoIntersect(), CirclePoly(), LinePoly(), RoundRect(), square_therm(), and SquarePadPoly().

Here is the call graph for this function:

Cardinal GetLowestDistancePolygonPoint ( PolygonType Polygon,
Coord  X,
Coord  Y 
)

Returns:
The index of the polygon point which is the end point of the segment with the lowest distance to the passed coordinates.

Definition at line 1300 of file polygon.c.

References n, polygon_st::PointN, polygon_st::Points, prev_contour_point(), ptr1, ptr2, SQUARE, u(), PointType::X, and PointType::Y.

Referenced by NotifyMode().

Here is the call graph for this function:

void GoToPreviousPoint ( void  )
bool isects ( POLYAREA ,
PolygonType ,
bool   
)

Definition at line 1708 of file polygon.c.

References polygon_st::Clipped, poly_Free(), Touching(), and x.

Referenced by IsArcInPolygon(), IsLineInPolygon(), IsPointInPolygon(), IsPolygonInPolygon(), IsRectangleInPolygon(), LOCtoPVpoly_callback(), and pv_poly_callback().

Here is the call graph for this function:

bool IsPointInPolygon ( Coord  ,
Coord  ,
Coord  ,
PolygonType  
)

Definition at line 1722 of file polygon.c.

References c, CirclePoly(), polygon_st::Clipped, isects(), poly_CheckInside(), X, and Y.

Referenced by CheckPolygonForRubberbandConnection(), LOCtoPVpoly_callback(), mptl_pin_callback(), polygon_callback(), and pv_poly_callback().

Here is the call graph for this function:

bool IsPointInPolygonIgnoreHoles ( Coord  ,
Coord  ,
PolygonType  
)

Definition at line 1739 of file polygon.c.

References polygon_st::Clipped, POLYAREA::contours, poly_InsideContour(), X, and Y.

Referenced by DrawShortestRats().

Here is the call graph for this function:

bool IsRectangleInPolygon ( Coord  ,
Coord  ,
Coord  ,
Coord  ,
PolygonType  
)

Definition at line 1748 of file polygon.c.

References isects(), max, min, RectPoly(), and s.

Referenced by IsLineInPolygon(), LOCtoPVpoly_callback(), and pv_poly_callback().

Here is the call graph for this function:

POLYAREA* LinePoly ( LineType l,
Coord  thick 
)
Cardinal next_contour_point ( PolygonType polygon,
Cardinal  point 
)

Definition at line 157 of file polygon.c.

References polygon_st::HoleIndex, polygon_st::HoleIndexN, polygon_st::PointN, and polygon_point_contour().

Referenced by RemoveExcessPolygonPoints(), XORDrawMoveOrCopyObject(), and XORPolygon().

Here is the call graph for this function:

void NoHolesPolygonDicer ( PolygonType p,
const BoxType clip,
void(*)(PLINE *, void *)  emit,
void *  user_data 
)
POLYAREA* OctagonPoly ( Coord  x,
Coord  y,
Coord  radius 
)

Definition at line 370 of file polygon.c.

References ContourToPoly(), PLINE::head, poly_CreateNode(), poly_InclVertex(), poly_NewContour(), VNODE::prev, ROUND, TAN_22_5_DEGREE_2, x, and y.

Referenced by LOCtoPVpoly_callback(), oct_therm(), PinPoly(), and pv_poly_callback().

Here is the call graph for this function:

POLYAREA* PinPoly ( PinType l,
Coord  thick,
Coord  clear 
)

Create a polygon of the pin clearance.

Definition at line 777 of file polygon.c.

References CirclePoly(), OctagonPoly(), RoundRect(), TEST_FLAG, pin_st::X, and pin_st::Y.

Referenced by pin_sub_callback(), and SubtractPin().

Here is the call graph for this function:

int PlowsPolygon ( DataType ,
int  ,
void *  ,
void *  ,
int(*)(DataType *, LayerType *, PolygonType *, int, void *, void *, void *)  callback,
void *  userdata 
)
void polygon_init ( void  )

Definition at line 120 of file polygon.c.

References M_PI, POLY_CIRC_SEGS_F, and rotate_circle_seg.

Referenced by main().

Cardinal polygon_point_contour ( PolygonType polygon,
Cardinal  point 
)

Find contour number.

0 for outer,

1 for first hole etc..

Definition at line 145 of file polygon.c.

References polygon_st::HoleIndex, and polygon_st::HoleIndexN.

Referenced by DestroyPolygonPoint(), next_contour_point(), prev_contour_point(), and RemovePolygonPoint().

Cardinal polygon_point_idx ( PolygonType polygon,
PointType point 
)
int PolygonHoles ( PolygonType ptr,
const BoxType range,
int(*)(PLINE *, void *user_data)  callback,
void *  user_data 
)
POLYAREA* PolygonToPoly ( PolygonType )

Definition at line 338 of file polygon.c.

References original_poly().

Referenced by NotifyMode().

Here is the call graph for this function:

void PolyToPolygonsOnLayer ( DataType ,
LayerType ,
POLYAREA ,
FlagType   
)
Cardinal prev_contour_point ( PolygonType polygon,
Cardinal  point 
)
POLYAREA* RectPoly ( Coord  x1,
Coord  x2,
Coord  y1,
Coord  y2 
)
bool RemoveExcessPolygonPoints ( LayerType Layer,
PolygonType Polygon 
)

Remove redundant polygon points.

Any point that lies on the straight line between the points on either side of it is redundant.

Returns:
True if any points are removed.

Definition at line 1265 of file polygon.c.

References IsPointOnLine(), line, n, next_contour_point(), polygon_st::PointN, polygon_st::Points, prev_contour_point(), RemoveObject(), Undoing(), PointType::X, and PointType::Y.

Referenced by InsertPointIntoPolygon(), MovePolygonPoint(), and RemovePolygonPoint().

Here is the call graph for this function: