KiCad PCB EDA Suite
convert_basic_shapes_to_polygon.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
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.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef CONVERT_BASIC_SHAPES_TO_POLYGON_H
26 #define CONVERT_BASIC_SHAPES_TO_POLYGON_H
27 
30 #include <wx/gdicmn.h> // for wxPoint
31 
32 
33 // The chamfer positions of chamfered rect shape.
34 // the position is relative to a pad with orientation = 0
35 // we can have 1 to 4 chamfered corners (0 corner = roundrect)
36 // The position list is the OR of corner to chamfer
38 {
48 };
49 
50 
62 int ConvertArcToPolyline( SHAPE_LINE_CHAIN& aPolyline, VECTOR2I aCenter, int aRadius,
63  double aStartAngleDeg, double aArcAngleDeg, double aAccuracy,
64  ERROR_LOC aErrorLoc );
65 
66 
78 void TransformCircleToPolygon( SHAPE_LINE_CHAIN& aCornerBuffer, const wxPoint& aCenter, int aRadius,
79  int aError, ERROR_LOC aErrorLoc, int aMinSegCount = 0 );
80 
92 void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer, const wxPoint& aCenter, int aRadius,
93  int aError, ERROR_LOC aErrorLoc, int aMinSegCount = 0 );
94 
95 
113 void TransformOvalToPolygon( SHAPE_POLY_SET& aCornerBuffer, const wxPoint& aStart,
114  const wxPoint& aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc,
115  int aMinSegCount = 0 );
116 
131 void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer,
132  const wxPoint& aPosition, const wxSize& aSize,
133  double aRotation, int aDeltaX, int aDeltaY, int aInflate,
134  int aError, ERROR_LOC aErrorLoc );
135 
160  const wxPoint& aPosition, const wxSize& aSize,
161  double aRotation, int aCornerRadius,
162  double aChamferRatio, int aChamferCorners, int aInflate,
163  int aError, ERROR_LOC aErrorLoc );
164 
176 void TransformArcToPolygon( SHAPE_POLY_SET& aCornerBuffer, const wxPoint& aStart,
177  const wxPoint& aMid, const wxPoint& aEnd, int aWidth, int aError,
178  ERROR_LOC aErrorLoc );
179 
190 void TransformRingToPolygon( SHAPE_POLY_SET& aCornerBuffer, const wxPoint& aCentre, int aRadius,
191  int aWidth, int aError, ERROR_LOC aErrorLoc );
192 
193 #endif // CONVERT_BASIC_SHAPES_TO_POLYGON_H
Define a general 2D-vector/point.
Definition: vector2d.h:61
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aInflate, int aError, ERROR_LOC aErrorLoc)
Convert a rectangle with rounded corners and/or chamfered corners to a polygon.
Represent a set of closed polygons.
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, const wxPoint &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
void TransformTrapezoidToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aDeltaX, int aDeltaY, int aInflate, int aError, ERROR_LOC aErrorLoc)
Convert a rectangle or trapezoid to a polygon.
a few functions useful in geometry calculations.
int ConvertArcToPolyline(SHAPE_LINE_CHAIN &aPolyline, VECTOR2I aCenter, int aRadius, double aStartAngleDeg, double aArcAngleDeg, double aAccuracy, ERROR_LOC aErrorLoc)
Generate a polyline to approximate a arc.
Represent a polyline (an zero-thickness chain of connected line segments).
void TransformOvalToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
void TransformArcToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arc to multiple straight segments.
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aCentre, int aRadius, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arcs to multiple straight segments.