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

#include <tracks_cleaner.h>

Public Member Functions

 TRACKS_CLEANER (BOARD *aPcb, BOARD_COMMIT &aCommit)
 
void CleanupBoard (bool aDryRun, std::vector< std::shared_ptr< CLEANUP_ITEM > > *aItemsList, bool aCleanVias, bool aRemoveMisConnected, bool aMergeSegments, bool aDeleteUnconnected, bool aDeleteTracksinPad, bool aDeleteDanglingVias, REPORTER *aReporter=nullptr)
 the cleanup function.
 
void SetFilter (const std::function< bool(BOARD_CONNECTED_ITEM *aItem)> &aFilter)
 

Private Member Functions

bool filterItem (BOARD_CONNECTED_ITEM *aItem)
 
void removeShortingTrackSegments ()
 
bool deleteDanglingTracks (bool aTrack, bool aVia)
 Removes tracks or vias only connected on one end.
 
void deleteTracksInPads ()
 
void cleanup (bool aDeleteDuplicateVias, bool aDeleteNullSegments, bool aDeleteDuplicateSegments, bool aMergeSegments)
 Geometry-based cleanup: duplicate items, null items, colinear items.
 
bool mergeCollinearSegments (PCB_TRACK *aSeg1, PCB_TRACK *aSeg2)
 helper function merge aTrackRef and aCandidate, when possible, i.e.
 
bool testTrackEndpointIsNode (PCB_TRACK *aTrack, bool aTstStart)
 
void removeItems (std::set< BOARD_ITEM * > &aItems)
 
const std::vector< BOARD_CONNECTED_ITEM * > & getConnectedItems (PCB_TRACK *aTrack)
 

Private Attributes

BOARDm_brd
 
BOARD_COMMITm_commit
 
bool m_dryRun
 
std::vector< std::shared_ptr< CLEANUP_ITEM > > * m_itemsList
 
REPORTERm_reporter
 
std::map< PCB_TRACK *, std::vector< BOARD_CONNECTED_ITEM * > > m_connectedItemsCache
 
std::function< bool(BOARD_CONNECTED_ITEM *aItem)> m_filter
 

Detailed Description

Definition at line 36 of file tracks_cleaner.h.

Constructor & Destructor Documentation

◆ TRACKS_CLEANER()

TRACKS_CLEANER::TRACKS_CLEANER ( BOARD aPcb,
BOARD_COMMIT aCommit 
)

Definition at line 38 of file tracks_cleaner.cpp.

Member Function Documentation

◆ cleanup()

void TRACKS_CLEANER::cleanup ( bool  aDeleteDuplicateVias,
bool  aDeleteNullSegments,
bool  aDeleteDuplicateSegments,
bool  aMergeSegments 
)
private

◆ CleanupBoard()

void TRACKS_CLEANER::CleanupBoard ( bool  aDryRun,
std::vector< std::shared_ptr< CLEANUP_ITEM > > *  aItemsList,
bool  aCleanVias,
bool  aRemoveMisConnected,
bool  aMergeSegments,
bool  aDeleteUnconnected,
bool  aDeleteTracksinPad,
bool  aDeleteDanglingVias,
REPORTER aReporter = nullptr 
)

the cleanup function.

Parameters
aDryRun= true to build changes list, false to modify the board
aItemsList= list of modified items
aCleanVias= true to remove superimposed vias
aRemoveMisConnected= true to remove segments connecting 2 different nets (short circuits)
aMergeSegments= true to merge collinear segmenst and remove 0 len segm
aDeleteUnconnected= true to remove dangling tracks
aDeleteTracksinPad= true to remove tracks fully inside pads
aDeleteDanglingVias= true to remove a via that is only connected to a single layer
aReporteris a REPORTER to print activity and info

Definition at line 55 of file tracks_cleaner.cpp.

References _, cleanup(), deleteDanglingTracks(), deleteTracksInPads(), m_dryRun, m_itemsList, m_reporter, removeShortingTrackSegments(), and REPORTER::Report().

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ deleteDanglingTracks()

bool TRACKS_CLEANER::deleteDanglingTracks ( bool  aTrack,
bool  aVia 
)
private

Removes tracks or vias only connected on one end.

Parameters
aTrackif true, clean dangling tracks
aViaif true, clean dangling vias
Returns
true if any items were deleted

Definition at line 259 of file tracks_cleaner.cpp.

References BOARD::BuildConnectivity(), CLEANUP_DANGLING_TRACK, CLEANUP_DANGLING_VIA, filterItem(), BOARD::GetConnectivity(), IS_DELETED, m_brd, m_commit, m_dryRun, m_itemsList, PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, BOARD::Remove(), COMMIT::Removed(), and BOARD::Tracks().

Referenced by CleanupBoard().

◆ deleteTracksInPads()

◆ filterItem()

bool TRACKS_CLEANER::filterItem ( BOARD_CONNECTED_ITEM aItem)
private

◆ getConnectedItems()

const std::vector< BOARD_CONNECTED_ITEM * > & TRACKS_CLEANER::getConnectedItems ( PCB_TRACK aTrack)
private

◆ mergeCollinearSegments()

bool TRACKS_CLEANER::mergeCollinearSegments ( PCB_TRACK aSeg1,
PCB_TRACK aSeg2 
)
private

helper function merge aTrackRef and aCandidate, when possible, i.e.

when they are colinear, same width, and obviously same layer

Returns
true if the segments are merged, false if not
Parameters
aSeg1is the reference
aSeg2is the candidate, and after merging, the removed segment

Definition at line 591 of file tracks_cleaner.cpp.

References CLEANUP_MERGE_TRACKS, getConnectedItems(), BOARD::GetConnectivity(), PCB_TRACK::GetEnd(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), IS_DELETED, BOARD_ITEM::IsLocked(), PCB_TRACK::IsPointOnEnds(), m_brd, m_commit, m_dryRun, m_itemsList, COMMIT::Modify(), PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, BOARD::Remove(), COMMIT::Removed(), PCB_TRACK::SetEnd(), EDA_ITEM::SetFlags(), BOARD_ITEM::SetParentGroup(), PCB_TRACK::SetStart(), testTrackEndpointIsNode(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ removeItems()

void TRACKS_CLEANER::removeItems ( std::set< BOARD_ITEM * > &  aItems)
private

◆ removeShortingTrackSegments()

void TRACKS_CLEANER::removeShortingTrackSegments ( )
private

◆ SetFilter()

void TRACKS_CLEANER::SetFilter ( const std::function< bool(BOARD_CONNECTED_ITEM *aItem)> &  aFilter)
inline

Definition at line 59 of file tracks_cleaner.h.

References m_filter.

Referenced by DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup().

◆ testTrackEndpointIsNode()

bool TRACKS_CLEANER::testTrackEndpointIsNode ( PCB_TRACK aTrack,
bool  aTstStart 
)
private
Returns
true if a track end position is a node, i.e. a end connected to more than one item.
Parameters
aTrackis the track to test.
aTstStart= true ot test the start point of the track or false for end point

Definition at line 226 of file tracks_cleaner.cpp.

References anchor, CN_ITEM::Anchors(), BOARD::GetConnectivity(), PCB_TRACK::GetEnd(), PCB_TRACK::GetStart(), m_brd, and CN_ITEM::Valid().

Referenced by mergeCollinearSegments().

Member Data Documentation

◆ m_brd

◆ m_commit

BOARD_COMMIT& TRACKS_CLEANER::m_commit
private

Definition at line 112 of file tracks_cleaner.h.

Referenced by deleteDanglingTracks(), mergeCollinearSegments(), and removeItems().

◆ m_connectedItemsCache

std::map<PCB_TRACK*, std::vector<BOARD_CONNECTED_ITEM*> > TRACKS_CLEANER::m_connectedItemsCache
private

Definition at line 118 of file tracks_cleaner.h.

Referenced by getConnectedItems().

◆ m_dryRun

bool TRACKS_CLEANER::m_dryRun
private

◆ m_filter

std::function<bool( BOARD_CONNECTED_ITEM* aItem )> TRACKS_CLEANER::m_filter
private

Definition at line 120 of file tracks_cleaner.h.

Referenced by filterItem(), and SetFilter().

◆ m_itemsList

std::vector<std::shared_ptr<CLEANUP_ITEM> >* TRACKS_CLEANER::m_itemsList
private

◆ m_reporter

REPORTER* TRACKS_CLEANER::m_reporter
private

Definition at line 115 of file tracks_cleaner.h.

Referenced by CleanupBoard().


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