48 std::vector<PCB_TRACK*>* buffer;
52 buffer =
new std::vector<PCB_TRACK*>;
57 buffer = (*item).second;
60 buffer->push_back( aTrack );
109 aList.emplace_back(
static_cast<PCB_VIA*
>( item ) );
116 bool aRoundShapesOnly,
117 bool aIncludeNotDrilled )
const
121 for(
PAD*
pad : fp->Pads() )
123 if( !
pad->IsOnCopperLayer() )
126 if(
pad->GetNetCode() <= 0 )
132 if( aRoundShapesOnly )
136 &&
pad->GetSize().x ==
pad->GetSize().y );
141 if(
pad->HasHole() && !aDrilledViaPad )
144 if(
pad->HasHole() || aIncludeNotDrilled )
145 aList.emplace_back(
pad );
155 if( zone->IsTeardropArea() )
156 aList.push_back( zone );
166 if( zone->IsTeardropArea() )
170 if( !zone->IsOnLayer( aTrack->
GetLayer() ) )
173 if( zone->GetNetCode() == aTrack->
GetNetCode() )
212 if( curr_track == aTrackRef )
215 match = curr_track->IsPointOnEnds( aEndPoint,
m_tolerance);
224 double previous_len = candidate->
GetLength();
225 double curr_len = curr_track->GetLength();
227 if( previous_len >= curr_len )
232 candidate = curr_track;
258 std::vector<VECTOR2I>& aPoly,
261 std::vector<VECTOR2I>& pts )
const
268 int td_height = aViaPad.
m_Width * Vpercent;
276 int radius = aViaPad.
m_Width / 2;
277 double minVpercent =
double( aTrackHalfWidth ) / radius;
278 double weaken = (Vpercent - minVpercent) / ( 1 - minVpercent ) / radius;
280 double biasBC = 0.5 *
SEG( pts[1], pts[2] ).
Length();
281 double biasAE = 0.5 *
SEG( pts[4], pts[0] ).
Length();
285 pts[2].y + vecC.
x * biasBC * weaken );
288 pts[4].y - vecE.
x * biasAE * weaken );
290 VECTOR2I tangentB =
VECTOR2I( pts[1].x - aTrackDir.
x * biasBC, pts[1].y - aTrackDir.
y * biasBC );
291 VECTOR2I tangentA =
VECTOR2I( pts[0].x - aTrackDir.
x * biasAE, pts[0].y - aTrackDir.
y * biasAE );
293 std::vector<VECTOR2I> curve_pts;
299 aPoly.push_back( corner );
301 aPoly.push_back( pts[3] );
308 aPoly.push_back( corner );
317 std::vector<VECTOR2I>& aPoly,
int aTdHeight,
318 int aTrackHalfWidth,
VIAPAD& aViaPad,
319 std::vector<VECTOR2I>& aPts )
const
327 VECTOR2I side1( aPts[2] - aPts[1] );
329 VECTOR2I side2( aPts[4] - aPts[0] );
331 std::vector<VECTOR2I> curve_pts;
335 VECTOR2I ctrl1 = ( aPts[1] + aPts[1] + aPts[2] ) / 3;
336 VECTOR2I ctrl2 = ( aPts[1] + aPts[2] + aPts[2] ) / 3;
341 int delta = ( aTdHeight / 2 - aTrackHalfWidth );
349 int delta_effective = std::min(
delta, side_length/8 );
370 aPoly.push_back( corner );
372 aPoly.push_back( aPts[3] );
376 ctrl1 = ( aPts[4] + aPts[4] + aPts[0] ) / 3;
377 ctrl2 = ( aPts[4] + aPts[0] + aPts[0] ) / 3;
380 delta_effective = std::min(
delta, side_length/8 );
399 aPoly.push_back( corner );
406 std::vector<VECTOR2I>& aPts )
const
439 wxCHECK(
pad,
false );
441 force_clip_shape =
true;
453 int halfsize = std::min( aCurrParams->
m_TdMaxHeight, preferred_height )/2;
458 VECTOR2I ref_on_track = ( aPts[0] + aPts[1] ) / 2;
459 VECTOR2I teardrop_axis( aPts[3] - ref_on_track );
471 clipping_rect.
Append( 0, - halfsize );
472 clipping_rect.
Append( 0, halfsize );
473 clipping_rect.
Append( len, halfsize );
474 clipping_rect.
Append( len, - halfsize );
476 clipping_rect.
Rotate( -orient );
477 clipping_rect.
Move( ref_on_track );
490 std::vector<VECTOR2I> points = padpoly.
CPoints();
492 std::vector<VECTOR2I> initialPoints;
493 initialPoints.push_back( aPts[0] );
494 initialPoints.push_back( aPts[1] );
497 initialPoints.emplace_back( pt.x, pt.y );
499 std::vector<VECTOR2I> hull;
506 int found_start = -1;
512 for(
unsigned ii = 0, jj = 0; jj < hull.size(); ii++, jj++ )
514 unsigned next = ii+ 1;
516 if(
next >= hull.size() )
522 prev = hull.size()-1;
524 if( hull[ii] == start )
527 if( hull[
next] != pend )
535 if( hull[ii] == pend )
537 if( hull[
next] != start )
546 if( found_start < 0 )
548 int ii = found_end-1;
558 int ii = found_start-1;
575 double area1 = dummy1.
Area();
577 std::swap( aPts[2], aPts[4] );
579 double area2 = dummy2.
Area();
582 std::swap( aPts[2], aPts[4] );
591 int* aEffectiveTeardropLen,
598 int radius = aViaPad.
m_Width / 2;
604 targetLength = std::min( aCurrParams->
m_TdMaxLen, targetLength );
608 bool need_swap =
false;
613 std::swap( start, end );
627 pad->TransformShapeToPolygon( shapebuffer, aTrack->
GetLayer(), 0,
637 int pt_count = outline.
Intersect(
SEG( start, end ), pts );
649 actualTdLen = std::min( targetLength,
SEG( start, end ).Length() );
654 if( actualTdLen < targetLength && aFollowTracks )
658 while( actualTdLen+consumed < targetLength )
664 if( connected_track ==
nullptr )
668 consumed += actualTdLen;
670 actualTdLen = std::min( targetLength-consumed,
int( connected_track->
GetLength() ) );
671 aTrack = connected_track;
672 end = connected_track->
GetEnd();
673 start = connected_track->
GetStart();
678 std::swap( start, end );
712 for(
int ii = poly.
PointCount()-1; ii >= 0 ; ii-- )
718 if( dist_from_start < actualTdLen || ii == 0 )
720 start = poly.
CPoint( ii );
723 end = poly.
CPoint( ii+1 );
732 if( actualTdLen < 0 )
735 actualTdLen = std::min( actualTdLen, (end - start).
EuclideanNorm() );
750 *aEffectiveTeardropLen = actualTdLen;
756 std::vector<VECTOR2I>& aCorners,
769 aFollowTracks, aTrackLookupList ) )
779 int track_halfwidth = aTrack->
GetWidth() / 2;
780 VECTOR2I pointB = start +
VECTOR2I( vecT.
x * track_stub_len + vecT.
y * track_halfwidth,
781 vecT.
y * track_stub_len - vecT.
x * track_halfwidth );
782 VECTOR2I pointA = start +
VECTOR2I( vecT.
x * track_stub_len - vecT.
y * track_halfwidth,
783 vecT.
y * track_stub_len + vecT.
x * track_halfwidth );
791 if(
pad->HitTest( pointA ) )
794 if(
pad->HitTest( pointB ) )
803 pointD +=
VECTOR2I(
int( -vecT.
x*offset),
int(-vecT.
y*offset) );
806 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.
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
FOOTPRINTS & Footprints()
KICAD_T Type() const
Returns the type of object.
int GetDrillSizeY() const
VECTOR2I GetPosition() const override
int GetDrillSizeX() const
PAD_SHAPE GetShape() const
const VECTOR2I & GetSize() const
const VECTOR2I & GetMid() const
virtual double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
VECTOR2I GetPosition() const override
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
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 union between a and b, store the result in it self For aFastMode meaning,...
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
SHAPE_LINE_CHAIN & Outline(int aIndex)
int NewOutline()
Creates a new hole in a given outline.
void Move(const VECTOR2I &aVector) override
bool ComputePointsOnPadVia(TEARDROP_PARAMETERS *aCurrParams, PCB_LAYER_ID aLayer, VIAPAD &aViaPad, std::vector< VECTOR2I > &aPts) const
Compute the 2 points on pad/via of the teardrop shape.
void collectTeardrops(std::vector< ZONE * > &aList) const
Build a list of all teardrops on the current board.
void collectVias(std::vector< VIAPAD > &aList) const
Collect and build the list of all vias from the given board.
void collectPadsCandidate(std::vector< VIAPAD > &aList, bool aDrilledViaPad, bool aRoundShapesOnly, bool aIncludeNotDrilled) const
Build a list of pads candidate for teardrops from the given board Pads with no net are not candidate ...
bool findAnchorPointsOnTrack(TEARDROP_PARAMETERS *aCurrParams, VECTOR2I &aStartPoint, VECTOR2I &aEndPoint, PCB_TRACK *&aTrack, VIAPAD &aViaPad, int *aEffectiveTeardropLen, bool aFollowTracks, TRACK_BUFFER &aTrackLookupList) const
void computeCurvedForRoundShape(TEARDROP_PARAMETERS *aCurrParams, std::vector< VECTOR2I > &aPoly, int aTrackHalfWidth, VECTOR2D aTrackDir, VIAPAD &aViaPad, std::vector< VECTOR2I > &aPts) const
Compute the curve part points for teardrops connected to a round shape The Bezier curve control point...
bool isViaAndTrackInSameZone(VIAPAD &aVia, PCB_TRACK *aTrack) const
bool computeTeardropPolygonPoints(TEARDROP_PARAMETERS *aCurrParams, std::vector< VECTOR2I > &aCorners, PCB_TRACK *aTrack, VIAPAD &aVia, bool aFollowTracks, TRACK_BUFFER &aTrackLookupList) const
Compute all teardrop points of the polygon shape.
PCB_TRACK * findTouchingTrack(EDA_ITEM_FLAGS &aMatchType, PCB_TRACK *aTrackRef, const VECTOR2I &aEndPoint, TRACK_BUFFER &aTrackLookupList) const
Find a track connected to the end of another track.
void computeCurvedForRectShape(TEARDROP_PARAMETERS *aCurrParams, std::vector< VECTOR2I > &aPoly, int aTdHeight, int aTrackHalfWidth, VIAPAD &aViaPad, std::vector< VECTOR2I > &aPts) const
Compute the curve part points for teardrops connected to a rectangular/polygonal shape The Bezier cur...
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_HeightRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxHeight
max allowed height for teardrops in IU. <= 0 to disable
int m_TdMaxLen
the type of target for these parameters
double m_LengthRatio
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
std::vector< PCB_TRACK * > * GetTrackList(int aLayer, int aNetcode)
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
Stores info of a pad, via or track end to build a teardrop.
BOARD_CONNECTED_ITEM * m_Parent
static VECTOR2D NormalizeVector(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
@ NONE
Pads are not covered.