47    return ( aSeg.
A == aPoint ) ? aSeg.
B : aSeg.
A;
 
 
   53    if( aSegA.
A == aSegB.
A || aSegA.
A == aSegB.
B )
 
   57    else if( aSegA.
B == aSegB.
A || aSegA.
B == aSegB.
B )
 
 
   68    const std::array<VECTOR2I, 4> corners = {
 
   76        SEG{ corners[0], corners[1] },
 
   77        SEG{ corners[1], corners[2] },
 
   78        SEG{ corners[2], corners[3] },
 
   79        SEG{ corners[3], corners[0] },
 
 
  147    std::optional<VECTOR2I> ptA, ptB;
 
  149    for( 
const SEG& boxSeg : boxSegs )
 
  159        if( !ptA || *intersection == *ptA )
 
  173        return SEG( *ptA, *ptB );
 
  178    if( ptA && *ptA != aRay.
GetStart() )
 
 
  193    std::optional<VECTOR2I> ptA, ptB;
 
  195    for( 
const SEG& boxSeg : boxSegs )
 
  200        if( intersection && boxSeg.Contains( *intersection ) )
 
  203            if( !ptA || *intersection == *ptA )
 
  218        return SEG( *ptA, *ptB );
 
 
  253    default: wxFAIL_MSG( 
"Invalid direction" ); 
return SHAPE_ARC();
 
 
  287    default: wxFAIL_MSG( 
"Invalid direction" );
 
 
  309        return nw + 
VECTOR2I( -aOutset, -aOutset );
 
  317        wxFAIL_MSG( 
"Invalid direction" );
 
 
  326    std::vector<TYPED_POINT2I> pts;
 
  341        pt.m_point += aCircle.
Center;
 
 
  352    const auto handleSegment = [&]( 
const SEG& aSeg )
 
  354        const VECTOR2I p0( aSeg.A.x, aSeg.B.y );
 
  355        const VECTOR2I p1( aSeg.B.x, aSeg.A.y );
 
  357        raOutline.
Append( aSeg.A );
 
  366        handleSegment( aPoly.
CSegment( i ) );
 
 
  384    if( aHole.PointCount() < 3 || aHole.Area() == 0 )
 
  389    aOutline.
AddHole( std::move( aHole ) );
 
 
  398    std::vector<VECTOR2I> pts;
 
  400    for( 
size_t i = 0; i < aN; i++ )
 
  403        pts.push_back( 
KiROUND( pt + aCenter ) );
 
 
  411                                                        int aRadius, 
bool aAcrossCorners,
 
  414    if( !aAcrossCorners )
 
  417        aRadius = aRadius / ( 
FULL_CIRCLE / ( aN * 2 ) ).Cos();
 
 
  428    std::vector<SEG> segs;
 
  431    segs.emplace_back( pt0, aCenter - ( pt0 - aCenter ) );
 
  434    segs.emplace_back( pt0, aCenter - ( pt0 - aCenter ) );
 
 
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
 
constexpr coord_type GetLeft() const
 
constexpr coord_type GetRight() const
 
constexpr coord_type GetTop() const
 
constexpr coord_type GetBottom() const
 
Represent basic circle geometry with utility geometry functions.
 
VECTOR2I Center
Public to make access simpler.
 
int Radius
Public to make access simpler.
 
Directions
Available directions, there are 8 of them, as on a rectilinear map (north = up) + an extra undefined ...
 
OPT_VECTOR2I Intersect(const SEG &aSeg) const
 
const VECTOR2I & GetStart() const
Get the start point of the ray.
 
OPT_VECTOR2I Intersect(const SEG &aOther) const
 
SEG Reversed() const
Returns the center point of the line.
 
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const override
Check if point aP lies inside a closed shape.
 
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
 
bool IsClosed() const override
 
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
 
int PointCount() const
Return the number of points (vertices) in this line chain.
 
void Simplify(int aTolerance=0)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
 
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
 
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
 
int SegmentCount() const
Return the number of segments in this line chain.
 
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
 
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
 
Represent a set of closed polygons.
 
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Adds a new hole to the given outline (default: last) and returns its index.
 
int GetWidth() const override
 
const VECTOR2I & GetPosition() const
 
static constexpr EDA_ANGLE ANGLE_90
 
static constexpr EDA_ANGLE FULL_CIRCLE
 
static constexpr EDA_ANGLE ANGLE_180
 
bool AddHoleIfValid(SHAPE_POLY_SET &aOutline, SHAPE_LINE_CHAIN &&aHole)
Adds a hole to a polygon if it is valid (i.e.
 
VECTOR2I 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 > GetCircleKeyPoints(const CIRCLE &aCircle, bool aIncludeCenter)
Get key points of an CIRCLE.
 
std::vector< VECTOR2I > 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.
 
OPT_VECTOR2I 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 connec...
 
std::vector< SEG > GetSegsInDirection(const BOX2I &aBox, DIRECTION_45::Directions aDir)
Get the segments of a box that are in the given direction.
 
SEG 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.
 
std::vector< SEG > MakeCrossSegments(const VECTOR2I &aCenter, const VECTOR2I &aSize, EDA_ANGLE aAngle)
Create the two segments for a cross.
 
std::array< SEG, 4 > BoxToSegs(const BOX2I &aBox)
Decompose a BOX2 into four segments.
 
std::optional< SEG > 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 > ClipLineToBox(const LINE &aLine, const BOX2I &aBox)
Get the segment of a line that is inside a box, if any.
 
SHAPE_ARC 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 giv...
 
SHAPE_LINE_CHAIN RectifyPolygon(const SHAPE_LINE_CHAIN &aPoly)
 
SHAPE_ARC 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 give...
 
void CollectBoxCorners(const BOX2I &aBox, std::vector< VECTOR2I > &aCorners)
Add the 4 corners of a BOX2I to a vector.
 
const VECTOR2I & GetOtherEnd(const SEG &aSeg, const VECTOR2I &aPoint)
Get the end point of the segment that is not the given point.
 
@ PT_CENTER
The point is the center of something.
 
@ PT_QUADRANT
The point is on a quadrant of a circle (N, E, S, W points).
 
std::optional< VECTOR2I > OPT_VECTOR2I
 
Utility functions for working with shapes.
 
VECTOR2I GetRotated(const VECTOR2I &aVector, const EDA_ANGLE &aAngle)
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
 
VECTOR2< int32_t > VECTOR2I
 
VECTOR2< double > VECTOR2D
 
constexpr int LexicographicalCompare(const VECTOR2< T > &aA, const VECTOR2< T > &aB)