Refine track dangling test.

Turns out Clean Up Tracks and Vias wants a different answer from DRC.

(cherry picked from commit fb40c202a1)
This commit is contained in:
Jeff Young 2023-06-17 22:56:57 +01:00
parent 0df1ec8765
commit f6d1baa50a
4 changed files with 16 additions and 9 deletions

View File

@ -710,7 +710,8 @@ static int getMinDist( BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aPoint )
}
bool CONNECTIVITY_DATA::TestTrackEndpointDangling( PCB_TRACK* aTrack, VECTOR2I* aPos ) const
bool CONNECTIVITY_DATA::TestTrackEndpointDangling( PCB_TRACK* aTrack, bool aIgnoreTracksInPads,
VECTOR2I* aPos ) const
{
const std::list<CN_ITEM*>& items = GetConnectivityAlgo()->ItemEntry( aTrack ).GetItems();
@ -770,12 +771,17 @@ bool CONNECTIVITY_DATA::TestTrackEndpointDangling( PCB_TRACK* aTrack, VECTOR2I*
if( hitStart && hitEnd )
{
if( zone || item->Type() == PCB_PAD_T || item->Type() == PCB_VIA_T )
if( zone )
{
// Both start and end in a zone or under a pad: track may be redundant, but
// it's not dangling
// Both start and end in a zone: track may be redundant, but it's not dangling
return false;
}
else if( item->Type() == PCB_PAD_T || item->Type() == PCB_VIA_T )
{
// Both start and end are under a pad: see what the caller wants us to do
if( aIgnoreTracksInPads )
return false;
}
if( getMinDist( item, aTrack->GetStart() ) < getMinDist( item, aTrack->GetEnd() ) )
start_count++;

View File

@ -210,7 +210,8 @@ public:
void RunOnUnconnectedEdges( std::function<bool( CN_EDGE& )> aFunc );
bool TestTrackEndpointDangling( PCB_TRACK* aTrack, VECTOR2I* aPos = nullptr ) const;
bool TestTrackEndpointDangling( PCB_TRACK* aTrack, bool aIgnoreTracksInPads,
VECTOR2I* aPos = nullptr ) const;
/**
* Function ClearLocalRatsnest()

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2022 KiCad Developers.
* Copyright (C) 2004-2023 KiCad Developers.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -100,7 +100,7 @@ bool DRC_TEST_PROVIDER_CONNECTIVITY::Run()
int code = track->Type() == PCB_VIA_T ? DRCE_DANGLING_VIA : DRCE_DANGLING_TRACK;
VECTOR2I pos;
if( connectivity->TestTrackEndpointDangling( track, &pos ) )
if( connectivity->TestTrackEndpointDangling( track, true, &pos ) )
{
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( code );
drcItem->SetItems( track );

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2004-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -273,7 +273,7 @@ bool TRACKS_CLEANER::deleteDanglingTracks( bool aTrack, bool aVia )
continue;
// Test if a track (or a via) endpoint is not connected to another track or zone.
if( m_brd->GetConnectivity()->TestTrackEndpointDangling( track ) )
if( m_brd->GetConnectivity()->TestTrackEndpointDangling( track, false ) )
{
std::shared_ptr<CLEANUP_ITEM> item;