Pcbnew, connectivity: fix incorrect detection of dangling track ends when a end is inside a zone.

This end was not detected as connected by the IsDangling method.
Fix incorrect cleaning of dangling tracks in track cleaner.
Remove also a dead code.
The merge co-linear track segments is still full bugged in track cleaner.
This commit is contained in:
jean-pierre charras 2019-06-28 15:14:17 +02:00
parent 3135334c0c
commit 71aafb6eb3
3 changed files with 22 additions and 38 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2016-2018 CERN
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
@ -265,12 +265,20 @@ bool CN_ANCHOR::IsDangling() const
if( m_item->AnchorCount() == 1 )
return connected_count < minimal_count;
// Only items with multiple anchors might have additional items connected that we
// should ignore for this calculation.
// Items with multiple anchors have usually items connected to each anchor.
// We want only the item count of this anchor point
connected_count = 0;
for( auto item : m_item->ConnectedItems() )
{
if( !item->Parent()->HitTest( wxPoint( Pos().x, Pos().y ) ) )
connected_count--;
if( item->Parent()->Type() == PCB_ZONE_AREA_T )
{
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item->Parent() );
if( zone->HitTestFilledArea( wxPoint( Pos().x, Pos().y ) ) )
connected_count++;
}
else if( item->Parent()->HitTest( wxPoint( Pos().x, Pos().y ) ) )
connected_count++;
}
return connected_count < minimal_count;

View File

@ -45,7 +45,7 @@ int GLOBAL_EDIT_TOOL::CleanupTracksAndVias( const TOOL_EVENT& aEvent )
{
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
DIALOG_CLEANUP_TRACKS_AND_VIAS dlg( editFrame );
dlg.ShowModal();
return 0;
}
@ -223,21 +223,6 @@ bool TRACKS_CLEANER::cleanupVias()
}
bool TRACKS_CLEANER::testTrackHasPad( const TRACK* aTrack ) const
{
auto connectivity = m_brd->GetConnectivity();
// Mark track if connected to pads
for( auto pad : connectivity->GetConnectedPads( aTrack ) )
{
if( pad->HitTest( aTrack->GetStart() ) || pad->HitTest( aTrack->GetEnd() ) )
return true;
}
return false;
}
bool TRACKS_CLEANER::testTrackEndpointDangling( TRACK* aTrack )
{
auto connectivity = m_brd->GetConnectivity();
@ -275,19 +260,16 @@ bool TRACKS_CLEANER::deleteDanglingTracks()
do // Iterate when at least one track is deleted
{
item_erased = false;
// Ensure the connectivity is up to date, especially after removind a dangling segment
m_brd->BuildConnectivity();
for( TRACK* track : m_brd->Tracks() )
{
bool flag_erase = false; // Start without a good reason to erase it
if( track->Type() != PCB_TRACE_T )
continue;
// if a track endpoint is not connected to a pad, test if
// the endpoint is connected to another track or to a zone.
if( !testTrackHasPad( track ) )
flag_erase |= testTrackEndpointDangling( track );
// Tst if a track (or a via) endpoint is not connected to another track or to a zone.
if( testTrackEndpointDangling( track ) )
flag_erase = true;
if( flag_erase )
{
@ -307,11 +289,12 @@ bool TRACKS_CLEANER::deleteDanglingTracks()
* now perhaps is not connected and should be deleted */
item_erased = true;
modified = true;
break;
}
// Fix me: In dry run we should disable the track to erase and retry with this disabled track
// However the connectivity algo does not handle disabled items.
}
}
} while( item_erased );
} while( item_erased ); // A segment was erased: test for some new dangling segments
return modified;
}

View File

@ -56,13 +56,6 @@ private:
*/
bool removeBadTrackSegments();
/**
* Checks whether the track is connected to a pad
* @param aTrack pointer to the track
* @return true if the track has a pad
*/
bool testTrackHasPad( const TRACK* aTrack ) const;
/**
* Removes redundant vias like vias at same location
* or on pad through