KiCad PCB EDA Suite
|
#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 | testMergeCollinearSegments (PCB_TRACK *aSeg1, PCB_TRACK *aSeg2, PCB_TRACK *aDummySeg=nullptr) |
helper function test if 2 segments are colinear. | |
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 | |
BOARD * | m_brd |
BOARD_COMMIT & | m_commit |
bool | m_dryRun |
std::vector< std::shared_ptr< CLEANUP_ITEM > > * | m_itemsList |
REPORTER * | m_reporter |
std::map< PCB_TRACK *, std::vector< BOARD_CONNECTED_ITEM * > > | m_connectedItemsCache |
std::function< bool(BOARD_CONNECTED_ITEM *aItem)> | m_filter |
Definition at line 36 of file tracks_cleaner.h.
TRACKS_CLEANER::TRACKS_CLEANER | ( | BOARD * | aPcb, |
BOARD_COMMIT & | aCommit | ||
) |
Definition at line 42 of file tracks_cleaner.cpp.
|
private |
Geometry-based cleanup: duplicate items, null items, colinear items.
Definition at line 370 of file tracks_cleaner.cpp.
References LSET::AllCuMask(), CLEANUP_REDUNDANT_VIA, CLEANUP_ZERO_LENGTH_TRACK, filterItem(), BOARD::GetConnectivity(), PCB_VIA::GetLayerSet(), PCB_VIA::GetPosition(), PCB_VIA::GetViaType(), DRC_RTREE::Insert(), IS_DELETED, m_brd, m_itemsList, pad, PCB_TRACE_T, PCB_VIA_T, DRC_RTREE::QueryColliding(), SKIP_STRUCT, BOARD::Tracks(), and via.
Referenced by 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.
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 |
aReporter | is a REPORTER to print activity and info |
Definition at line 59 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().
|
private |
Removes tracks or vias only connected on one end.
aTrack | if true, clean dangling tracks |
aVia | if true, clean dangling vias |
Definition at line 263 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().
|
private |
Definition at line 323 of file tracks_cleaner.cpp.
References ARC_HIGH_DEF, SHAPE_POLY_SET::BooleanSubtract(), CLEANUP_TRACK_IN_PAD, ERROR_INSIDE, filterItem(), BOARD::GetConnectivity(), IS_DELETED, SHAPE_POLY_SET::IsEmpty(), m_brd, m_dryRun, m_itemsList, pad, PCB_VIA_T, removeItems(), and BOARD::Tracks().
Referenced by CleanupBoard().
|
private |
Definition at line 168 of file tracks_cleaner.cpp.
References m_filter.
Referenced by cleanup(), deleteDanglingTracks(), deleteTracksInPads(), and removeShortingTrackSegments().
|
private |
Definition at line 613 of file tracks_cleaner.cpp.
References connectedTypes, BOARD::GetConnectivity(), m_brd, m_connectedItemsCache, PCB_ARC_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, and PCB_ZONE_T.
Referenced by testMergeCollinearSegments().
helper function merge aTrackRef and aCandidate, when possible, i.e.
when they are colinear, same width, and obviously same layer
aSeg1 | is the reference |
aSeg2 | is the candidate, and after merging, the removed segment |
Definition at line 755 of file tracks_cleaner.cpp.
References CLEANUP_MERGE_TRACKS, BOARD::GetConnectivity(), BOARD_ITEM::GetParentGroup(), group, IS_DELETED, m_brd, m_commit, m_dryRun, m_itemsList, COMMIT::Modify(), BOARD::Remove(), COMMIT::Removed(), EDA_ITEM::SetFlags(), BOARD_ITEM::SetParentGroup(), and testMergeCollinearSegments().
|
private |
Definition at line 790 of file tracks_cleaner.cpp.
References m_brd, m_commit, BOARD::Remove(), and COMMIT::Removed().
Referenced by deleteTracksInPads(), and removeShortingTrackSegments().
|
private |
Definition at line 177 of file tracks_cleaner.cpp.
References CLEANUP_SHORTING_TRACK, CLEANUP_SHORTING_VIA, filterItem(), BOARD::GetConnectivity(), m_brd, m_dryRun, m_itemsList, PCB_VIA_T, removeItems(), and BOARD::Tracks().
Referenced by CleanupBoard().
|
inline |
Definition at line 59 of file tracks_cleaner.h.
References m_filter.
Referenced by DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup().
|
private |
helper function test if 2 segments are colinear.
Does not modify the connectivity
aSeg1 | is the reference |
aSeg2 | is the candidate |
Definition at line 630 of file tracks_cleaner.cpp.
References getConnectedItems(), PCB_TRACK::GetEnd(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), BOARD_ITEM::IsLocked(), PCB_TRACK::IsPointOnEnds(), PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, PCB_TRACK::SetEnd(), BOARD_ITEM::SetParentGroup(), PCB_TRACK::SetStart(), testTrackEndpointIsNode(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by mergeCollinearSegments().
|
private |
aTrack | is the track to test. |
aTstStart | = true ot test the start point of the track or false for end point |
Definition at line 230 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 testMergeCollinearSegments().
|
private |
Definition at line 120 of file tracks_cleaner.h.
Referenced by cleanup(), deleteDanglingTracks(), deleteTracksInPads(), getConnectedItems(), mergeCollinearSegments(), removeItems(), removeShortingTrackSegments(), and testTrackEndpointIsNode().
|
private |
Definition at line 121 of file tracks_cleaner.h.
Referenced by deleteDanglingTracks(), mergeCollinearSegments(), and removeItems().
|
private |
Definition at line 127 of file tracks_cleaner.h.
Referenced by getConnectedItems().
|
private |
Definition at line 122 of file tracks_cleaner.h.
Referenced by CleanupBoard(), deleteDanglingTracks(), deleteTracksInPads(), mergeCollinearSegments(), and removeShortingTrackSegments().
|
private |
Definition at line 129 of file tracks_cleaner.h.
Referenced by filterItem(), and SetFilter().
|
private |
Definition at line 123 of file tracks_cleaner.h.
Referenced by cleanup(), CleanupBoard(), deleteDanglingTracks(), deleteTracksInPads(), mergeCollinearSegments(), and removeShortingTrackSegments().
|
private |
Definition at line 124 of file tracks_cleaner.h.
Referenced by CleanupBoard().