KiCad PCB EDA Suite
|
Utility functions for working with shapes. More...
#include <array>
#include <optional>
#include <math/vector2d.h>
#include <math/box2.h>
#include <geometry/direction45.h>
Go to the source code of this file.
Namespaces | |
namespace | KIGEOM |
Functions | |
SEG | KIGEOM::NormalisedSeg (const SEG &aSeg) |
Returns a SEG such that the start point is smaller or equal in x and y compared to the end point. | |
const VECTOR2I & | KIGEOM::GetOtherEnd (const SEG &aSeg, const VECTOR2I &aPoint) |
Get the end point of the segment that is not the given point. | |
OPT_VECTOR2I | KIGEOM::GetSharedEndpoint (const SEG &aSegA, const SEG &aSegB) |
Get the shared endpoint of two segments, if it exists, or std::nullopt if the segments are not connected end-to-end. | |
std::array< SEG, 4 > | KIGEOM::BoxToSegs (const BOX2I &aBox) |
Decompose a BOX2 into four segments. | |
void | KIGEOM::CollectBoxCorners (const BOX2I &aBox, std::vector< VECTOR2I > &aCorners) |
Add the 4 corners of a BOX2I to a vector. | |
std::vector< SEG > | KIGEOM::GetSegsInDirection (const BOX2I &aBox, DIRECTION_45::Directions aDir) |
Get the segments of a box that are in the given direction. | |
std::optional< SEG > | KIGEOM::ClipHalfLineToBox (const HALF_LINE &aRay, const BOX2I &aBox) |
Get the segment of a half-line that is inside a box, if any. | |
std::optional< SEG > | KIGEOM::ClipLineToBox (const LINE &aLine, const BOX2I &aBox) |
Get the segment of a line that is inside a box, if any. | |
SHAPE_ARC | KIGEOM::MakeArcCw90 (const VECTOR2I &aCenter, int aRadius, DIRECTION_45::Directions aDir) |
Get a SHAPE_ARC representing a 90-degree arc in the clockwise direction with the midpoint in the given direction from the center. | |
SHAPE_ARC | KIGEOM::MakeArcCw180 (const VECTOR2I &aCenter, int aRadius, DIRECTION_45::Directions aDir) |
Get a SHAPE_ARC representing a 180-degree arc in the clockwise direction with the midpoint in the given direction from the center. | |
VECTOR2I | KIGEOM::GetPoint (const SHAPE_RECT &aRect, DIRECTION_45::Directions aDir, int aOutset=0) |
Get the point on a rectangle that corresponds to a given direction. | |
std::vector< TYPED_POINT2I > | KIGEOM::GetCircleKeyPoints (const CIRCLE &aCircle, bool aIncludeCenter) |
Get key points of an CIRCLE. | |
SHAPE_LINE_CHAIN | KIGEOM::RectifyPolygon (const SHAPE_LINE_CHAIN &aPoly) |
bool | KIGEOM::AddHoleIfValid (SHAPE_POLY_SET &aOutline, SHAPE_LINE_CHAIN &&aHole) |
Adds a hole to a polygon if it is valid (i.e. | |
std::vector< VECTOR2I > | KIGEOM::MakeRegularPolygonPoints (const VECTOR2I &aCenter, size_t aN, const VECTOR2I &aPt0) |
Get the corners of a regular polygon from the centre, one point and the number of sides. | |
std::vector< VECTOR2I > | KIGEOM::MakeRegularPolygonPoints (const VECTOR2I &aCenter, size_t aN, int aRadius, bool aAcrossCorners, EDA_ANGLE aAngle) |
Make a regular polygon of the given size across the corners. | |
std::vector< SEG > | KIGEOM::MakeCrossSegments (const VECTOR2I &aCenter, const VECTOR2I &aSize, EDA_ANGLE aAngle) |
Create the two segments for a cross. | |
Utility functions for working with shapes.
These are free functions to avoid bloating the shape classes with functions that only need to be used in a few places and can just use the public interfaces.
Definition in file shape_utils.h.