37 int aClearance,
int aChamfer )
43 s.
Append( aP0.
x - aClearance, aP0.
y - aClearance + aChamfer );
46 s.
Append( aP0.
x - aClearance + aChamfer, aP0.
y - aClearance );
48 s.
Append( aP0.
x + aSize.
x + aClearance - aChamfer, aP0.
y - aClearance );
51 s.
Append( aP0.
x + aSize.
x + aClearance, aP0.
y - aClearance + aChamfer );
53 s.
Append( aP0.
x + aSize.
x + aClearance, aP0.
y + aSize.
y + aClearance - aChamfer );
56 s.
Append( aP0.
x + aSize.
x + aClearance - aChamfer, aP0.
y + aSize.
y + aClearance );
58 s.
Append( aP0.
x - aClearance + aChamfer, aP0.
y + aSize.
y + aClearance );
61 s.
Append( aP0.
x - aClearance, aP0.
y + aSize.
y + aClearance - aChamfer );
69 int cl = aClearance + ( aWalkaroundThickness + 1 ) / 2;
78 2.0 * ( 1.0 - M_SQRT1_2 ) * ( r + cl ) );
82 int x = (int) ( 2.0 / ( 1.0 + M_SQRT2 ) * d ) / 2;
88 std::vector<VECTOR2I> reverse_line;
90 auto seg = line.Segment( 0 );
98 s.
Append( seg.A + p0 - pd );
99 s.
Append( seg.A - dp + ds );
100 s.
Append( seg.A - dp - ds );
101 s.
Append( seg.A - p0 - pd );
103 for(
int i = 1; i < line.SegmentCount(); i++ )
107 ( line.CSegment( i - 1 ).B - line.CSegment( i - 1 ).A ).Perpendicular().Resize( d );
108 auto pp2 = ( line.CSegment( i ).B - line.CSegment( i ).A ).Perpendicular().Resize( d );
110 auto sa_out = line.CSegment( i - 1 ), sa_in = line.CSegment( i - 1 );
111 auto sb_out = line.CSegment( i ), sb_in = line.CSegment( i );
123 auto ip_out = sa_out.IntersectLines( sb_out );
124 auto ip_in = sa_in.IntersectLines( sb_in );
126 seg = line.CSegment( i );
127 auto lead = ( pp + pp2 ) / 2;
130 reverse_line.push_back( *ip_in );
133 seg = line.CSegment( -1 );
139 s.
Append( seg.B - p0 + pd );
140 s.
Append( seg.B + dp - ds );
141 s.
Append( seg.B + dp + ds );
142 s.
Append( seg.B + p0 + pd );
144 for(
int i = reverse_line.size() - 1; i >= 0; i-- )
145 s.
Append( reverse_line[i] );
174template <
typename T>
int sgn(T val) {
175 return (T(0) < val) - (val < T(0));
180 int aWalkaroundThickness )
182 const int kinkThreshold = aClearance / 10;
184 int cl = aClearance + aWalkaroundThickness / 2;
185 double d = (double)aSeg.
GetWidth() / 2.0 + cl;
186 double x = 2.0 / ( 1.0 + M_SQRT2 ) * d;
210 if ( len <= kinkThreshold && len > 0 )
219 if( len <= kinkThreshold )
232 else if ( delta45 <= 2 )
251 int xx2 =
KiROUND( 2.0 * ( 1.0 - M_SQRT1_2 ) * d );
293 VECTOR2I moveBy = ( aDiagonal.
A - aDiagonal.
B ).Perpendicular().
Resize( dist - aClearance );
294 aDiagonal.
A += moveBy;
295 aDiagonal.
B += moveBy;
317 SEG toprightline =
SEG( corner,
329 SEG bottomleftline =
SEG( corner,
363 return SHAPE_RECT( std::min( p0.
x, p1.
x ), std::min( p0.
y, p1.
y ),
372 const VIA* va =
static_cast<const VIA*
>( aItemA );
373 const VIA* vb =
static_cast<const VIA*
>( aItemB );
379 const LINE* la =
static_cast<const LINE*
> ( aItemA );
380 const LINE* lb =
static_cast<const LINE*
> ( aItemB );
404 for(
auto& p : ips_raw )
410 int d1_idx = 0, d2_idx = 0;
415 if( !p.is_corner_our && !p.is_corner_their )
418 ips.push_back( ipp );
425 if( p.is_corner_our )
427 d1[0] = hull.
CSegment( p.index_our );
428 d1[1] = hull.
CSegment( p.index_our - 1 );
433 d1[0] = hull.
CSegment( p.index_our );
437 if( p.is_corner_their )
439 if( p.index_their > 0 )
441 d2[d2_idx++] = line.
CSegment( p.index_their - 1 ).
A;
445 d2[d2_idx++] = line.
CSegment( p.index_their ).
B;
450 d2[d2_idx++] = line.
CSegment( p.index_their ).
A;
451 d2[d2_idx++] = line.
CSegment( p.index_their ).
B;
454 for(
int i = 0; i < d1_idx; i++ )
456 for(
int j = 0; j < d2_idx; j++ )
458 if( d1[i].Side( d2[j] ) > 0 )
465#ifdef TOM_EXTRA_DEBUG
466 printf(
"p %d %d hi %d their %d co %d ct %d ipv %d\n", p.p.x, p.p.y, p.index_our, p.index_their, p.is_corner_our?1:0, p.is_corner_their?1:0, ipp.
valid ?1:0);
467 printf(
"d1 %d d2 %d\n", d1_idx, d2_idx );
471 ips.push_back( ipp );
478 int aWalkaroundThickness )
480 int cl = aClearance + ( aWalkaroundThickness + 1 )/ 2;
482 switch( aShape->
Type() )
500 2.0 * ( 1.0 - M_SQRT1_2 ) * ( r + cl ) );
506 return SegmentHull( *seg, aClearance, aWalkaroundThickness );
512 return ArcHull( *arc, aClearance, aWalkaroundThickness );
523 wxFAIL_MSG( wxString::Format( wxT(
"Unsupported hull shape: %d (%s)." ),
constexpr int ARC_LOW_DEF
std::optional< BOX2I > OPT_BOX2I
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr coord_type GetX() const
constexpr size_type GetHeight() const
constexpr const Vec & GetOrigin() const
constexpr const SizeVec & GetSize() const
Base class for PNS router board items.
bool OfKind(int aKindMask) const
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
OPT_BOX2I ChangedArea(const LINE *aOther) const
OPT_BOX2I ChangedArea(const VIA *aOther) const
int Length() const
Return the length (this).
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
int Side(const VECTOR2I &aP) const
Determine on which side of directed line passing via segment ends point aP lies.
EDA_ANGLE GetCentralAngle() const
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=DefaultAccuracyForPCB(), double *aEffectiveAccuracy=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
static double DefaultAccuracyForPCB()
const VECTOR2I & GetCenter() const
SHAPE_TYPE Type() const
Return the type of the shape.
const VECTOR2I GetCenter() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN Reverse() const
Reverse point order in the line chain.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int Intersect(const SEG &aSeg, INTERSECTIONS &aIp) const
Find all intersection points between our line chain and the segment aSeg.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
std::vector< INTERSECTION > INTERSECTIONS
const VECTOR2I & GetPosition() const
const VECTOR2I GetSize() const
const SEG & GetSeg() const
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
const SHAPE_LINE_CHAIN & Vertices() const
Return the list of vertices defining this simple polygon.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
An abstract shape on 2D plane.
constexpr VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Push and Shove diff pair dimensions (gap) settings dialog.
void HullIntersection(const SHAPE_LINE_CHAIN &hull, const SHAPE_LINE_CHAIN &line, SHAPE_LINE_CHAIN::INTERSECTIONS &ips)
const SHAPE_LINE_CHAIN BuildHullForPrimitiveShape(const SHAPE *aShape, int aClearance, int aWalkaroundThickness)
const SHAPE_LINE_CHAIN OctagonalHull(const VECTOR2I &aP0, const VECTOR2I &aSize, int aClearance, int aChamfer)
SHAPE_RECT ApproximateSegmentAsRect(const SHAPE_SEGMENT &aSeg)
const SHAPE_LINE_CHAIN ArcHull(const SHAPE_ARC &aArc, int aClearance, int aWalkaroundThickness)
Various utility functions.
const SHAPE_LINE_CHAIN ConvexHull(const SHAPE_SIMPLE &aConvex, int aClearance)
Function ConvexHull()
const SHAPE_LINE_CHAIN SegmentHull(const SHAPE_SEGMENT &aSeg, int aClearance, int aWalkaroundThickness)
static bool IsSegment45Degree(const SEG &aS)
static void MoveDiagonal(SEG &aDiagonal, const SHAPE_LINE_CHAIN &aVertices, int aClearance)
OPT_BOX2I ChangedArea(const ITEM *aItemA, const ITEM *aItemB)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ SH_RECT
axis-aligned rectangle
@ SH_SIMPLE
simple polygon
static wxString SHAPE_TYPE_asString(SHAPE_TYPE a)
Represent an intersection between two line segments.
bool valid
Auxiliary flag to avoid copying intersection info to intersection refining code, used by the refining...
VECTOR2< int32_t > VECTOR2I