pcb 4.1.1
An interactive printed circuit board layout editor.
|
Special polygon editing routines. More...
#include <assert.h>
#include <math.h>
#include <memory.h>
#include <setjmp.h>
#include "global.h"
#include "box.h"
#include "create.h"
#include "crosshair.h"
#include "data.h"
#include "draw.h"
#include "error.h"
#include "find.h"
#include "misc.h"
#include "move.h"
#include "pcb-printf.h"
#include "polygon.h"
#include "remove.h"
#include "rtree.h"
#include "search.h"
#include "set.h"
#include "thermal.h"
#include "undo.h"
Go to the source code of this file.
Data Structures | |
struct | cpInfo |
struct | plow_info |
Defines | |
#define | ROUND(x) ((long)(((x) >= 0 ? (x) + 0.5 : (x) - 0.5))) |
#define | UNSUBTRACT_BLOAT 10 |
#define | SUBTRACT_PIN_VIA_BATCH_SIZE 100 |
#define | SUBTRACT_LINE_BATCH_SIZE 20 |
#define | ARC_ANGLE 5 |
#define | MIN_CLEARANCE_BEFORE_BISECT 10. |
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 | next_contour_point (PolygonType *polygon, Cardinal point) |
Cardinal | prev_contour_point (PolygonType *polygon, Cardinal point) |
static void | add_noholes_polyarea (PLINE *pline, void *user_data) |
void | ComputeNoHoles (PolygonType *poly) |
static POLYAREA * | biggest (POLYAREA *p) |
POLYAREA * | ContourToPoly (PLINE *contour) |
static POLYAREA * | original_poly (PolygonType *p) |
POLYAREA * | PolygonToPoly (PolygonType *p) |
POLYAREA * | RectPoly (Coord x1, Coord x2, Coord y1, Coord y2) |
POLYAREA * | OctagonPoly (Coord x, Coord y, Coord radius) |
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. | |
POLYAREA * | CirclePoly (Coord x, Coord y, Coord radius) |
Create a circle approximation from lines. | |
POLYAREA * | RoundRect (Coord x1, Coord x2, Coord y1, Coord y2, Coord t) |
Make a rounded-corner rectangle with radius t beyond x1,x2,y1,y2 rectangle. | |
static POLYAREA * | ArcPolyNoIntersect (ArcType *a, Coord thick) |
POLYAREA * | ArcPoly (ArcType *a, Coord thick) |
POLYAREA * | LinePoly (LineType *L, Coord thick) |
POLYAREA * | SquarePadPoly (PadType *pad, Coord clear) |
Make a rounded-corner rectangle. | |
static int | Subtract (POLYAREA *np1, PolygonType *p, bool fnp) |
Clear np1 from the polygon. | |
POLYAREA * | PinPoly (PinType *pin, Coord thick, Coord clear) |
Create a polygon of the pin clearance. | |
POLYAREA * | BoxPolyBloated (BoxType *box, Coord bloat) |
static int | SubtractPin (DataType *d, PinType *pin, LayerType *l, PolygonType *p) |
Remove the pin clearance from the polygon. | |
static int | SubtractLine (LineType *line, PolygonType *p) |
static int | SubtractArc (ArcType *arc, PolygonType *p) |
static int | SubtractText (TextType *text, PolygonType *p) |
static int | SubtractPad (PadType *pad, PolygonType *p) |
static void | subtract_accumulated (struct cpInfo *info, PolygonType *polygon) |
static int | pin_sub_callback (const BoxType *b, void *cl) |
static int | arc_sub_callback (const BoxType *b, void *cl) |
static int | pad_sub_callback (const BoxType *b, void *cl) |
static int | line_sub_callback (const BoxType *b, void *cl) |
static int | text_sub_callback (const BoxType *b, void *cl) |
static int | Group (DataType *Data, Cardinal layer) |
static int | clearPoly (DataType *Data, LayerType *Layer, PolygonType *polygon, const BoxType *here, Coord expand) |
static int | Unsubtract (POLYAREA *np1, PolygonType *p) |
static int | UnsubtractPin (PinType *pin, LayerType *l, PolygonType *p) |
static int | UnsubtractArc (ArcType *arc, LayerType *l, PolygonType *p) |
static int | UnsubtractLine (LineType *line, LayerType *l, PolygonType *p) |
static int | UnsubtractText (TextType *text, LayerType *l, PolygonType *p) |
static int | UnsubtractPad (PadType *pad, LayerType *l, PolygonType *p) |
int | InitClip (DataType *Data, LayerType *layer, PolygonType *p) |
bool | RemoveExcessPolygonPoints (LayerType *Layer, PolygonType *Polygon) |
Remove redundant polygon points. | |
Cardinal | GetLowestDistancePolygonPoint (PolygonType *Polygon, Coord X, Coord Y) |
| |
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 *polygon, const BoxType *range, int(*callback)(PLINE *contour, void *user_data), void *user_data) |
Find polygon holes in range, then call the callback function for each hole. | |
static int | subtract_plow (DataType *Data, LayerType *Layer, PolygonType *Polygon, int type, void *ptr1, void *ptr2, void *userdata) |
static int | add_plow (DataType *Data, LayerType *Layer, PolygonType *Polygon, int type, void *ptr1, void *ptr2, void *userdata) |
static int | plow_callback (const BoxType *b, void *cl) |
int | PlowsPolygon (DataType *Data, int type, void *ptr1, void *ptr2, int(*call_back)(DataType *data, LayerType *lay, PolygonType *poly, int type, void *ptr1, void *ptr2, void *userdata), void *userdata) |
void | RestoreToPolygon (DataType *Data, int type, void *ptr1, void *ptr2) |
void | ClearFromPolygon (DataType *Data, int type, void *ptr1, void *ptr2) |
bool | isects (POLYAREA *a, PolygonType *p, bool fr) |
bool | IsPointInPolygon (Coord X, Coord Y, Coord r, PolygonType *p) |
bool | IsPointInPolygonIgnoreHoles (Coord X, Coord Y, PolygonType *p) |
bool | IsRectangleInPolygon (Coord X1, Coord Y1, Coord X2, Coord Y2, PolygonType *p) |
static void | r_NoHolesPolygonDicer (POLYAREA *pa, void(*emit)(PLINE *, void *), void *user_data) |
| |
void | NoHolesPolygonDicer (PolygonType *p, const BoxType *clip, void(*emit)(PLINE *, void *), void *user_data) |
bool | MorphPolygon (LayerType *layer, PolygonType *poly) |
Make a polygon split into multiple parts into multiple polygons. | |
void | debug_pline (PLINE *pl) |
void | debug_polyarea (POLYAREA *p) |
void | debug_polygon (PolygonType *p) |
void | PolyToPolygonsOnLayer (DataType *Destination, LayerType *Layer, POLYAREA *Input, FlagType Flags) |
Convert a POLYAREA (and all linked POLYAREA) to raw PCB polygons on the given layer. | |
Variables | |
static double | rotate_circle_seg [4] |
static bool | inhibit = false |
Special polygon editing routines.
Here's a brief tour of the data and life of a polygon, courtesy of Ben Jackson:
A PCB PolygonType contains an array of points outlining the polygon. This is what is manipulated by the UI and stored in the saved PCB.
A PolygonType also contains a POLYAREA called 'Clipped' which is computed dynamically by InitClip every time a board is loaded. The point array is coverted to a POLYAREA by original_poly and then holes are cut in it by clearPoly. After that it is maintained dynamically as parts are added, moved or removed (this is why sometimes bugs can be fixed by just re-loading the board).
A POLYAREA consists of a linked list of PLINE structures. The head of that list is POLYAREA.contours. The first contour is an outline of a filled region. All of the subsequent PLINEs are holes cut out of that first contour. POLYAREAs are in a doubly-linked list and each member of the list is an independent (non-overlapping) area with its own outline and holes. The function biggest() finds the largest POLYAREA so that PolygonType.Clipped points to that shape. The rest of the polygon still exists, it's just ignored when turning the polygon into copper.
The first POLYAREA in PolygonType.Clipped is what is used for the vast majority of Polygon related tests. The basic logic for an intersection is "is the target shape inside POLYAREA.contours and NOT fully enclosed in any of POLYAREA.contours.next... (the holes)".
The polygon dicer (NoHolesPolygonDicer and r_NoHolesPolygonDicer) emits a series of "simple" PLINE shapes. That is, the PLINE isn't linked to any other "holes" oulines. That's the meaning of the first test in r_NoHolesPolygonDicer. It is testing to see if the PLINE contour (the first, making it a solid outline) has a valid next pointer (which would point to one or more holes). The dicer works by recursively chopping the polygon in half through the first hole it sees (which is guaranteed to eliminate at least that one hole). The dicer output is used for HIDs which cannot render things with holes (which would require erasure).
PCB, interactive printed circuit board design
Copyright (C) 1994,1995,1996,2010 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.c.
#define ARC_ANGLE 5 |
Definition at line 489 of file polygon.c.
Referenced by ArcPolyNoIntersect().
#define MIN_CLEARANCE_BEFORE_BISECT 10. |
#define SUBTRACT_LINE_BATCH_SIZE 20 |
Definition at line 115 of file polygon.c.
Referenced by line_sub_callback().
#define SUBTRACT_PIN_VIA_BATCH_SIZE 100 |
Definition at line 114 of file polygon.c.
Referenced by pin_sub_callback().
#define UNSUBTRACT_BLOAT 10 |
Definition at line 113 of file polygon.c.
Referenced by UnsubtractArc(), UnsubtractLine(), UnsubtractPad(), UnsubtractPin(), and UnsubtractText().
static void add_noholes_polyarea | ( | PLINE * | pline, |
void * | user_data | ||
) | [static] |
Definition at line 203 of file polygon.c.
References PLINE::next, polygon_st::NoHoles, and poly.
Referenced by ComputeNoHoles().
static int add_plow | ( | DataType * | Data, |
LayerType * | Layer, | ||
PolygonType * | Polygon, | ||
int | type, | ||
void * | ptr1, | ||
void * | ptr2, | ||
void * | userdata | ||
) | [static] |
Definition at line 1543 of file polygon.c.
References GetLayerNumber(), UnsubtractArc(), UnsubtractLine(), UnsubtractPad(), UnsubtractPin(), UnsubtractText(), VIA_IS_BURIED, and VIA_ON_LAYER.
Referenced by RestoreToPolygon().
static int arc_sub_callback | ( | const BoxType * | b, |
void * | cl | ||
) | [static] |
Definition at line 961 of file polygon.c.
References cpInfo::env, cpInfo::other, cpInfo::polygon, SubtractArc(), and TEST_FLAG.
Referenced by clearPoly().
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 491 of file polygon.c.
References ARC_ANGLE, ContourToPoly(), ArcType::Delta, frac_circle(), GetArcEnds(), PLINE::head, ArcType::Height, M180, M_PI, MAX, POLY_ARC_MAX_DEVIATION, poly_CreateNode(), poly_InclVertex(), poly_NewContour(), VNODE::prev, ArcType::StartAngle, ArcType::Width, ArcType::X, BoxType::X1, BoxType::X2, ArcType::Y, BoxType::Y1, and BoxType::Y2.
Referenced by ArcPoly().
Definition at line 224 of file polygon.c.
References PLINE::area, POLYAREA::b, POLYAREA::contour_tree, POLYAREA::contours, POLYAREA::f, PCBType::IsleArea, n, PCB, and poly_DelContour().
Referenced by original_poly(), Subtract(), and Unsubtract().
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 * | Data, |
int | type, | ||
void * | ptr1, | ||
void * | ptr2 | ||
) |
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().
static int clearPoly | ( | DataType * | Data, |
LayerType * | Layer, | ||
PolygonType * | polygon, | ||
const BoxType * | here, | ||
Coord | expand | ||
) | [static] |
Definition at line 1059 of file polygon.c.
References cpInfo::accumulate, arc_sub_callback(), cpInfo::batch_size, bloat_box(), cpInfo::bottom, bottom_silk_layer, clip_box(), cpInfo::data, END_LOOP, cpInfo::env, GetLayerNumber(), Group(), GROUP_LOOP, layer, Layer, cpInfo::layer, line_sub_callback(), max_copper_layer, polygon_st::NoHolesValid, cpInfo::other, pad_sub_callback(), DataType::pad_tree, pin_sub_callback(), DataType::pin_tree, cpInfo::polygon, r_search(), region, subtract_accumulated(), TEST_FLAG, text_sub_callback(), top_silk_layer, and DataType::via_tree.
Referenced by InitClip(), UnsubtractArc(), UnsubtractLine(), UnsubtractPad(), UnsubtractPin(), and UnsubtractText().
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().
void debug_pline | ( | PLINE * | pl | ) |
Definition at line 1918 of file polygon.c.
References PLINE::head, VNODE::next, pcb_fprintf(), VNODE::point, PLINE::xmax, PLINE::xmin, PLINE::ymax, and PLINE::ymin.
Referenced by debug_polyarea().
void debug_polyarea | ( | POLYAREA * | p | ) |
Definition at line 1934 of file polygon.c.
References POLYAREA::contours, debug_pline(), and PLINE::next.
Referenced by debug_polygon().
void debug_polygon | ( | PolygonType * | p | ) |
Definition at line 1944 of file polygon.c.
References polygon_st::Clipped, debug_polyarea(), POLYAREA::f, polygon_st::HoleIndex, polygon_st::HoleIndexN, pcb_fprintf(), polygon_st::PointN, polygon_st::Points, PointType::X, and PointType::Y.
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().
Definition at line 1048 of file polygon.c.
References max_group, and DataType::pcb.
Referenced by clearPoly().
int InitClip | ( | DataType * | Data, |
LayerType * | layer, | ||
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 * | a, |
PolygonType * | p, | ||
bool | fr | ||
) |
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 | X, |
Coord | Y, | ||
Coord | r, | ||
PolygonType * | p | ||
) |
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 | X, |
Coord | Y, | ||
PolygonType * | p | ||
) |
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 | X1, |
Coord | Y1, | ||
Coord | X2, | ||
Coord | Y2, | ||
PolygonType * | p | ||
) |
Definition at line 1748 of file polygon.c.
References isects(), max, min, RectPoly(), and s.
Referenced by IsLineInPolygon(), LOCtoPVpoly_callback(), and pv_poly_callback().
static int line_sub_callback | ( | const BoxType * | b, |
void * | cl | ||
) | [static] |
Definition at line 1001 of file polygon.c.
References cpInfo::accumulate, cpInfo::batch_size, cpInfo::env, line, LinePoly(), cpInfo::other, PBO_UNITE, poly_Boolean_free(), cpInfo::polygon, subtract_accumulated(), SUBTRACT_LINE_BATCH_SIZE, and TEST_FLAG.
Referenced by clearPoly().
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 * | layer, |
PolygonType * | poly | ||
) |
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().
static POLYAREA* original_poly | ( | PolygonType * | p | ) | [static] |
Definition at line 287 of file polygon.c.
References biggest(), PLINE::Flags, PLINE::head, polygon_st::HoleIndex, n, PLINE::orient, PLF_DIR, PLF_INV, polygon_st::PointN, polygon_st::Points, poly_Create(), poly_CreateNode(), poly_InclContour(), poly_InclVertex(), poly_InvContour(), poly_NewContour(), poly_PreContour(), poly_Valid(), VNODE::prev, TRUE, PointType::X, and PointType::Y.
Referenced by InitClip(), PolygonToPoly(), and Unsubtract().
static int pad_sub_callback | ( | const BoxType * | b, |
void * | cl | ||
) | [static] |
Definition at line 979 of file polygon.c.
References cpInfo::bottom, cpInfo::env, cpInfo::other, cpInfo::polygon, SubtractPad(), TEST_FLAG, and XOR.
Referenced by clearPoly().
static int pin_sub_callback | ( | const BoxType * | b, |
void * | cl | ||
) | [static] |
Definition at line 915 of file polygon.c.
References cpInfo::accumulate, cpInfo::batch_size, pin_st::Clearance, cpInfo::data, cpInfo::env, GetLayerNumber(), cpInfo::layer, cpInfo::other, PBO_UNITE, DataType::pcb, pin, PIN_SIZE, PinPoly(), poly_Boolean_free(), cpInfo::polygon, subtract_accumulated(), SUBTRACT_PIN_VIA_BATCH_SIZE, TEST_THERM, ThermPoly(), VIA_IS_BURIED, and VIA_ON_LAYER.
Referenced by clearPoly().
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().
static int plow_callback | ( | const BoxType * | b, |
void * | cl | ||
) | [static] |
Definition at line 1579 of file polygon.c.
References plow_info::callback, plow_info::data, plow_info::layer, plow_info::ptr1, plow_info::ptr2, TEST_FLAG, plow_info::type, and plow_info::userdata.
Referenced by PlowsPolygon().
int PlowsPolygon | ( | DataType * | Data, |
int | type, | ||
void * | ptr1, | ||
void * | ptr2, | ||
int(*)(DataType *data, LayerType *lay, PolygonType *poly, int type, void *ptr1, void *ptr2, void *userdata) | call_back, | ||
void * | userdata | ||
) |
Definition at line 1591 of file polygon.c.
References bottom_silk_layer, plow_info::callback, plow_info::data, END_LOOP, GetLayerGroupNumberByNumber(), GetLayerNumber(), GROUP_LOOP, layer, plow_info::layer, LAYER_LOOP, max_copper_layer, PAD_LOOP, pin, PIN_LOOP, plow_callback(), ptr1, plow_info::ptr1, ptr2, plow_info::ptr2, r_search(), TEST_FLAG, top_silk_layer, plow_info::type, and plow_info::userdata.
Referenced by ClearFromPolygon(), DRCAll(), and RestoreToPolygon().
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 * | polygon, |
const BoxType * | range, | ||
int(*)(PLINE *contour, void *user_data) | callback, | ||
void * | user_data | ||
) |
Find polygon holes in range, then call the callback function for each hole.
If the callback returns non-zero, stop the search.
Definition at line 1462 of file polygon.c.
References callback(), polygon_st::Clipped, POLYAREA::contours, PLINE::next, BoxType::X1, BoxType::X2, PLINE::xmax, PLINE::xmin, BoxType::Y1, BoxType::Y2, PLINE::ymax, and PLINE::ymin.
Referenced by common_thindraw_pcb_polygon().
POLYAREA* PolygonToPoly | ( | PolygonType * | p | ) |
Definition at line 338 of file polygon.c.
References original_poly().
Referenced by NotifyMode().
void PolyToPolygonsOnLayer | ( | DataType * | Destination, |
LayerType * | Layer, | ||
POLYAREA * | Input, | ||
FlagType | Flags | ||
) |
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().
static void r_NoHolesPolygonDicer | ( | POLYAREA * | pa, |
void(*)(PLINE *, void *) | emit, | ||
void * | user_data | ||
) | [static] |
Definition at line 1764 of file polygon.c.
References POLYAREA::b, POLYAREA::contours, POLYAREA::f, PLINE::next, poly_AndSubtract_free(), poly_Free(), RectPoly(), PLINE::xmax, PLINE::xmin, PLINE::ymax, and PLINE::ymin.
Referenced by NoHolesPolygonDicer().
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 * | Data, |
int | type, | ||
void * | ptr1, | ||
void * | ptr2 | ||
) |
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().
Make a rounded-corner rectangle with radius t beyond x1,x2,y1,y2 rectangle.
Definition at line 462 of file polygon.c.
References ContourToPoly(), frac_circle(), PLINE::head, poly_CreateNode(), poly_InclVertex(), poly_NewContour(), and VNODE::prev.
Referenced by PinPoly(), and SubtractText().
Make a rounded-corner rectangle.
Definition at line 657 of file polygon.c.
References c, ContourToPoly(), cx, cy, frac_circle(), PLINE::head, poly_CreateNode(), poly_InclVertex(), poly_NewContour(), and VNODE::prev.
Referenced by SubtractPad().
static int Subtract | ( | POLYAREA * | np1, |
PolygonType * | p, | ||
bool | fnp | ||
) | [static] |
Clear np1 from the polygon.
Definition at line 733 of file polygon.c.
References biggest(), polygon_st::Clipped, err_ok, Message(), polygon_st::NoHoles, PBO_SUB, poly_Boolean(), poly_Boolean_free(), poly_Free(), poly_Valid(), and x.
Referenced by subtract_accumulated(), SubtractArc(), SubtractLine(), SubtractPad(), SubtractPin(), and SubtractText().
static void subtract_accumulated | ( | struct cpInfo * | info, |
PolygonType * | polygon | ||
) | [static] |
Definition at line 905 of file polygon.c.
References cpInfo::accumulate, cpInfo::batch_size, and Subtract().
Referenced by clearPoly(), line_sub_callback(), and pin_sub_callback().
static int subtract_plow | ( | DataType * | Data, |
LayerType * | Layer, | ||
PolygonType * | Polygon, | ||
int | type, | ||
void * | ptr1, | ||
void * | ptr2, | ||
void * | userdata | ||
) | [static] |
Definition at line 1499 of file polygon.c.
References polygon_st::Clipped, GetLayerNumber(), polygon_st::NoHolesValid, SubtractArc(), SubtractLine(), SubtractPad(), SubtractPin(), SubtractText(), VIA_IS_BURIED, and VIA_ON_LAYER.
Referenced by ClearFromPolygon().
static int SubtractArc | ( | ArcType * | arc, |
PolygonType * | p | ||
) | [static] |
Definition at line 845 of file polygon.c.
References ArcPoly(), ArcType::Clearance, Subtract(), TEST_FLAG, and ArcType::Thickness.
Referenced by arc_sub_callback(), and subtract_plow().
static int SubtractLine | ( | LineType * | line, |
PolygonType * | p | ||
) | [static] |
Definition at line 833 of file polygon.c.
References LinePoly(), Subtract(), and TEST_FLAG.
Referenced by subtract_plow().
static int SubtractPad | ( | PadType * | pad, |
PolygonType * | p | ||
) | [static] |
Definition at line 871 of file polygon.c.
References LinePoly(), SquarePadPoly(), Subtract(), and TEST_FLAG.
Referenced by pad_sub_callback(), and subtract_plow().
static int SubtractPin | ( | DataType * | d, |
PinType * | pin, | ||
LayerType * | l, | ||
PolygonType * | p | ||
) | [static] |
Remove the pin clearance from the polygon.
Definition at line 809 of file polygon.c.
References pin_st::Clearance, GetLayerNumber(), DataType::pcb, PIN_SIZE, PinPoly(), Subtract(), TEST_THERM, ThermPoly(), and TRUE.
Referenced by subtract_plow().
static int SubtractText | ( | TextType * | text, |
PolygonType * | p | ||
) | [static] |
Definition at line 857 of file polygon.c.
References PCBType::Bloat, PCB, RoundRect(), Subtract(), TEST_FLAG, BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.
Referenced by subtract_plow(), and text_sub_callback().
static int text_sub_callback | ( | const BoxType * | b, |
void * | cl | ||
) | [static] |
Definition at line 1030 of file polygon.c.
References cpInfo::env, cpInfo::other, cpInfo::polygon, SubtractText(), and TEST_FLAG.
Referenced by clearPoly().
static int Unsubtract | ( | POLYAREA * | np1, |
PolygonType * | p | ||
) | [static] |
Definition at line 1110 of file polygon.c.
References biggest(), polygon_st::Clipped, err_ok, polygon_st::NoHoles, original_poly(), PBO_ISECT, PBO_UNITE, poly_Boolean_free(), poly_Free(), poly_Valid(), and x.
Referenced by UnsubtractArc(), UnsubtractLine(), UnsubtractPad(), UnsubtractPin(), and UnsubtractText().
static int UnsubtractArc | ( | ArcType * | arc, |
LayerType * | l, | ||
PolygonType * | p | ||
) | [static] |
Definition at line 1163 of file polygon.c.
References BoxPolyBloated(), clearPoly(), PCBType::Data, PCB, TEST_FLAG, Unsubtract(), and UNSUBTRACT_BLOAT.
Referenced by add_plow().
static int UnsubtractLine | ( | LineType * | line, |
LayerType * | l, | ||
PolygonType * | p | ||
) | [static] |
Definition at line 1182 of file polygon.c.
References BoxPolyBloated(), clearPoly(), PCBType::Data, PCB, TEST_FLAG, Unsubtract(), and UNSUBTRACT_BLOAT.
Referenced by add_plow().
static int UnsubtractPad | ( | PadType * | pad, |
LayerType * | l, | ||
PolygonType * | p | ||
) | [static] |
Definition at line 1220 of file polygon.c.
References BoxPolyBloated(), clearPoly(), PCBType::Data, PCB, Unsubtract(), and UNSUBTRACT_BLOAT.
Referenced by add_plow().
static int UnsubtractPin | ( | PinType * | pin, |
LayerType * | l, | ||
PolygonType * | p | ||
) | [static] |
Definition at line 1147 of file polygon.c.
References BoxPolyBloated(), clearPoly(), PCBType::Data, PCB, Unsubtract(), and UNSUBTRACT_BLOAT.
Referenced by add_plow().
static int UnsubtractText | ( | TextType * | text, |
LayerType * | l, | ||
PolygonType * | p | ||
) | [static] |
Definition at line 1201 of file polygon.c.
References BoxPolyBloated(), clearPoly(), PCBType::Data, PCB, TEST_FLAG, Unsubtract(), and UNSUBTRACT_BLOAT.
Referenced by add_plow().
bool inhibit = false [static] |
Definition at line 1235 of file polygon.c.
Referenced by InitClip(), and MorphPolygon().
double rotate_circle_seg[4] [static] |
Definition at line 117 of file polygon.c.
Referenced by frac_circle(), and polygon_init().