![]() |
KiCad PCB EDA Suite
|
#include <algorithm>
#include <math.h>
#include <type_traits>
#include <convert_basic_shapes_to_polygon.h>
#include <geometry/geometry_utils.h>
#include <geometry/shape_line_chain.h>
#include <geometry/shape_poly_set.h>
#include <math/util.h>
#include <math/vector2d.h>
#include <trigo.h>
Go to the source code of this file.
Functions | |
void | TransformCircleToPolygon (SHAPE_LINE_CHAIN &aCornerBuffer, wxPoint aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc) |
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines. More... | |
void | TransformCircleToPolygon (SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc) |
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines. More... | |
void | TransformOvalToPolygon (SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc) |
convert a oblong shape to a polygon, using multiple segments It is similar to TransformRoundedEndsSegmentToPolygon, but the polygon is outside the actual oblong shape (a segment with rounded ends) It is suitable to create oblong clearance areas. More... | |
void | TransformRoundRectToPolygon (SHAPE_POLY_SET &aCornerBuffer, const wxSize &aSize, int aCornerRadius, int aError, ERROR_LOC aErrorLoc) |
void | TransformRoundChamferedRectToPolygon (SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aError, ERROR_LOC aErrorLoc) |
convert a rectangle with rounded corners and/or chamfered corners to a polygon Convert rounded corners arcs to multiple straight lines. More... | |
void | TransformArcToPolygon (SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aMid, wxPoint aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc) |
Function TransformArcToPolygon Creates a polygon from an Arc Convert arcs to multiple straight segments. More... | |
void | TransformRingToPolygon (SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, int aRadius, int aWidth, int aError, ERROR_LOC aErrorLoc) |
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segments. More... | |
void TransformArcToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
wxPoint | aStart, | ||
wxPoint | aMid, | ||
wxPoint | aEnd, | ||
int | aWidth, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
Function TransformArcToPolygon Creates a polygon from an Arc Convert arcs to multiple straight segments.
aCornerBuffer | = a buffer to store the polygon |
aCentre | = centre of the arc or circle |
aStart | = start point of the arc, or a point on the circle |
aArcAngle | = arc angle in 0.1 degrees. For a circle, aArcAngle = 3600 |
aWidth | = width (thickness) of the line |
aError | = the IU allowed for error in approximation |
aErrorLoc | = should the approximation error be placed outside or inside the polygon? |
Definition at line 352 of file convert_basic_shapes_to_polygon.cpp.
References SEG::A, SEG::B, SHAPE_ARC::ConvertToPolyline(), ERROR_OUTSIDE, SHAPE_LINE_CHAIN::GetSegment(), SHAPE_LINE_CHAIN::GetSegmentCount(), and TransformOvalToPolygon().
Referenced by CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers(), TRACK::TransformShapeWithClearanceToPolygon(), and PCB_SHAPE::TransformShapeWithClearanceToPolygon().
void TransformCircleToPolygon | ( | SHAPE_LINE_CHAIN & | aCornerBuffer, |
wxPoint | aCenter, | ||
int | aRadius, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
aCornerBuffer | = a buffer to store the polygon |
aCenter | = the center of the circle |
aRadius | = the radius of the circle |
aError | = the IU allowed for error in approximation |
aErrorLoc | = should the approximation error be placed outside or inside the polygon? |
Definition at line 41 of file convert_basic_shapes_to_polygon.cpp.
References PNS::angle(), SHAPE_LINE_CHAIN::Append(), ERROR_OUTSIDE, GetArcToSegmentCount(), GetCircleToPolyCorrection(), RotatePoint(), and SHAPE_LINE_CHAIN::SetClosed().
Referenced by ZONE_FILLER::addHatchFillTypeOnZone(), addHoleToPolygon(), ZONE_FILLER::buildCopperItemClearances(), ConvertOutlineToPolygon(), D_CODE::ConvertShapeToPolygon(), BOARD_ADAPTER::createLayers(), AM_PRIMITIVE::DrawBasicShape(), CONVERT_TOOL::makePolysFromCircles(), PAD::MergePrimitivesAsPolygon(), TransformRingToPolygon(), TRACK::TransformShapeWithClearanceToPolygon(), DIMENSION_BASE::TransformShapeWithClearanceToPolygon(), PCB_SHAPE::TransformShapeWithClearanceToPolygon(), and PAD::TransformShapeWithClearanceToPolygon().
void TransformCircleToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
wxPoint | aCenter, | ||
int | aRadius, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
aCornerBuffer | = a buffer to store the polygon |
aCenter | = the center of the circle |
aRadius | = the radius of the circle |
aError | = the IU allowed for error in approximation |
aErrorLoc | = should the approximation error be placed outside or inside the polygon? |
Definition at line 65 of file convert_basic_shapes_to_polygon.cpp.
References PNS::angle(), SHAPE_POLY_SET::Append(), ERROR_OUTSIDE, GetArcToSegmentCount(), GetCircleToPolyCorrection(), SHAPE_POLY_SET::NewOutline(), and RotatePoint().
void TransformOvalToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
wxPoint | aStart, | ||
wxPoint | aEnd, | ||
int | aWidth, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
convert a oblong shape to a polygon, using multiple segments It is similar to TransformRoundedEndsSegmentToPolygon, but the polygon is outside the actual oblong shape (a segment with rounded ends) It is suitable to create oblong clearance areas.
because multiple segments create a smaller area than the circle, the radius of the circle to approximate must be bigger ( radius*aCorrectionFactor) to create segments outside the circle.
aCornerBuffer | = a buffer to store the polygon |
aStart | = the first point of the segment |
aEnd | = the second point of the segment |
aWidth | = the width of the segment |
aError | = the IU allowed for error in approximation |
aErrorLoc | = should the approximation error be placed outside or inside the polygon? |
Definition at line 95 of file convert_basic_shapes_to_polygon.cpp.
References PNS::angle(), SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::BooleanIntersection(), ERROR_OUTSIDE, EuclideanNorm(), GetArcToSegmentCount(), GetCircleToPolyCorrection(), KiROUND(), SHAPE_POLY_SET::Move(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, SHAPE_POLY_SET::Rotate(), and RotatePoint().
Referenced by addTextSegmToPoly(), BOARD_ADAPTER::buildPadOutlineAsPolygon(), CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers(), DIALOG_PAD_PROPERTIES::padValuesOK(), DXF_PLOTTER::PlotPoly(), DXF_PLOTTER::ThickSegment(), TransformArcToPolygon(), PAD::TransformHoleWithClearanceToPolygon(), TRACK::TransformShapeWithClearanceToPolygon(), DIMENSION_BASE::TransformShapeWithClearanceToPolygon(), PCB_SHAPE::TransformShapeWithClearanceToPolygon(), and PAD::TransformShapeWithClearanceToPolygon().
void TransformRingToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
wxPoint | aCentre, | ||
int | aRadius, | ||
int | aWidth, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segments.
aCornerBuffer | = a buffer to store the polygon |
aCentre | = centre of the arc or circle |
aRadius | = radius of the circle |
aWidth | = width (thickness) of the ring |
aError | = the IU allowed for error in approximation |
aErrorLoc | = should the approximation error be placed outside or inside the polygon? |
Definition at line 375 of file convert_basic_shapes_to_polygon.cpp.
References SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::Fracture(), SHAPE_POLY_SET::Hole(), SHAPE_POLY_SET::NewHole(), SHAPE_POLY_SET::PM_FAST, and TransformCircleToPolygon().
Referenced by BOARD_ADAPTER::buildPadOutlineAsPolygon(), AM_PRIMITIVE::DrawBasicShape(), and PCB_SHAPE::TransformShapeWithClearanceToPolygon().
void TransformRoundChamferedRectToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
const wxPoint & | aPosition, | ||
const wxSize & | aSize, | ||
double | aRotation, | ||
int | aCornerRadius, | ||
double | aChamferRatio, | ||
int | aChamferCorners, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
convert a rectangle with rounded corners and/or chamfered corners to a polygon Convert rounded corners arcs to multiple straight lines.
This will generate at least 16 segments per circle
aCornerBuffer | = a buffer to store the polygon |
aPosition | = the coordinate of the center of the rectangle |
aSize | = the size of the rectangle |
aCornerRadius | = radius of rounded corners (can be 0) |
aRotation | = rotation in 0.1 degrees of the rectangle |
aChamferRatio | = ratio between smaller rect size and chamfer value |
aChamferCorners | = identifier of the corners to chamfer: 0 = no chamfer 1 = TOP_LEFT 2 = TOP_RIGHT 4 = BOTTOM_LEFT 8 = BOTTOM_RIGHT One can have more than one chamfered corner by ORing the corner identifers |
aError | = the IU allowed for error in approximation |
aErrorLoc | = should the approximation error be placed outside or inside the polygon? |
Definition at line 281 of file convert_basic_shapes_to_polygon.cpp.
References SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::BooleanAdd(), SHAPE_POLY_SET::BooleanSubtract(), DECIDEG2RAD(), SHAPE_POLY_SET::Move(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, RECT_CHAMFER_BOTTOM_LEFT, RECT_CHAMFER_BOTTOM_RIGHT, RECT_CHAMFER_TOP_LEFT, RECT_CHAMFER_TOP_RIGHT, SHAPE_POLY_SET::RemoveAllContours(), SHAPE_POLY_SET::Rotate(), and TransformRoundRectToPolygon().
Referenced by PAD::BuildEffectiveShapes(), GERBER_PLOTTER::FlashPadChamferRoundRect(), PSLIKE_PLOTTER::FlashPadRoundRect(), DXF_PLOTTER::FlashPadRoundRect(), HPGL_PLOTTER::FlashPadRoundRect(), GERBER_PLOTTER::FlashPadRoundRect(), DSN::SPECCTRA_DB::makePADSTACK(), and PAD::TransformShapeWithClearanceToPolygon().
void TransformRoundRectToPolygon | ( | SHAPE_POLY_SET & | aCornerBuffer, |
const wxSize & | aSize, | ||
int | aCornerRadius, | ||
int | aError, | ||
ERROR_LOC | aErrorLoc | ||
) |
Definition at line 192 of file convert_basic_shapes_to_polygon.cpp.
References PNS::angle(), SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::BooleanIntersection(), ERROR_OUTSIDE, GetArcToSegmentCount(), GetCircleToPolyCorrection(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::PM_FAST, RotatePoint(), and SHAPE_LINE_CHAIN::SetClosed().
Referenced by TransformRoundChamferedRectToPolygon().