KiCad PCB EDA Suite
Loading...
Searching...
No Matches
TEARDROP_MANAGER Class Reference

TEARDROP_MANAGER manage and build teardrop areas A teardrop area is a polygonal area (a copper ZONE) having: 2 points on the track connected to a pad or via 2 points on the outline of this pad or via 1 point near the pad/via position (calculated in order to have this pad/via position inside the area The 2 sides joining a point on the track to the corresponding point on the pad/via outline can be a straight line or a curved shape (defined from a Bezier curve) This curved shape is built by segments (3 to 10) from this Bezier curve Because one cannot build a suitable shape for a custom pad, custom pads are ignored. More...

#include <teardrop.h>

Public Types

enum  TEARDROP_VARIANT { TD_TYPE_PADVIA , TD_TYPE_TRACKEND }
 

Public Member Functions

 TEARDROP_MANAGER (BOARD *aBoard, TOOL_MANAGER *aToolManager)
 
void RemoveTeardrops (BOARD_COMMIT &aCommit, const std::vector< BOARD_ITEM * > *dirtyPadsAndVias, const std::set< PCB_TRACK * > *dirtyTracks)
 Remove teardrops connected to any dirty pads, vias or tracks.
 
void UpdateTeardrops (BOARD_COMMIT &aCommit, const std::vector< BOARD_ITEM * > *dirtyPadsAndVias, const std::set< PCB_TRACK * > *dirtyTracks, bool aForceFullUpdate=false)
 Update teardrops on a list of items.
 
void AddTeardropsOnTracks (BOARD_COMMIT &aCommit, const std::set< PCB_TRACK * > *aTracks, bool aForceFullUpdate=false)
 Add teardrop on tracks of different sizes connected by their end.
 
void DeleteTrackToTrackTeardrops (BOARD_COMMIT &aCommit)
 

Static Public Member Functions

static int GetWidth (BOARD_ITEM *aItem, PCB_LAYER_ID aLayer)
 
static bool IsRound (BOARD_ITEM *aItem, PCB_LAYER_ID aLayer)
 

Private Member Functions

bool areItemsInSameZone (BOARD_ITEM *aPadOrVia, PCB_TRACK *aTrack) const
 
void computeCurvedForRoundShape (const TEARDROP_PARAMETERS &aParams, std::vector< VECTOR2I > &aPoly, PCB_LAYER_ID aLayer, 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 points are optimized for a round pad/via shape, and do not give a good curve shape for other pad shapes use m_m_heightRatio.
 
void computeCurvedForRectShape (const TEARDROP_PARAMETERS &aParams, std::vector< VECTOR2I > &aPoly, int aTdWidth, int aTrackHalfWidth, std::vector< VECTOR2I > &aPts, const VECTOR2I &aIntersection) const
 Compute the curve part points for teardrops connected to a rectangular/polygonal shape The Bezier curve control points are not optimized for a special shape, so use computeCurvedForRoundShape() for round shapes for better result.
 
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.
 
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.
 
PCB_TRACKfindTouchingTrack (EDA_ITEM_FLAGS &aMatchType, PCB_TRACK *aTrackRef, const VECTOR2I &aEndPoint) const
 Find a track connected to the end of another track.
 
ZONEcreateTeardrop (TEARDROP_VARIANT aTeardropVariant, std::vector< VECTOR2I > &aPoints, PCB_TRACK *aTrack) const
 Creates a teardrop (a ZONE item) from its polygonal shape, track netcode and layer.
 
void setTeardropPriorities ()
 Set priority of created teardrops.
 
bool findAnchorPointsOnTrack (const TEARDROP_PARAMETERS &aParams, VECTOR2I &aStartPoint, VECTOR2I &aEndPoint, VECTOR2I &aIntersection, PCB_TRACK *&aTrack, BOARD_ITEM *aOther, const VECTOR2I &aOtherPos, int *aEffectiveTeardropLen) const
 
void buildTrackCaches ()
 

Private Attributes

int m_tolerance
 
BOARDm_board
 
TOOL_MANAGERm_toolManager
 
TEARDROP_PARAMETERS_LISTm_prmsList
 
DRC_RTREE m_tracksRTree
 
TRACK_BUFFER m_trackLookupList
 
std::vector< ZONE * > m_createdTdList
 

Friends

class TEARDROP_PARAMETERS
 

Detailed Description

TEARDROP_MANAGER manage and build teardrop areas A teardrop area is a polygonal area (a copper ZONE) having: 2 points on the track connected to a pad or via 2 points on the outline of this pad or via 1 point near the pad/via position (calculated in order to have this pad/via position inside the area The 2 sides joining a point on the track to the corresponding point on the pad/via outline can be a straight line or a curved shape (defined from a Bezier curve) This curved shape is built by segments (3 to 10) from this Bezier curve Because one cannot build a suitable shape for a custom pad, custom pads are ignored.

Size of area (height and length) are defined from the pad/via size or for pads having a size X and a size Y, the smallest of X,Y size.

Definition at line 96 of file teardrop.h.

Member Enumeration Documentation

◆ TEARDROP_VARIANT

Enumerator
TD_TYPE_PADVIA 
TD_TYPE_TRACKEND 

Definition at line 101 of file teardrop.h.

Constructor & Destructor Documentation

◆ TEARDROP_MANAGER()

TEARDROP_MANAGER::TEARDROP_MANAGER ( BOARD aBoard,
TOOL_MANAGER aToolManager 
)

Member Function Documentation

◆ AddTeardropsOnTracks()

◆ areItemsInSameZone()

bool TEARDROP_MANAGER::areItemsInSameZone ( BOARD_ITEM aPadOrVia,
PCB_TRACK aTrack 
) const
private
Returns
true if the given aViaPad + aTrack is located inside a zone of the same netname

Definition at line 116 of file teardrop_utils.cpp.

References BOARD_ITEM::GetLayer(), BOARD_CONNECTED_ITEM::GetNetCode(), EDA_ITEM::GetPosition(), m_board, pad, PCB_PAD_T, EDA_ITEM::Type(), and BOARD::Zones().

Referenced by UpdateTeardrops().

◆ buildTrackCaches()

void TEARDROP_MANAGER::buildTrackCaches ( )
private

◆ computeAnchorPoints()

bool TEARDROP_MANAGER::computeAnchorPoints ( const TEARDROP_PARAMETERS aParams,
PCB_LAYER_ID  aLayer,
BOARD_ITEM aItem,
const VECTOR2I aPos,
std::vector< VECTOR2I > &  aPts 
) const
private

Compute the 2 points on pad/via of the teardrop shape.

Returns
false if these 2 points are not found
Parameters
aLayeris the layer for the teardrop
aItemis the via/pad/track used to build the teardrop
aPosis the via/pad position, or track start or end teardrop height = aViaPad size * aHeightRatio
aPtsis the buffer that contains initial and final teardrop polygonal shape in aPts: A and B ( aPts[0] and aPts[1] ) are points on the track C and E ( aPts[2] and aPts[4] ) are points on the aViaPad D ( aPts[3] ) is midpoint behind the aViaPad centre m_heightRatio is the factor to calculate the aViaPad teardrop size

Definition at line 318 of file teardrop_utils.cpp.

References SHAPE_POLY_SET::Append(), ARC_LOW_DEF, SHAPE_LINE_CHAIN::Area(), SHAPE_POLY_SET::BooleanIntersection(), BuildConvexHull(), SHAPE_LINE_CHAIN::CPoints(), ERROR_INSIDE, VECTOR2< T >::EuclideanNorm(), GetWidth(), IsRound(), KiROUND(), TEARDROP_PARAMETERS::m_BestWidthRatio, TEARDROP_PARAMETERS::m_TdMaxWidth, SHAPE_POLY_SET::Move(), SHAPE_POLY_SET::NewOutline(), next(), SHAPE_POLY_SET::Outline(), pad, PCB_PAD_T, SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::Rotate(), TransformCircleToPolygon(), and EDA_ITEM::Type().

Referenced by computeTeardropPolygon().

◆ computeCurvedForRectShape()

void TEARDROP_MANAGER::computeCurvedForRectShape ( const TEARDROP_PARAMETERS aParams,
std::vector< VECTOR2I > &  aPoly,
int  aTdWidth,
int  aTrackHalfWidth,
std::vector< VECTOR2I > &  aPts,
const VECTOR2I aIntersection 
) const
private

Compute the curve part points for teardrops connected to a rectangular/polygonal shape The Bezier curve control points are not optimized for a special shape, so use computeCurvedForRoundShape() for round shapes for better result.

Definition at line 274 of file teardrop_utils.cpp.

References ARC_HIGH_DEF, VECTOR2< T >::EuclideanNorm(), BEZIER_POLY::GetPoly(), and VECTOR2< T >::Resize().

Referenced by computeTeardropPolygon().

◆ computeCurvedForRoundShape()

void TEARDROP_MANAGER::computeCurvedForRoundShape ( const TEARDROP_PARAMETERS aParams,
std::vector< VECTOR2I > &  aPoly,
PCB_LAYER_ID  aLayer,
int  aTrackHalfWidth,
const VECTOR2D aTrackDir,
BOARD_ITEM aOther,
const VECTOR2I aOtherPos,
std::vector< VECTOR2I > &  aPts 
) const
private

Compute the curve part points for teardrops connected to a round shape The Bezier curve control points are optimized for a round pad/via shape, and do not give a good curve shape for other pad shapes use m_m_heightRatio.

Definition at line 213 of file teardrop_utils.cpp.

References ARC_HIGH_DEF, BEZIER_POLY::GetPoly(), GetWidth(), KiROUND(), SEG::Length(), TEARDROP_PARAMETERS::m_BestWidthRatio, TEARDROP_PARAMETERS::m_TdMaxWidth, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by computeTeardropPolygon().

◆ computeTeardropPolygon()

bool TEARDROP_MANAGER::computeTeardropPolygon ( const TEARDROP_PARAMETERS aParams,
std::vector< VECTOR2I > &  aCorners,
PCB_TRACK aTrack,
BOARD_ITEM aOther,
const VECTOR2I aOtherPos 
) const
private

◆ createTeardrop()

ZONE * TEARDROP_MANAGER::createTeardrop ( TEARDROP_VARIANT  aTeardropVariant,
std::vector< VECTOR2I > &  aPoints,
PCB_TRACK aTrack 
) const
private

◆ DeleteTrackToTrackTeardrops()

void TEARDROP_MANAGER::DeleteTrackToTrackTeardrops ( BOARD_COMMIT aCommit)

◆ findAnchorPointsOnTrack()

bool TEARDROP_MANAGER::findAnchorPointsOnTrack ( const TEARDROP_PARAMETERS aParams,
VECTOR2I aStartPoint,
VECTOR2I aEndPoint,
VECTOR2I aIntersection,
PCB_TRACK *&  aTrack,
BOARD_ITEM aOther,
const VECTOR2I aOtherPos,
int *  aEffectiveTeardropLen 
) const
private
Returns
true if a point on a track can be found as anchor point of a teardrop
Parameters
aStartPointis the start point of the track found (always inside the teardrop)
aEndPointis the start point of the track found (always outside the teardrop)
aIntersectionis the point where the track's centerline meets the pad/via edge
aTrackis the track connected to the pad/via used to search a anchor point this reference can be modified if a connected track to the initial track is selected
aOtheris the via/pad/track used to build the teardrop
aOtherPosis the via/pad position, or track start or end
aEffectiveTeardropLenis the actual teardrop length, that can be smaller than expected if the connected track length is too small
aFollowTracks= true to use a connected track to aTrack if aTrack is too small
aTrackLookupListis the list of tracks to explore if aFollowTracks = true m_lengthRatio is the length of teardrop (ratio pad/via size/teardrop len)

Definition at line 499 of file teardrop_utils.cpp.

References ARC_LOW_DEF, SHAPE_ARC::ConvertToPolyline(), SHAPE_LINE_CHAIN::CPoint(), ERROR_INSIDE, findTouchingTrack(), PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayer(), PCB_TRACK::GetLength(), PCB_ARC::GetMid(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), GetWidth(), EDA_ITEM::HitTest(), SHAPE_LINE_CHAIN::Intersect(), IsRound(), KiROUND(), TEARDROP_PARAMETERS::m_AllowUseTwoTracks, TEARDROP_PARAMETERS::m_BestLengthRatio, TEARDROP_PARAMETERS::m_TdMaxLen, SHAPE_POLY_SET::Outline(), PCB_ARC_T, PCB_PAD_T, SHAPE_LINE_CHAIN::PointCount(), SHAPE_ARC::Reverse(), SHAPE_LINE_CHAIN::SetClosed(), STARTPOINT, TransformCircleToPolygon(), and EDA_ITEM::Type().

Referenced by computeTeardropPolygon().

◆ findTouchingTrack()

PCB_TRACK * TEARDROP_MANAGER::findTouchingTrack ( EDA_ITEM_FLAGS aMatchType,
PCB_TRACK aTrackRef,
const VECTOR2I aEndPoint 
) const
private

Find a track connected to the end of another track.

Returns
a reference to the touching track (or nullptr)
Parameters
aMatchTypereturns the end point id 0, STARTPOINT, ENDPOINT
aTrackRefis the reference track
aEndpointis the coordinate to test
tracksRTreeis an RTree containing the available tracks

Definition at line 153 of file teardrop_utils.cpp.

References BOARD_ITEM::GetLayer(), m_tracksRTree, and DRC_RTREE::QueryColliding().

Referenced by findAnchorPointsOnTrack().

◆ GetWidth()

◆ IsRound()

◆ RemoveTeardrops()

void TEARDROP_MANAGER::RemoveTeardrops ( BOARD_COMMIT aCommit,
const std::vector< BOARD_ITEM * > *  dirtyPadsAndVias,
const std::set< PCB_TRACK * > *  dirtyTracks 
)

Remove teardrops connected to any dirty pads, vias or tracks.

They need to be removed before being rebuilt.

NB: this must be called BEFORE the connectivity is updated for the change in question.

Definition at line 99 of file teardrop.cpp.

References alg::contains(), BOARD::GetConnectivity(), m_board, pad, BOARD::Remove(), COMMIT::Removed(), via, and BOARD::Zones().

Referenced by BOARD_COMMIT::Push().

◆ setTeardropPriorities()

void TEARDROP_MANAGER::setTeardropPriorities ( )
private

Set priority of created teardrops.

smaller have bigger priority

Definition at line 304 of file teardrop.cpp.

References ZONE::GetFirstLayer(), ZONE::GetOutlineArea(), m_createdTdList, and MAGIC_TEARDROP_ZONE_ID.

Referenced by UpdateTeardrops().

◆ UpdateTeardrops()

Friends And Related Function Documentation

◆ TEARDROP_PARAMETERS

friend class TEARDROP_PARAMETERS
friend

Definition at line 98 of file teardrop.h.

Member Data Documentation

◆ m_board

◆ m_createdTdList

std::vector<ZONE*> TEARDROP_MANAGER::m_createdTdList
private

Definition at line 246 of file teardrop.h.

Referenced by AddTeardropsOnTracks(), setTeardropPriorities(), and UpdateTeardrops().

◆ m_prmsList

TEARDROP_PARAMETERS_LIST* TEARDROP_MANAGER::m_prmsList
private

Definition at line 242 of file teardrop.h.

Referenced by AddTeardropsOnTracks(), TEARDROP_MANAGER(), and UpdateTeardrops().

◆ m_tolerance

int TEARDROP_MANAGER::m_tolerance
private

Definition at line 238 of file teardrop.h.

Referenced by AddTeardropsOnTracks(), TEARDROP_MANAGER(), and UpdateTeardrops().

◆ m_toolManager

TOOL_MANAGER* TEARDROP_MANAGER::m_toolManager
private

Definition at line 241 of file teardrop.h.

◆ m_trackLookupList

TRACK_BUFFER TEARDROP_MANAGER::m_trackLookupList
private

Definition at line 245 of file teardrop.h.

Referenced by AddTeardropsOnTracks(), and buildTrackCaches().

◆ m_tracksRTree

DRC_RTREE TEARDROP_MANAGER::m_tracksRTree
private

Definition at line 244 of file teardrop.h.

Referenced by buildTrackCaches(), and findTouchingTrack().


The documentation for this class was generated from the following files: