49 std::vector<PCB_TRACK*>* buffer;
53 buffer =
new std::vector<PCB_TRACK*>;
58 buffer = (*item).second;
61 buffer->push_back( aTrack );
70 return via->GetWidth();
75 return std::min(
pad->GetSize().x,
pad->GetSize().y );
93 return pad->GetShape() == PAD_SHAPE::CIRCLE
94 || (
pad->GetShape() == PAD_SHAPE::OVAL &&
pad->GetSize().x ==
pad->GetSize().y );
119 if( zone->IsTeardropArea() )
123 if( !zone->IsOnLayer( aTrack->
GetLayer() ) )
126 if( zone->GetNetCode() == aTrack->
GetNetCode() )
133 PAD *
pad =
static_cast<PAD*
>( aPadOrVia );
135 if( zone->GetPadConnection() == ZONE_CONNECTION::NONE
136 ||
pad->GetZoneConnectionOverrides(
nullptr ) == ZONE_CONNECTION::NONE )
161 return trackItem != aTrackRef;
166 PCB_TRACK* curr_track = static_cast<PCB_TRACK*>( trackItem );
169 if( EDA_ITEM_FLAGS match = curr_track->IsPointOnEnds( aEndPoint, m_tolerance ) )
176 double previous_len = candidate->GetLength();
177 double curr_len = curr_track->GetLength();
179 if( previous_len >= curr_len )
184 candidate = curr_track;
212 std::vector<VECTOR2I>& aPoly,
213 int aTrackHalfWidth,
const VECTOR2D& aTrackDir,
215 std::vector<VECTOR2I>& pts )
const
230 int radius =
GetWidth( aOther ) / 2;
233 wxCHECK2( radius != 0, radius = 1 );
235 double minVpercent = double( aTrackHalfWidth ) / radius;
236 double weaken = (Vpercent - minVpercent) / ( 1 - minVpercent ) / radius;
238 double biasBC = 0.5 *
SEG( pts[1], pts[2] ).
Length();
239 double biasAE = 0.5 *
SEG( pts[4], pts[0] ).
Length();
243 pts[2].y + vecC.
x * biasBC * weaken );
246 pts[4].y - vecE.
x * biasAE * weaken );
248 VECTOR2I tangentB =
VECTOR2I( pts[1].x - aTrackDir.
x * biasBC, pts[1].y - aTrackDir.
y * biasBC );
249 VECTOR2I tangentA =
VECTOR2I( pts[0].x - aTrackDir.
x * biasAE, pts[0].y - aTrackDir.
y * biasAE );
251 std::vector<VECTOR2I> curve_pts;
256 aPoly.push_back( corner );
258 aPoly.push_back( pts[3] );
264 aPoly.push_back( corner );
273 std::vector<VECTOR2I>& aPoly,
int aTdWidth,
275 std::vector<VECTOR2I>& aPts )
const
283 VECTOR2I side1( aPts[2] - aPts[1] );
285 VECTOR2I side2( aPts[4] - aPts[0] );
287 std::vector<VECTOR2I> curve_pts;
291 VECTOR2I ctrl1 = ( aPts[1] + aPts[1] + aPts[2] ) / 3;
292 VECTOR2I ctrl2 = ( aPts[1] + aPts[2] + aPts[2] ) / 3;
297 int delta = ( aTdWidth / 2 - aTrackHalfWidth );
305 int delta_effective = std::min(
delta, side_length/8 );
325 aPoly.push_back( corner );
327 aPoly.push_back( aPts[3] );
331 ctrl1 = ( aPts[4] + aPts[4] + aPts[0] ) / 3;
332 ctrl2 = ( aPts[4] + aPts[0] + aPts[0] ) / 3;
335 delta_effective = std::min(
delta, side_length/8 );
353 aPoly.push_back( corner );
359 std::vector<VECTOR2I>& aPts )
const
402 int halfsize = std::min( aParams.
m_TdMaxWidth, preferred_width )/2;
407 VECTOR2I ref_on_track = ( aPts[0] + aPts[1] ) / 2;
408 VECTOR2I teardrop_axis( aPts[3] - ref_on_track );
420 clipping_rect.
Append( 0, - halfsize );
421 clipping_rect.
Append( 0, halfsize );
422 clipping_rect.
Append( len, halfsize );
423 clipping_rect.
Append( len, - halfsize );
425 clipping_rect.
Rotate( -orient );
426 clipping_rect.
Move( ref_on_track );
439 std::vector<VECTOR2I> points = padpoly.
CPoints();
441 std::vector<VECTOR2I> initialPoints;
442 initialPoints.push_back( aPts[0] );
443 initialPoints.push_back( aPts[1] );
446 initialPoints.emplace_back( pt.x, pt.y );
448 std::vector<VECTOR2I> hull;
455 int found_start = -1;
461 for(
unsigned ii = 0, jj = 0; jj < hull.size(); ii++, jj++ )
463 unsigned next = ii+ 1;
465 if(
next >= hull.size() )
471 prev = hull.size()-1;
473 if( hull[ii] == start )
476 if( hull[
next] != pend )
484 if( hull[ii] == pend )
486 if( hull[
next] != start )
495 if( found_start < 0 )
497 int ii = found_end-1;
507 int ii = found_start-1;
524 double area1 = dummy1.
Area();
526 std::swap( aPts[2], aPts[4] );
528 double area2 = dummy2.
Area();
531 std::swap( aPts[2], aPts[4] );
541 int* aEffectiveTeardropLen )
const
546 int radius =
GetWidth( aOther ) / 2;
552 targetLength = std::min( aParams.
m_TdMaxLen, targetLength );
556 bool need_swap =
false;
560 if( !aOther->
HitTest( start, 0 ) )
562 std::swap( start, end );
574 static_cast<PAD*
>( aOther )->TransformShapeToPolygon( shapebuffer, aTrack->
GetLayer(), 0,
594 pt_count = outline.
Intersect( poly, pts );
609 actualTdLen = std::min( targetLength,
SEG( start, end ).Length() );
618 while( actualTdLen + consumed < targetLength )
624 if( connected_track ==
nullptr )
628 consumed += actualTdLen;
630 actualTdLen = std::min( targetLength-consumed,
int( connected_track->
GetLength() ) );
631 aTrack = connected_track;
632 end = connected_track->
GetEnd();
633 start = connected_track->
GetStart();
638 std::swap( start, end );
672 for(
int ii = poly.
PointCount()-1; ii >= 0 ; ii-- )
678 if( dist_from_start < actualTdLen || ii == 0 )
680 start = poly.
CPoint( ii );
683 end = poly.
CPoint( ii+1 );
692 if( actualTdLen < 0 )
695 actualTdLen = std::min( actualTdLen, (end - start).
EuclideanNorm() );
710 *aEffectiveTeardropLen = actualTdLen;
716 std::vector<VECTOR2I>& aCorners,
PCB_TRACK* aTrack,
736 int track_halfwidth = aTrack->
GetWidth() / 2;
737 VECTOR2I pointB = start +
VECTOR2I( vecT.
x * track_stub_len + vecT.
y * track_halfwidth,
738 vecT.
y * track_stub_len - vecT.
x * track_halfwidth );
739 VECTOR2I pointA = start +
VECTOR2I( vecT.
x * track_stub_len - vecT.
y * track_halfwidth,
740 vecT.
y * track_stub_len + vecT.
x * track_halfwidth );
748 if(
pad->HitTest( pointA ) )
751 if(
pad->HitTest( pointB ) )
760 pointD +=
VECTOR2I(
int( -vecT.
x*offset),
int(-vecT.
y*offset) );
763 std::vector<VECTOR2I> pts = {pointA, pointB, pointC, pointD, pointE};
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
Bezier curves to polygon converter.
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMinSegLen=0, int aMaxSegCount=32)
Convert a Bezier curve to a polygon.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
const ZONES & Zones() const
const TRACKS & Tracks() const
void Insert(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer, int aWorstClearance=0)
Insert an item into the tree on a particular layer with an optional worst clearance.
int QueryColliding(BOARD_ITEM *aRefItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer, std::function< bool(BOARD_ITEM *)> aFilter=nullptr, std::function< bool(BOARD_ITEM *)> aVisitor=nullptr, int aClearance=0) const
This is a fast test which essentially does bounding-box overlap given a worst-case clearance.
virtual VECTOR2I GetPosition() const
KICAD_T Type() const
Returns the type of object.
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Test if aPosition is inside or on the boundary of this item.
const VECTOR2I & GetMid() const
virtual double GetLength() const
Get the length of the track using the hypotenuse calculation.
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
int Length() const
Return the length (this).
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=DefaultAccuracyForPCB(), double *aEffectiveAccuracy=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
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.
double Area(bool aAbsolute=true) const
Return the area of this chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
std::vector< INTERSECTION > INTERSECTIONS
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void Move(const VECTOR2I &aVector) override
bool computeAnchorPoints(const TEARDROP_PARAMETERS &aParams, PCB_LAYER_ID aLayer, BOARD_ITEM *aItem, const VECTOR2I &aPos, std::vector< VECTOR2I > &aPts) const
Compute the 2 points on pad/via of the teardrop shape.
bool computeTeardropPolygon(const TEARDROP_PARAMETERS &aParams, std::vector< VECTOR2I > &aCorners, PCB_TRACK *aTrack, BOARD_ITEM *aOther, const VECTOR2I &aOtherPos) const
Compute all teardrop points of the polygon shape.
PCB_TRACK * findTouchingTrack(EDA_ITEM_FLAGS &aMatchType, PCB_TRACK *aTrackRef, const VECTOR2I &aEndPoint) const
Find a track connected to the end of another track.
bool findAnchorPointsOnTrack(const TEARDROP_PARAMETERS &aParams, VECTOR2I &aStartPoint, VECTOR2I &aEndPoint, PCB_TRACK *&aTrack, BOARD_ITEM *aOther, const VECTOR2I &aOtherPos, int *aEffectiveTeardropLen) const
TRACK_BUFFER m_trackLookupList
static bool IsRound(BOARD_ITEM *aItem)
bool areItemsInSameZone(BOARD_ITEM *aPadOrVia, PCB_TRACK *aTrack) const
void computeCurvedForRectShape(const TEARDROP_PARAMETERS &aParams, std::vector< VECTOR2I > &aPoly, int aTdWidth, int aTrackHalfWidth, std::vector< VECTOR2I > &aPts) const
Compute the curve part points for teardrops connected to a rectangular/polygonal shape The Bezier cur...
static int GetWidth(BOARD_ITEM *aItem)
void computeCurvedForRoundShape(const TEARDROP_PARAMETERS &aParams, std::vector< VECTOR2I > &aPoly, int aTrackHalfWidth, const VECTOR2D &aTrackDir, BOARD_ITEM *aOther, const VECTOR2I &aOtherPos, std::vector< VECTOR2I > &aPts) const
Compute the curve part points for teardrops connected to a round shape The Bezier curve control point...
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
number of segments to build the curved sides of a teardrop area must be > 2.
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
int idxFromLayNet(int aLayer, int aNetcode) const
void AddTrack(PCB_TRACK *aTrack, int aLayer, int aNetcode)
Add a track in buffer, in space grouping tracks having the same netcode and the same layer.
std::map< int, std::vector< PCB_TRACK * > * > m_map_tracks
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Handle a list of polygons defining a copper zone.
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
void BuildConvexHull(std::vector< VECTOR2I > &aResult, const std::vector< VECTOR2I > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
static constexpr EDA_ANGLE ANGLE_90
std::uint32_t EDA_ITEM_FLAGS
#define STARTPOINT
When a line is selected, these flags indicate which.
PCB_LAYER_ID
A quick note on layer IDs:
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
static bool intersect(const SEGMENT_WITH_NORMALS &aSeg, const SFVEC2F &aStart, const SFVEC2F &aEnd)
constexpr int mmToIU(double mm) const
static VECTOR2D NormalizeVector(const VECTOR2I &aVector)
double EuclideanNorm(const VECTOR2I &vector)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".