Consider tracks and vias together

Dangling tracks and vias affect each other and need to be considered at
the same time in order to fully remove the dangling segments
This commit is contained in:
Seth Hillbrand 2021-01-08 08:36:18 -08:00
parent 93d203aef7
commit 1e96374715
2 changed files with 12 additions and 9 deletions

View File

@ -66,11 +66,7 @@ void TRACKS_CLEANER::CleanupBoard( bool aDryRun, std::vector<std::shared_ptr<CLE
if( aDeleteTracksinPad )
deleteTracksInPads();
if( aDeleteUnconnected )
has_deleted = deleteDanglingTracks( false );
if( aDeleteDanglingVias )
has_deleted |= deleteDanglingTracks( true );
has_deleted = deleteDanglingTracks( aDeleteUnconnected, aDeleteDanglingVias );
if( has_deleted && aMergeSegments )
cleanup( false, false, false, true );
@ -160,11 +156,14 @@ bool TRACKS_CLEANER::testTrackEndpointIsNode( TRACK* aTrack, bool aTstStart )
}
bool TRACKS_CLEANER::deleteDanglingTracks( bool aVia )
bool TRACKS_CLEANER::deleteDanglingTracks( bool aTrack, bool aVia )
{
bool item_erased = false;
bool modified = false;
if( !aTrack && !aVia )
return false;
do // Iterate when at least one track is deleted
{
item_erased = false;
@ -176,7 +175,10 @@ bool TRACKS_CLEANER::deleteDanglingTracks( bool aVia )
for( TRACK* track : temp_tracks )
{
if( ( aVia && track->Type() != PCB_VIA_T ) || ( !aVia && track->Type() == PCB_VIA_T ) )
if( !aVia && track->Type() == PCB_VIA_T )
continue;
if( !aTrack && ( track->Type() == PCB_TRACE_T || track->Type() == PCB_ARC_T ) )
continue;
// Test if a track (or a via) endpoint is not connected to another track or zone.

View File

@ -59,10 +59,11 @@ private:
/**
* Removes tracks or vias only connected on one end
* @param aVia if true, clean vias, if false clean tracks
* @param aTrack if true, clean dangling tracks
* @param aVia if true, clean dangling vias
* @return true if any items were deleted
*/
bool deleteDanglingTracks( bool aVia );
bool deleteDanglingTracks( bool aTrack, bool aVia );
void deleteTracksInPads();