KiCad PCB EDA Suite
|
a few functions useful in geometry calculations. More...
Go to the source code of this file.
Macros | |
#define | MIN_SEGCOUNT_FOR_CIRCLE 8 |
Functions | |
int | GetArcToSegmentCount (int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle) |
int | CircleToEndSegmentDeltaRadius (int aRadius, int aSegCount) |
int | GetCircleToPolyCorrection (int aMaxError) |
int | clipOutCode (const BOX2I *aClipBox, int x, int y) |
bool | ClipLine (const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2) |
Test if any part of a line falls within the bounds of a rectangle. | |
Variables | |
static bool | s_disable_arc_correction = false |
a few functions useful in geometry calculations.
Definition in file geometry_utils.cpp.
#define MIN_SEGCOUNT_FOR_CIRCLE 8 |
Definition at line 40 of file geometry_utils.cpp.
int CircleToEndSegmentDeltaRadius | ( | int | aInnerCircleRadius, |
int | aSegCount | ||
) |
aInnerCircleRadius | is the radius of the circle tangent to the middle of segments |
aSegCount | is the seg count to approximate the circle |
Definition at line 67 of file geometry_utils.cpp.
References std::abs(), delta, and KiROUND().
Referenced by ConvertArcToPolyline(), SHAPE_ARC::ConvertToPolyline(), CornerListToPolygon(), TransformCircleToPolygon(), and TransformOvalToPolygon().
bool ClipLine | ( | const BOX2I * | aClipBox, |
int & | x1, | ||
int & | y1, | ||
int & | x2, | ||
int & | y2 | ||
) |
Test if any part of a line falls within the bounds of a rectangle.
Please note that this is only accurate for lines that are one pixel wide.
aClipBox | - The rectangle to test. |
x1 | - X coordinate of one end of a line. |
y1 | - Y coordinate of one end of a line. |
x2 | - X coordinate of the other end of a line. |
y2 | - Y coordinate of the other end of a line. |
Definition at line 137 of file geometry_utils.cpp.
References clipOutCode(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), and BOX2< Vec >::GetY().
Referenced by KIGFX::DrawDashedLine(), STROKE_PARAMS::Stroke(), KIGFX::ORIGIN_VIEWITEM::ViewDraw(), and PCB_TRACK::ViewGetLOD().
|
inline |
Definition at line 117 of file geometry_utils.cpp.
References BOX2< Vec >::GetBottom(), and BOX2< Vec >::GetRight().
Referenced by ClipLine().
int GetArcToSegmentCount | ( | int | aRadius, |
int | aErrorMax, | ||
const EDA_ANGLE & | aArcAngle | ||
) |
aRadius | is the radius od the circle or arc |
aErrorMax | is the max error This is the max distance between the middle of a segment and the circle. |
aArcAngleDegree | is the arc angle |
Definition at line 42 of file geometry_utils.cpp.
References EDA_ANGLE::AsDegrees(), KiROUND(), and MIN_SEGCOUNT_FOR_CIRCLE.
Referenced by SHAPE_POLY_SET::chamferFilletPolygon(), ConvertArcToPolyline(), SHAPE_ARC::ConvertToPolyline(), CornerListToPolygon(), BOARD_ADAPTER::createTrackWithMargin(), KIGFX::OPENGL_GAL::DrawArcSegment(), EXPORTER_PCB_VRML::ExportVrmlPadHole(), EXPORTER_PCB_VRML::ExportVrmlViaHoles(), fillArcPOLY(), gen_arc(), BOARD_ADAPTER::GetCircleSegmentCount(), SHAPE_POLY_SET::Inflate(), PCB_IO_EAGLE::loadPlain(), PCB_IO_EAGLE::loadPolygon(), SHAPE_POLY_SET::OffsetLineChain(), PCB_IO_EAGLE::packageCircle(), PCB_IO_EAGLE::packagePolygon(), DIALOG_GLOBAL_EDIT_TEARDROPS::TransferDataFromWindow(), TransformCircleToPolygon(), and TransformOvalToPolygon().
int GetCircleToPolyCorrection | ( | int | aMaxError | ) |
aMaxError | is the same error value used to calculate the number of segments. |
When creating a polygon from a circle, the polygon is inside the circle. Only corners are on the circle. This is incorrect when building clearance areas of circles, that need to build the equivalent polygon outside the circle.
Definition at line 106 of file geometry_utils.cpp.
References s_disable_arc_correction.
Referenced by CornerListToPolygon(), TransformCircleToPolygon(), and TransformOvalToPolygon().
|
static |
Definition at line 94 of file geometry_utils.cpp.
Referenced by DISABLE_ARC_RADIUS_CORRECTION::DISABLE_ARC_RADIUS_CORRECTION(), GetCircleToPolyCorrection(), and DISABLE_ARC_RADIUS_CORRECTION::~DISABLE_ARC_RADIUS_CORRECTION().