61    const int dist = 
delta.EuclideanNorm();
 
 
   97    aPtB.
x = std::max( p0.
x, std::min( c.
x, p0.
x + size.
x ) );
 
   98    aPtB.
y = std::max( p0.
y, std::min( c.
y, p0.
y + size.
y ) );
 
  104        int distToLeft = c.
x - p0.
x;
 
  105        int distToRight = p0.
x + size.
x - c.
x;
 
  106        int distToTop = c.
y - p0.
y;
 
  107        int distToBottom = p0.
y + size.
y - c.
y;
 
  109        int minDist = std::min( { distToLeft, distToRight, distToTop, distToBottom } );
 
  111        if( minDist == distToLeft )
 
  116        else if( minDist == distToRight )
 
  121        else if( minDist == distToTop )
 
 
  179    int64_t minDistSq = std::numeric_limits<int64_t>::max();
 
  189            int64_t distSq = ( ptB - ptA ).SquaredEuclideanNorm();
 
  190            if( distSq < minDistSq )
 
  202        for( 
size_t j = 0; j < 
chain->ArcCount(); j++ )
 
  212                if( distSq < minDistSq )
 
  222    return minDistSq < std::numeric_limits<int64_t>::max();
 
 
  284    int64_t minDistSq = std::numeric_limits<int64_t>::max();
 
  295            int64_t distSq = ( ptB - ptA ).SquaredEuclideanNorm();
 
  296            if( distSq < minDistSq )
 
  308        for( 
size_t j = 0; j < 
chain->ArcCount(); j++ )
 
  318                if( distSq < minDistSq )
 
  328    return minDistSq < std::numeric_limits<int64_t>::max();
 
 
  340    int64_t minDistSq = std::numeric_limits<int64_t>::max();
 
  356                int64_t distSq = ( ptB - ptA ).SquaredEuclideanNorm();
 
  357                if( distSq < minDistSq )
 
  370        for( 
size_t i = 0; i < chainA->
ArcCount(); i++ )
 
  377                for( 
size_t j = 0; j < chainB->
ArcCount(); j++ )
 
  383                        if( distSq < minDistSq )
 
  400                    if( distSq < minDistSq )
 
  411    if( chainB && !chainA )
 
  414        for( 
size_t j = 0; j < chainB->
ArcCount(); j++ )
 
  424                    if( distSq < minDistSq )
 
  435    return minDistSq < std::numeric_limits<int64_t>::max();
 
 
  477    int64_t minDistSq = std::numeric_limits<int64_t>::max();
 
  487            if( distSq < minDistSq )
 
  499        for( 
size_t j = 0; j < 
chain->ArcCount(); j++ )
 
  505                if( distSq < minDistSq )
 
 
  557        dir = ( aPtA - aPtB ).Resize( aSegB.
GetWidth() / 2 );
 
 
  583template<
class T_a, 
class T_b>
 
  586    return NearestPoints( *
static_cast<const T_a*
>( aA ), *
static_cast<const T_b*
>( aB ),
 
 
  590template<
class T_a, 
class T_b>
 
  593    return NearestPoints( *
static_cast<const T_b*
>( aB ), *
static_cast<const T_a*
>( aA ),
 
 
  666                int64_t minDistSq = std::numeric_limits<int64_t>::max();
 
  669                for( 
int i = 0; i < 
chain->SegmentCount(); i++ )
 
  677                        if( distSq < minDistSq )
 
  687                for( 
size_t i = 0; i < 
chain->ArcCount(); i++ )
 
  691                    if( 
chain->Arc( i ).NearestPoints( *arc, ptA, ptB, distSq ) )
 
  693                        if( distSq < minDistSq )
 
  702                return minDistSq < std::numeric_limits<int64_t>::max();
 
  750                int64_t minDistSq = std::numeric_limits<int64_t>::max();
 
  752                for( 
size_t i = 0; i < 
chain->GetSegmentCount(); i++ )
 
  760                        if( distSq < minDistSq )
 
  769                return minDistSq < std::numeric_limits<int64_t>::max();
 
  801            int64_t minDistSq = std::numeric_limits<int64_t>::max();
 
  810                    int64_t distSq = ( ptB - ptA ).SquaredEuclideanNorm();
 
  811                    if( distSq < minDistSq )
 
  820            return minDistSq < std::numeric_limits<int64_t>::max();
 
  832        int64_t minDistSq = std::numeric_limits<int64_t>::max();
 
  841                int64_t distSq = ( ptB - ptA ).SquaredEuclideanNorm();
 
  842                if( distSq < minDistSq )
 
  851        return minDistSq < std::numeric_limits<int64_t>::max();
 
 
  863    int64_t minDistSq = std::numeric_limits<int64_t>::max();
 
  866    auto checkNearestPoints =
 
  867            [&]( 
const SHAPE* shapeA, 
const SHAPE* shapeB ) -> 
bool 
  873                    int64_t distSq = ( ptB - ptA ).SquaredEuclideanNorm();
 
  875                    if( distSq < minDistSq )
 
  898                checkNearestPoints( elemA, elemB );
 
  908            checkNearestPoints( elemA, aB );
 
  917            checkNearestPoints( aA, elemB );
 
 
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
 
bool NearestPoints(const SHAPE_ARC &aArc, VECTOR2I &aPtA, VECTOR2I &aPtB, int64_t &aDistSq) const
Compute closest points between this arc and aArc.
 
SHAPE_TYPE Type() const
Return the type of the shape.
 
const VECTOR2I GetCenter() const
 
const std::vector< SHAPE * > & Shapes() const
 
virtual size_t GetSegmentCount() const =0
 
virtual const SEG GetSegment(int aIndex) const =0
 
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
 
const SHAPE_ARC & Arc(size_t aArc) const
 
bool IsArcSegment(size_t aSegment) const
 
Represent a set of closed polygons.
 
CONST_SEGMENT_ITERATOR CIterateSegmentsWithHoles() const
Return an iterator object, for the aOutline-th outline in the set (with holes).
 
CONST_SEGMENT_ITERATOR CIterateSegments(int aFirst, int aLast, bool aIterateHoles=false) const
Return an iterator object, for iterating between aFirst and aLast outline, with or without holes (def...
 
const SHAPE_LINE_CHAIN Outline() const
 
const VECTOR2I & GetPosition() const
 
const VECTOR2I GetSize() const
 
const SEG & GetSeg() const
 
int GetWidth() const override
 
An abstract shape on 2D plane.
 
SHAPE(SHAPE_TYPE aType)
Create an empty shape of type aType.
 
bool NearestPoints(const SHAPE *aOther, VECTOR2I &aPtThis, VECTOR2I &aPtOther) const
Return the two points that mark the closest distance between this shape and aOther.
 
VECTOR2_TRAITS< int32_t >::extended_type extended_type
 
@ SH_POLY_SET
set of polygons (with holes, etc.)
 
@ SH_RECT
axis-aligned rectangle
 
@ SH_SIMPLE
simple polygon
 
@ SH_POLY_SET_TRIANGLE
a single triangle belonging to a POLY_SET triangulation
 
@ SH_LINE_CHAIN
line chain (polyline)
 
@ SH_COMPOUND
compound shape, consisting of multiple simple shapes
 
VECTOR2I::extended_type ecoord
 
static bool NearestPoints(const SHAPE_LINE_CHAIN_BASE &aA, const SHAPE_LINE_CHAIN_BASE &aB, VECTOR2I &aPtA, VECTOR2I &aPtB)
Find the nearest points between two line chains.
 
bool NearestPointsCase(const SHAPE *aA, const SHAPE *aB, VECTOR2I &aPtA, VECTOR2I &aPtB)
Template functions to handle shape conversions and reversals.
 
static bool nearestPointsSingleShapes(const SHAPE *aA, const SHAPE *aB, VECTOR2I &aPtA, VECTOR2I &aPtB)
Main dispatcher for finding nearest points between arbitrary shapes.
 
static bool nearestPoints(const SHAPE *aA, const SHAPE *aB, VECTOR2I &aPtA, VECTOR2I &aPtB)
Handle compound shapes by finding nearest points between all sub-shape pairs.
 
bool NearestPointsCaseReversed(const SHAPE *aA, const SHAPE *aB, VECTOR2I &aPtA, VECTOR2I &aPtB)
 
const SHAPE_LINE_CHAIN chain
 
VECTOR2< int32_t > VECTOR2I