pcb 4.1.1
An interactive printed circuit board layout editor.
|
Prototypes for polygon editing routines. More...
#include "global.h"
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: . | |
#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) |
POLYAREA * | ContourToPoly (PLINE *) |
POLYAREA * | PolygonToPoly (PolygonType *) |
POLYAREA * | RectPoly (Coord x1, Coord x2, Coord y1, Coord y2) |
POLYAREA * | CirclePoly (Coord x, Coord y, Coord radius) |
Create a circle approximation from lines. | |
POLYAREA * | OctagonPoly (Coord x, Coord y, Coord radius) |
POLYAREA * | LinePoly (LineType *l, Coord thick) |
POLYAREA * | ArcPoly (ArcType *l, Coord thick) |
POLYAREA * | PinPoly (PinType *l, Coord thick, Coord clear) |
Create a polygon of the pin clearance. | |
POLYAREA * | BoxPolyBloated (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. |
Prototypes for polygon editing routines.
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
Definition in file polygon.h.
#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 |
(1.0 + M_PI / POLY_CIRC_SEGS_F * \ M_PI / POLY_CIRC_SEGS_F / 2.0)
Adjustment to make the segments outline the circle rather than connect points on the circle: .
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().
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().
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().
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().
void ClearFromPolygon | ( | DataType * | , |
int | , | ||
void * | , | ||
void * | |||
) |
Definition at line 1696 of file polygon.c.
References PCBType::Data, InitClip(), PCB, PlowsPolygon(), DataType::polyClip, and subtract_plow().
Referenced by AddObjectToCreateUndoList(), ChangeArcAngles(), ChangeArcClearSize(), ChangeArcJoin(), ChangeArcSize(), ChangeElement2ndSize(), ChangeHole(), ChangeLineClearSize(), ChangeLineJoin(), ChangeLineSize(), ChangeObjectViaLayers(), ChangePadClearSize(), ChangePadSize(), ChangePadSquare(), ChangePin2ndSize(), ChangePinClearSize(), ChangePinOctagon(), ChangePinSize(), ChangePinSquare(), ChangePinThermal(), ChangeSelectedViaLayers(), ChangeTextJoin(), ChangeTextName(), ChangeTextSize(), ChangeVia2ndSize(), ChangeViaClearSize(), ChangeViaOctagon(), ChangeViaSize(), ChangeViaThermal(), FreeRotateElementLowLevel(), InsertPointIntoLine(), IronDownAllUnfixedPaths(), MirrorElementCoordinates(), MoveArc(), MoveArcToBuffer(), MoveArcToLayer(), MoveElementLowLevel(), MoveElementToBuffer(), MoveLine(), MoveLinePoint(), MoveLineToBuffer(), MoveLineToLayer(), MoveText(), MoveTextToBuffer(), MoveTextToLayerLowLevel(), MoveVia(), MoveViaToBuffer(), RotateArc(), RotateElementLowLevel(), RotateLinePoint(), RotateObject(), RotateText(), UndoChangeClearSize(), UndoChangeSize(), UndoClearPoly(), and UndoSetViaLayers().
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().
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().
Definition at line 274 of file polygon.c.
References PLINE::Flags, PLINE::orient, PLF_DIR, poly_Create(), poly_InclContour(), poly_PreContour(), poly_Valid(), and TRUE.
Referenced by ArcPolyNoIntersect(), CirclePoly(), diag_line(), LinePoly(), OctagonPoly(), RectPoly(), RoundRect(), square_therm(), and SquarePadPoly().
void CopyAttachedPolygonToLayer | ( | void | ) |
Moves the data of the attached (new) polygon to the current layer.
Definition at line 1424 of file polygon.c.
References addedLines, AddObjectToCreateUndoList(), CrosshairType::AttachedLine, CrosshairType::AttachedPolygon, CreateNewPolygon(), Crosshair, CURRENT, PCBType::Data, DrawPolygon(), IncrementUndoSerialNumber(), InitClip(), NoFlags, PCB, cpInfo::polygon, r_create_tree(), r_insert_entry(), SET_FLAG, SetChangedFlag(), SetPolygonBoundingBox(), AttachedLineType::State, STATE_FIRST, and TEST_FLAG.
Referenced by ClosePolygon(), and NotifyMode().
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().
Cardinal GetLowestDistancePolygonPoint | ( | PolygonType * | Polygon, |
Coord | X, | ||
Coord | Y | ||
) |
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().
void GoToPreviousPoint | ( | void | ) |
Go back to the previous point of the polygon.
Definition at line 1353 of file polygon.c.
References addedLines, CrosshairType::AttachedLine, CrosshairType::AttachedPolygon, Crosshair, n, AttachedLineType::Point1, polygon_st::PointN, polygon_st::Points, AttachedLineType::State, STATE_FIRST, PointType::X, and PointType::Y.
Referenced by ActionPolygon(), and ActionUndo().
int InitClip | ( | DataType * | d, |
LayerType * | l, | ||
PolygonType * | p | ||
) |
Definition at line 1238 of file polygon.c.
References clearPoly(), polygon_st::Clipped, inhibit, polygon_st::NoHoles, polygon_st::NoHolesValid, original_poly(), poly_Free(), poly_FreeContours(), poly_Valid(), and TEST_FLAG.
Referenced by ChangePolyClear(), ClearFromPolygon(), CopyAttachedPolygonToLayer(), CopyPolygon(), DestroyPolygonPoint(), InsertPointIntoPolygon(), MovePolygon(), MovePolygonPoint(), MovePolygonToLayer(), PolyToPolygonsOnLayer(), RemovePolygonContour(), RemovePolygonPoint(), RestoreToPolygon(), and UndoSwapCopiedObject().
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().
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().
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().
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().
Definition at line 595 of file polygon.c.
References CirclePoly(), ContourToPoly(), frac_circle(), PLINE::head, poly_CreateNode(), poly_InclVertex(), poly_NewContour(), VNODE::prev, and TEST_FLAG.
Referenced by IsLineInPolygon(), line_sub_callback(), square_therm(), SubtractLine(), and SubtractPad().
bool MorphPolygon | ( | LayerType * | , |
PolygonType * | |||
) |
Make a polygon split into multiple parts into multiple polygons.
Definition at line 1851 of file polygon.c.
References AddObjectToCreateUndoList(), PLINE::area, POLYAREA::b, polygon_st::Clipped, POLYAREA::contours, CreateNewPointInPolygon(), CreateNewPolygon(), DrawPolygon(), ErasePolygon(), POLYAREA::f, PLINE::head, IncrementUndoSerialNumber(), inhibit, PCBType::IsleArea, VNODE::next, polygon_st::NoHoles, PCB, VNODE::point, poly_DelContour(), LayerType::polygon_tree, r_insert_entry(), RemovePolygon(), TEST_FLAG, PLINE::xmax, PLINE::xmin, PLINE::ymax, and PLINE::ymin.
Referenced by ActionMorphPolygon().
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().
void NoHolesPolygonDicer | ( | PolygonType * | p, |
const BoxType * | clip, | ||
void(*)(PLINE *, void *) | emit, | ||
void * | user_data | ||
) |
Definition at line 1816 of file polygon.c.
References POLYAREA::b, polygon_st::Clipped, POLYAREA::f, PBO_ISECT, poly_Boolean_free(), poly_Copy1(), poly_Create(), r_NoHolesPolygonDicer(), RectPoly(), BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.
Referenced by common_fill_pcb_polygon(), and ComputeNoHoles().
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().
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().
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 | ||
) |
Definition at line 130 of file polygon.c.
References polygon_st::PointN, and polygon_st::Points.
Referenced by DestroyPolygonPoint(), RemovePolygonPoint(), UndoInsertPoint(), and XORDrawMoveOrCopyObject().
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().
Convert a POLYAREA (and all linked POLYAREA) to raw PCB polygons on the given layer.
Definition at line 1974 of file polygon.c.
References AddObjectToCreateUndoList(), POLYAREA::contours, CreateNewHoleInPolygon(), CreateNewPointInPolygon(), CreateNewPolygon(), DrawPolygon(), POLYAREA::f, PLINE::head, InitClip(), Input, PLINE::next, VNODE::next, node, VNODE::point, Polygon, LayerType::polygon_tree, r_create_tree(), r_insert_entry(), SetChangedFlag(), and SetPolygonBoundingBox().
Referenced by NotifyMode().
Cardinal prev_contour_point | ( | PolygonType * | polygon, |
Cardinal | point | ||
) |
Definition at line 179 of file polygon.c.
References polygon_st::HoleIndex, polygon_st::HoleIndexN, polygon_st::PointN, and polygon_point_contour().
Referenced by GetLowestDistancePolygonPoint(), InsertPointIntoPolygon(), NotifyMode(), RemoveExcessPolygonPoints(), and XORDrawMoveOrCopyObject().
Definition at line 344 of file polygon.c.
References ContourToPoly(), PLINE::head, poly_CreateNode(), poly_InclVertex(), poly_NewContour(), and VNODE::prev.
Referenced by BoxPolyBloated(), fill_clipped_contour(), IsRectangleInPolygon(), NoHolesPolygonDicer(), oct_therm(), r_NoHolesPolygonDicer(), and ThermPoly().
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.
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().
void RestoreToPolygon | ( | DataType * | , |
int | , | ||
void * | , | ||
void * | |||
) |
Definition at line 1684 of file polygon.c.
References add_plow(), PCBType::Data, InitClip(), PCB, PlowsPolygon(), and DataType::polyClip.
Referenced by ChangeArcAngles(), ChangeArcClearSize(), ChangeArcJoin(), ChangeArcSize(), ChangeElement2ndSize(), ChangeHole(), ChangeLineClearSize(), ChangeLineJoin(), ChangeLineSize(), ChangeObjectViaLayers(), ChangePadClearSize(), ChangePadSize(), ChangePadSquare(), ChangePin2ndSize(), ChangePinClearSize(), ChangePinOctagon(), ChangePinSize(), ChangePinSquare(), ChangePinThermal(), ChangeSelectedViaLayers(), ChangeTextJoin(), ChangeTextName(), ChangeTextSize(), ChangeVia2ndSize(), ChangeViaClearSize(), ChangeViaOctagon(), ChangeViaSize(), ChangeViaThermal(), FreeRotateElementLowLevel(), InsertPointIntoLine(), IronDownAllUnfixedPaths(), MirrorElementCoordinates(), MoveArc(), MoveArcToBuffer(), MoveArcToLayer(), MoveElementLowLevel(), MoveElementToBuffer(), MoveLine(), MoveLinePoint(), MoveLineToBuffer(), MoveLineToLayer(), MoveText(), MoveTextToBuffer(), MoveTextToLayerLowLevel(), MoveVia(), MoveViaToBuffer(), RotateArc(), RotateElementLowLevel(), RotateLinePoint(), RotateObject(), RotateText(), UndoChangeClearSize(), UndoChangeSize(), UndoClearPoly(), and UndoSetViaLayers().