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 d = aSeg.
GetWidth() / 2 + aClearance + aWalkaroundThickness / 2
71 int x = (int) ( 2.0 / ( 1.0 + M_SQRT2 ) * d ) / 2;
77 std::vector<VECTOR2I> reverse_line;
79 auto seg = line.Segment( 0 );
87 s.
Append( seg.A + p0 - pd );
88 s.
Append( seg.A - dp + ds );
89 s.
Append( seg.A - dp - ds );
90 s.
Append( seg.A - p0 - pd );
92 for(
int i = 1; i < line.SegmentCount(); i++ )
96 ( line.CSegment( i - 1 ).B - line.CSegment( i - 1 ).A ).Perpendicular().Resize( d );
97 auto pp2 = ( line.CSegment( i ).B - line.CSegment( i ).A ).Perpendicular().Resize( d );
99 auto sa_out = line.CSegment( i - 1 ), sa_in = line.CSegment( i - 1 );
100 auto sb_out = line.CSegment( i ), sb_in = line.CSegment( i );
112 auto ip_out = sa_out.IntersectLines( sb_out );
113 auto ip_in = sa_in.IntersectLines( sb_in );
115 seg = line.CSegment( i );
116 auto lead = ( pp + pp2 ) / 2;
119 reverse_line.push_back( *ip_in );
122 seg = line.CSegment( -1 );
128 s.
Append( seg.B - p0 + pd );
129 s.
Append( seg.B + dp - ds );
130 s.
Append( seg.B + dp + ds );
131 s.
Append( seg.B + p0 + pd );
133 for(
int i = reverse_line.size() - 1; i >= 0; i-- )
134 s.
Append( reverse_line[i] );
164template <
typename T>
int sgn(T val) {
165 return (T(0) < val) - (val < T(0));
170 int aWalkaroundThickness )
172 const int kinkThreshold = aClearance / 10;
174 int cl = aClearance + aWalkaroundThickness / 2;
175 double d = (double)aSeg.
GetWidth() / 2.0 + cl;
176 double x = 2.0 / ( 1.0 + M_SQRT2 ) * d;
200 if ( len <= kinkThreshold && len > 0 )
209 if( len <= kinkThreshold )
222 else if ( delta45 <= 2 )
241 int xx2 =
KiROUND( 2.0 * ( 1.0 - M_SQRT1_2 ) * d );
283 VECTOR2I moveBy = ( aDiagonal.
A - aDiagonal.
B ).Perpendicular().
Resize( dist - aClearance );
284 aDiagonal.
A += moveBy;
285 aDiagonal.
B += moveBy;
307 SEG toprightline =
SEG( corner,
319 SEG bottomleftline =
SEG( corner,
353 return SHAPE_RECT( std::min( p0.
x, p1.
x ), std::min( p0.
y, p1.
y ),
362 const VIA* va =
static_cast<const VIA*
>( aItemA );
363 const VIA* vb =
static_cast<const VIA*
>( aItemB );
369 const LINE* la =
static_cast<const LINE*
> ( aItemA );
370 const LINE* lb =
static_cast<const LINE*
> ( aItemB );
394 for(
auto& p : ips_raw )
400 int d1_idx = 0, d2_idx = 0;
405 if( !p.is_corner_our && !p.is_corner_their )
408 ips.push_back( ipp );
415 if( p.is_corner_our )
417 d1[0] = hull.
CSegment( p.index_our );
418 d1[1] = hull.
CSegment( p.index_our - 1 );
423 d1[0] = hull.
CSegment( p.index_our );
427 if( p.is_corner_their )
429 if( p.index_their > 0 )
431 d2[d2_idx++] = line.
CSegment( p.index_their - 1 ).
A;
435 d2[d2_idx++] = line.
CSegment( p.index_their ).
B;
440 d2[d2_idx++] = line.
CSegment( p.index_their ).
A;
441 d2[d2_idx++] = line.
CSegment( p.index_their ).
B;
444 for(
int i = 0; i < d1_idx; i++ )
446 for(
int j = 0; j < d2_idx; j++ )
448 if( d1[i].Side( d2[j] ) > 0 )
455#ifdef TOM_EXTRA_DEBUG
456 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);
457 printf(
"d1 %d d2 %d\n", d1_idx, d2_idx );
461 ips.push_back( ipp );
468 int aWalkaroundThickness )
470 int cl = aClearance + ( aWalkaroundThickness + 1 )/ 2;
472 switch( aShape->
Type() )
490 2.0 * ( 1.0 - M_SQRT1_2 ) * ( r + cl ) );
496 return SegmentHull( *seg, aClearance, aWalkaroundThickness );
502 return ArcHull( *arc, aClearance, aWalkaroundThickness );
513 wxFAIL_MSG( wxString::Format( wxT(
"Unsupported hull shape: %d (%s)." ),
std::optional< BOX2I > OPT_BOX2I
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
const Vec & GetOrigin() const
coord_type GetHeight() const
coord_type GetWidth() const
const Vec & 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.
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()
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.
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 &aSeg, 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...
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".