2017-03-22 13:43:10 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
2018-02-04 13:34:17 +00:00
|
|
|
* Copyright (C) 2016-2018 CERN
|
2020-08-18 14:17:16 +00:00
|
|
|
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
2017-03-22 13:43:10 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2018-10-12 06:17:15 +00:00
|
|
|
#include <connectivity/connectivity_algo.h>
|
2017-11-23 16:20:27 +00:00
|
|
|
#include <widgets/progress_reporter.h>
|
2018-05-21 00:06:01 +00:00
|
|
|
#include <geometry/geometry_utils.h>
|
2019-05-25 01:55:40 +00:00
|
|
|
#include <board_commit.h>
|
2017-11-23 16:20:27 +00:00
|
|
|
|
|
|
|
#include <thread>
|
|
|
|
#include <mutex>
|
2018-10-27 01:00:43 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <future>
|
2018-05-19 00:08:52 +00:00
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
#ifdef PROFILE
|
|
|
|
#include <profile.h>
|
|
|
|
#endif
|
|
|
|
|
2018-02-09 13:14:32 +00:00
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
bool CN_CONNECTIVITY_ALGO::Remove( BOARD_ITEM* aItem )
|
|
|
|
{
|
2017-06-23 11:56:28 +00:00
|
|
|
markItemNetAsDirty( aItem );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case PCB_MODULE_T:
|
2017-06-23 11:56:28 +00:00
|
|
|
for( auto pad : static_cast<MODULE*>( aItem ) -> Pads() )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2020-08-07 20:37:00 +00:00
|
|
|
m_itemMap[pad].MarkItemsAsInvalid();
|
|
|
|
m_itemMap.erase( pad );
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
m_itemList.SetDirty( true );
|
2017-03-22 13:43:10 +00:00
|
|
|
break;
|
2017-06-23 11:56:28 +00:00
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
case PCB_PAD_T:
|
2020-08-07 20:37:00 +00:00
|
|
|
m_itemMap[aItem].MarkItemsAsInvalid();
|
|
|
|
m_itemMap.erase( aItem );
|
2018-05-21 00:06:01 +00:00
|
|
|
m_itemList.SetDirty( true );
|
2017-03-22 13:43:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_TRACE_T:
|
2019-05-17 00:13:21 +00:00
|
|
|
case PCB_ARC_T:
|
2020-08-07 20:37:00 +00:00
|
|
|
m_itemMap[aItem].MarkItemsAsInvalid();
|
|
|
|
m_itemMap.erase( aItem );
|
2018-05-21 00:06:01 +00:00
|
|
|
m_itemList.SetDirty( true );
|
2017-03-22 13:43:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_VIA_T:
|
2020-08-07 20:37:00 +00:00
|
|
|
m_itemMap[aItem].MarkItemsAsInvalid();
|
|
|
|
m_itemMap.erase( aItem );
|
2018-05-21 00:06:01 +00:00
|
|
|
m_itemList.SetDirty( true );
|
2017-03-22 13:43:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_ZONE_AREA_T:
|
|
|
|
{
|
2020-08-07 20:37:00 +00:00
|
|
|
m_itemMap[aItem].MarkItemsAsInvalid();
|
|
|
|
m_itemMap.erase ( aItem );
|
2018-07-06 21:55:25 +00:00
|
|
|
m_itemList.SetDirty( true );
|
2017-03-22 13:43:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-06-23 11:56:28 +00:00
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
default:
|
2017-06-23 11:56:28 +00:00
|
|
|
return false;
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
// Once we delete an item, it may connect between lists, so mark both as potentially invalid
|
|
|
|
m_itemList.SetHasInvalid( true );
|
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
|
|
|
|
void CN_CONNECTIVITY_ALGO::markItemNetAsDirty( const BOARD_ITEM* aItem )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2017-06-23 11:56:28 +00:00
|
|
|
if( aItem->IsConnected() )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2017-06-23 11:56:28 +00:00
|
|
|
auto citem = static_cast<const BOARD_CONNECTED_ITEM*>( aItem );
|
2017-07-01 21:54:17 +00:00
|
|
|
MarkNetAsDirty( citem->GetNetCode() );
|
2017-06-23 11:56:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( aItem->Type() == PCB_MODULE_T )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2017-06-23 11:56:28 +00:00
|
|
|
auto mod = static_cast <const MODULE*>( aItem );
|
|
|
|
|
2019-06-01 23:23:36 +00:00
|
|
|
for( auto pad : mod->Pads() )
|
2017-07-01 21:54:17 +00:00
|
|
|
MarkNetAsDirty( pad->GetNetCode() );
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CN_CONNECTIVITY_ALGO::Add( BOARD_ITEM* aItem )
|
2017-06-23 11:56:28 +00:00
|
|
|
{
|
2019-07-25 11:08:41 +00:00
|
|
|
if( !aItem->IsOnCopperLayer() )
|
2018-07-10 19:22:36 +00:00
|
|
|
return false;
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
markItemNetAsDirty ( aItem );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
2017-07-01 21:54:17 +00:00
|
|
|
case PCB_NETINFO_T:
|
2017-07-02 21:05:23 +00:00
|
|
|
{
|
|
|
|
MarkNetAsDirty( static_cast<NETINFO_ITEM*>( aItem )->GetNet() );
|
|
|
|
break;
|
|
|
|
}
|
2017-06-23 11:56:28 +00:00
|
|
|
case PCB_MODULE_T:
|
|
|
|
for( auto pad : static_cast<MODULE*>( aItem ) -> Pads() )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2017-06-23 11:56:28 +00:00
|
|
|
if( m_itemMap.find( pad ) != m_itemMap.end() )
|
|
|
|
return false;
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
add( m_itemList, pad );
|
2017-06-23 11:56:28 +00:00
|
|
|
}
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
break;
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
case PCB_PAD_T:
|
2020-03-05 08:41:54 +00:00
|
|
|
if( m_itemMap.find ( aItem ) != m_itemMap.end() )
|
2017-06-23 11:56:28 +00:00
|
|
|
return false;
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
add( m_itemList, static_cast<D_PAD*>( aItem ) );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
break;
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
{
|
2020-03-05 08:41:54 +00:00
|
|
|
if( m_itemMap.find( aItem ) != m_itemMap.end() )
|
2017-06-23 11:56:28 +00:00
|
|
|
return false;
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
add( m_itemList, static_cast<TRACK*>( aItem ) );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
case PCB_ARC_T:
|
|
|
|
{
|
2020-03-05 08:41:54 +00:00
|
|
|
if( m_itemMap.find( aItem ) != m_itemMap.end() )
|
2019-05-17 00:13:21 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
add( m_itemList, static_cast<ARC*>( aItem ) );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
case PCB_VIA_T:
|
2020-03-05 08:41:54 +00:00
|
|
|
if( m_itemMap.find( aItem ) != m_itemMap.end() )
|
2017-06-23 11:56:28 +00:00
|
|
|
return false;
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
add( m_itemList, static_cast<VIA*>( aItem ) );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
break;
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
|
|
|
{
|
|
|
|
auto zone = static_cast<ZONE_CONTAINER*>( aItem );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2020-03-05 08:41:54 +00:00
|
|
|
if( m_itemMap.find( aItem ) != m_itemMap.end() )
|
2017-06-23 11:56:28 +00:00
|
|
|
return false;
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
m_itemMap[zone] = ITEM_MAP_ENTRY();
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
|
|
|
for( auto zitem : m_itemList.Add( zone, layer ) )
|
|
|
|
m_itemMap[zone].Link( zitem );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-12-01 15:53:58 +00:00
|
|
|
|
2018-06-26 06:12:11 +00:00
|
|
|
void CN_CONNECTIVITY_ALGO::searchConnections()
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2018-05-15 22:50:59 +00:00
|
|
|
#ifdef PROFILE
|
|
|
|
PROF_COUNTER garbage_collection( "garbage-collection" );
|
|
|
|
#endif
|
2017-06-23 11:56:28 +00:00
|
|
|
std::vector<CN_ITEM*> garbage;
|
|
|
|
garbage.reserve( 1024 );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
m_itemList.RemoveInvalidItems( garbage );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
for( auto item : garbage )
|
2017-03-22 13:43:10 +00:00
|
|
|
delete item;
|
|
|
|
|
|
|
|
#ifdef PROFILE
|
2018-05-15 22:50:59 +00:00
|
|
|
garbage_collection.Show();
|
2017-03-22 13:43:10 +00:00
|
|
|
PROF_COUNTER search_basic( "search-basic" );
|
|
|
|
#endif
|
|
|
|
|
2018-10-05 13:22:20 +00:00
|
|
|
std::vector<CN_ITEM*> dirtyItems;
|
|
|
|
std::copy_if( m_itemList.begin(), m_itemList.end(), std::back_inserter( dirtyItems ),
|
|
|
|
[] ( CN_ITEM* aItem ) { return aItem->Dirty(); } );
|
2018-09-21 12:21:12 +00:00
|
|
|
|
2018-06-26 06:12:11 +00:00
|
|
|
if( m_progressReporter )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2018-10-05 13:22:20 +00:00
|
|
|
m_progressReporter->SetMaxProgress( dirtyItems.size() );
|
2018-09-21 12:21:12 +00:00
|
|
|
m_progressReporter->KeepRefreshing();
|
2018-06-26 06:12:11 +00:00
|
|
|
}
|
|
|
|
|
2018-09-20 02:10:12 +00:00
|
|
|
if( m_itemList.IsDirty() )
|
2018-06-26 06:12:11 +00:00
|
|
|
{
|
2018-10-27 01:00:43 +00:00
|
|
|
size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency(),
|
|
|
|
( dirtyItems.size() + 7 ) / 8 );
|
|
|
|
|
2018-10-05 13:22:20 +00:00
|
|
|
std::atomic<size_t> nextItem( 0 );
|
2018-10-27 01:00:43 +00:00
|
|
|
std::vector<std::future<size_t>> returns( parallelThreadCount );
|
2018-09-20 02:10:12 +00:00
|
|
|
|
2018-10-27 01:00:43 +00:00
|
|
|
auto conn_lambda = [&nextItem, &dirtyItems]
|
|
|
|
( CN_LIST* aItemList, PROGRESS_REPORTER* aReporter) -> size_t
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2018-10-25 11:20:12 +00:00
|
|
|
for( size_t i = nextItem++; i < dirtyItems.size(); i = nextItem++ )
|
2018-05-21 00:06:01 +00:00
|
|
|
{
|
2018-10-25 11:20:12 +00:00
|
|
|
CN_VISITOR visitor( dirtyItems[i] );
|
|
|
|
aItemList->FindNearby( dirtyItems[i], visitor );
|
2018-10-05 13:22:20 +00:00
|
|
|
|
2018-10-25 11:20:12 +00:00
|
|
|
if( aReporter )
|
|
|
|
aReporter->AdvanceProgress();
|
|
|
|
}
|
2018-06-26 06:12:11 +00:00
|
|
|
|
2018-10-27 01:00:43 +00:00
|
|
|
return 1;
|
2018-10-25 11:20:12 +00:00
|
|
|
};
|
2018-09-20 02:10:12 +00:00
|
|
|
|
2018-10-25 11:20:12 +00:00
|
|
|
if( parallelThreadCount <= 1 )
|
|
|
|
conn_lambda( &m_itemList, m_progressReporter );
|
|
|
|
else
|
2018-09-20 02:10:12 +00:00
|
|
|
{
|
2018-10-25 11:20:12 +00:00
|
|
|
for( size_t ii = 0; ii < parallelThreadCount; ++ii )
|
2018-10-27 05:30:06 +00:00
|
|
|
returns[ii] = std::async( std::launch::async, conn_lambda,
|
|
|
|
&m_itemList, m_progressReporter );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2018-10-27 01:00:43 +00:00
|
|
|
for( size_t ii = 0; ii < parallelThreadCount; ++ii )
|
2018-10-25 11:20:12 +00:00
|
|
|
{
|
2018-11-06 04:11:12 +00:00
|
|
|
// Here we balance returns with a 100ms timeout to allow UI updating
|
2018-10-27 01:00:43 +00:00
|
|
|
std::future_status status;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if( m_progressReporter )
|
|
|
|
m_progressReporter->KeepRefreshing();
|
|
|
|
|
2018-11-06 04:11:12 +00:00
|
|
|
status = returns[ii].wait_for( std::chrono::milliseconds( 100 ) );
|
2018-10-27 01:00:43 +00:00
|
|
|
} while( status != std::future_status::ready );
|
2018-10-25 11:20:12 +00:00
|
|
|
}
|
2018-09-20 02:10:12 +00:00
|
|
|
}
|
2018-10-25 11:20:12 +00:00
|
|
|
|
|
|
|
if( m_progressReporter )
|
|
|
|
m_progressReporter->KeepRefreshing();
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
2018-09-20 02:10:12 +00:00
|
|
|
|
|
|
|
#ifdef PROFILE
|
|
|
|
search_basic.Show();
|
2018-06-26 06:12:11 +00:00
|
|
|
#endif
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2018-06-26 06:12:11 +00:00
|
|
|
m_itemList.ClearDirtyFlags();
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUSTER_SEARCH_MODE aMode )
|
|
|
|
{
|
2019-05-17 00:13:21 +00:00
|
|
|
constexpr KICAD_T types[] =
|
|
|
|
{ PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T, PCB_VIA_T, PCB_ZONE_AREA_T, PCB_MODULE_T, EOT };
|
|
|
|
constexpr KICAD_T no_zones[] =
|
|
|
|
{ PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T, PCB_VIA_T, PCB_MODULE_T, EOT };
|
2018-07-06 21:55:25 +00:00
|
|
|
|
|
|
|
if( aMode == CSM_PROPAGATE )
|
|
|
|
return SearchClusters( aMode, no_zones, -1 );
|
|
|
|
else
|
|
|
|
return SearchClusters( aMode, types, -1 );
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
|
|
|
|
const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUSTER_SEARCH_MODE aMode,
|
|
|
|
const KICAD_T aTypes[], int aSingleNet )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
|
|
|
bool withinAnyNet = ( aMode != CSM_PROPAGATE );
|
|
|
|
|
|
|
|
std::deque<CN_ITEM*> Q;
|
2020-07-27 16:33:01 +00:00
|
|
|
std::set<CN_ITEM*> item_set;
|
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
CLUSTERS clusters;
|
|
|
|
|
2018-10-12 12:57:56 +00:00
|
|
|
if( m_itemList.IsDirty() )
|
2018-06-26 06:12:11 +00:00
|
|
|
searchConnections();
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2020-07-27 16:33:01 +00:00
|
|
|
auto addToSearchList = [&item_set, withinAnyNet, aSingleNet, aTypes] ( CN_ITEM *aItem )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2017-06-23 11:56:28 +00:00
|
|
|
if( withinAnyNet && aItem->Net() <= 0 )
|
2017-03-22 13:43:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( !aItem->Valid() )
|
|
|
|
return;
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
if( aSingleNet >=0 && aItem->Net() != aSingleNet )
|
2017-03-22 13:43:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
bool found = false;
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
for( int i = 0; aTypes[i] != EOT; i++ )
|
|
|
|
{
|
|
|
|
if( aItem->Parent()->Type() == aTypes[i] )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
2017-06-23 11:56:28 +00:00
|
|
|
}
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
if( !found )
|
2017-03-22 13:43:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
aItem->SetVisited( false );
|
|
|
|
|
2020-07-27 16:33:01 +00:00
|
|
|
item_set.insert( aItem );
|
2017-03-22 13:43:10 +00:00
|
|
|
};
|
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
std::for_each( m_itemList.begin(), m_itemList.end(), addToSearchList );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2020-07-27 16:33:01 +00:00
|
|
|
while( !item_set.empty() )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
|
|
|
CN_CLUSTER_PTR cluster ( new CN_CLUSTER() );
|
2020-07-27 16:33:01 +00:00
|
|
|
CN_ITEM* root;
|
|
|
|
auto it = item_set.begin();
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2020-07-27 16:33:01 +00:00
|
|
|
while( it != item_set.end() && (*it)->Visited() )
|
|
|
|
it = item_set.erase( item_set.begin() );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2020-07-27 16:33:01 +00:00
|
|
|
if( it == item_set.end() )
|
|
|
|
break;
|
|
|
|
|
|
|
|
root = *it;
|
|
|
|
root->SetVisited ( true );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2020-07-27 16:33:01 +00:00
|
|
|
Q.clear();
|
2017-03-22 13:43:10 +00:00
|
|
|
Q.push_back( root );
|
|
|
|
|
|
|
|
while( Q.size() )
|
|
|
|
{
|
|
|
|
CN_ITEM* current = Q.front();
|
|
|
|
|
|
|
|
Q.pop_front();
|
|
|
|
cluster->Add( current );
|
|
|
|
|
|
|
|
for( auto n : current->ConnectedItems() )
|
|
|
|
{
|
2017-06-23 11:56:28 +00:00
|
|
|
if( withinAnyNet && n->Net() != root->Net() )
|
2017-03-22 13:43:10 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if( !n->Visited() && n->Valid() )
|
|
|
|
{
|
|
|
|
n->SetVisited( true );
|
|
|
|
Q.push_back( n );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clusters.push_back( cluster );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::sort( clusters.begin(), clusters.end(), []( CN_CLUSTER_PTR a, CN_CLUSTER_PTR b ) {
|
|
|
|
return a->OriginNet() < b->OriginNet();
|
|
|
|
} );
|
|
|
|
|
|
|
|
return clusters;
|
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
void CN_CONNECTIVITY_ALGO::Build( BOARD* aBoard )
|
|
|
|
{
|
2020-08-26 23:52:12 +00:00
|
|
|
for( ZONE_CONTAINER* zone : aBoard->Zones() )
|
2017-03-22 13:43:10 +00:00
|
|
|
Add( zone );
|
|
|
|
|
2020-08-26 23:52:12 +00:00
|
|
|
for( TRACK* tv : aBoard->Tracks() )
|
2017-03-22 13:43:10 +00:00
|
|
|
Add( tv );
|
|
|
|
|
2020-08-26 23:52:12 +00:00
|
|
|
for( MODULE* mod : aBoard->Modules() )
|
2017-06-23 11:56:28 +00:00
|
|
|
{
|
2020-08-26 23:52:12 +00:00
|
|
|
for( D_PAD* pad : mod->Pads() )
|
2017-03-22 13:43:10 +00:00
|
|
|
Add( pad );
|
2017-06-23 11:56:28 +00:00
|
|
|
}
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
|
|
|
|
void CN_CONNECTIVITY_ALGO::Build( const std::vector<BOARD_ITEM*>& aItems )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2017-06-23 11:56:28 +00:00
|
|
|
for( auto item : aItems )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_TRACE_T:
|
2019-05-17 00:13:21 +00:00
|
|
|
case PCB_ARC_T:
|
2017-03-22 13:43:10 +00:00
|
|
|
case PCB_VIA_T:
|
|
|
|
case PCB_PAD_T:
|
|
|
|
Add( item );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_MODULE_T:
|
|
|
|
{
|
2017-06-23 11:56:28 +00:00
|
|
|
for( auto pad : static_cast<MODULE*>( item )->Pads() )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
|
|
|
Add( pad );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
|
2019-05-25 01:55:40 +00:00
|
|
|
void CN_CONNECTIVITY_ALGO::propagateConnections( BOARD_COMMIT* aCommit )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2017-09-24 18:11:58 +00:00
|
|
|
for( const auto& cluster : m_connClusters )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2017-09-29 09:40:10 +00:00
|
|
|
if( cluster->IsConflicting() )
|
|
|
|
{
|
|
|
|
wxLogTrace( "CN", "Conflicting nets in cluster %p\n", cluster.get() );
|
|
|
|
}
|
|
|
|
else if( cluster->IsOrphaned() )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
|
|
|
wxLogTrace( "CN", "Skipping orphaned cluster %p [net: %s]\n", cluster.get(),
|
2017-07-02 20:12:56 +00:00
|
|
|
(const char*) cluster->OriginNetName().c_str() );
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
else if( cluster->HasValidNet() )
|
|
|
|
{
|
|
|
|
// normal cluster: just propagate from the pads
|
|
|
|
int n_changed = 0;
|
|
|
|
|
|
|
|
for( auto item : *cluster )
|
|
|
|
{
|
|
|
|
if( item->CanChangeNet() )
|
|
|
|
{
|
2017-07-21 09:40:26 +00:00
|
|
|
if( item->Valid() && item->Parent()->GetNetCode() != cluster->OriginNet() )
|
2017-07-02 21:05:23 +00:00
|
|
|
{
|
|
|
|
MarkNetAsDirty( item->Parent()->GetNetCode() );
|
|
|
|
MarkNetAsDirty( cluster->OriginNet() );
|
|
|
|
|
2019-05-25 01:55:40 +00:00
|
|
|
if( aCommit )
|
|
|
|
aCommit->Modify( item->Parent() );
|
|
|
|
|
2017-07-02 21:05:23 +00:00
|
|
|
item->Parent()->SetNetCode( cluster->OriginNet() );
|
|
|
|
n_changed++;
|
|
|
|
}
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( n_changed )
|
2020-01-11 21:28:25 +00:00
|
|
|
{
|
2017-03-22 13:43:10 +00:00
|
|
|
wxLogTrace( "CN", "Cluster %p : net : %d %s\n", cluster.get(),
|
2017-07-02 20:12:56 +00:00
|
|
|
cluster->OriginNet(), (const char*) cluster->OriginNetName().c_str() );
|
2020-01-11 21:28:25 +00:00
|
|
|
}
|
2017-03-22 13:43:10 +00:00
|
|
|
else
|
|
|
|
wxLogTrace( "CN", "Cluster %p : nothing to propagate\n", cluster.get() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxLogTrace( "CN", "Cluster %p : connected to unused net\n", cluster.get() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-25 01:55:40 +00:00
|
|
|
void CN_CONNECTIVITY_ALGO::PropagateNets( BOARD_COMMIT* aCommit )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
|
|
|
m_connClusters = SearchClusters( CSM_PROPAGATE );
|
2019-05-25 01:55:40 +00:00
|
|
|
propagateConnections( aCommit );
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
|
2017-12-01 15:53:58 +00:00
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( ZONE_CONTAINER* aZone,
|
|
|
|
PCB_LAYER_ID aLayer,
|
|
|
|
std::vector<int>& aIslands )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2020-06-24 02:19:08 +00:00
|
|
|
if( aZone->GetFilledPolysList( aLayer ).IsEmpty() )
|
2017-03-22 13:43:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
aIslands.clear();
|
|
|
|
|
|
|
|
Remove( aZone );
|
|
|
|
Add( aZone );
|
|
|
|
|
|
|
|
m_connClusters = SearchClusters( CSM_CONNECTIVITY_CHECK );
|
|
|
|
|
2017-09-24 18:11:58 +00:00
|
|
|
for( const auto& cluster : m_connClusters )
|
2017-06-23 11:56:28 +00:00
|
|
|
{
|
2017-03-22 13:43:10 +00:00
|
|
|
if( cluster->Contains( aZone ) && cluster->IsOrphaned() )
|
|
|
|
{
|
|
|
|
for( auto z : *cluster )
|
|
|
|
{
|
2020-06-24 02:19:08 +00:00
|
|
|
if( z->Parent() == aZone && z->Layer() == aLayer )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
|
|
|
aIslands.push_back( static_cast<CN_ZONE*>(z)->SubpolyIndex() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-23 11:56:28 +00:00
|
|
|
}
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-10-17 07:55:32 +00:00
|
|
|
wxLogTrace( "CN", "Found %u isolated islands\n", (unsigned)aIslands.size() );
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
|
2017-11-23 16:20:27 +00:00
|
|
|
void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( std::vector<CN_ZONE_ISOLATED_ISLAND_LIST>& aZones )
|
|
|
|
{
|
2020-07-01 02:21:59 +00:00
|
|
|
for( auto& z : aZones )
|
2018-06-26 06:12:11 +00:00
|
|
|
{
|
2020-07-01 02:21:59 +00:00
|
|
|
Remove( z.m_zone );
|
|
|
|
Add( z.m_zone );
|
2017-11-23 16:20:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_connClusters = SearchClusters( CSM_CONNECTIVITY_CHECK );
|
|
|
|
|
2020-07-01 02:21:59 +00:00
|
|
|
for( auto& zone : aZones )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
2020-07-01 02:21:59 +00:00
|
|
|
for( PCB_LAYER_ID layer : zone.m_zone->GetLayerSet().Seq() )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
2020-07-01 02:21:59 +00:00
|
|
|
if( zone.m_zone->GetFilledPolysList( layer ).IsEmpty() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for( const auto& cluster : m_connClusters )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
2020-07-01 02:21:59 +00:00
|
|
|
if( cluster->Contains( zone.m_zone ) && cluster->IsOrphaned() )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
2020-07-01 02:21:59 +00:00
|
|
|
for( auto z : *cluster )
|
|
|
|
{
|
|
|
|
if( z->Parent() == zone.m_zone && z->Layer() == layer )
|
|
|
|
{
|
|
|
|
zone.m_islands[layer].push_back(
|
|
|
|
static_cast<CN_ZONE*>( z )->SubpolyIndex() );
|
|
|
|
}
|
|
|
|
}
|
2017-11-23 16:20:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
const CN_CONNECTIVITY_ALGO::CLUSTERS& CN_CONNECTIVITY_ALGO::GetClusters()
|
|
|
|
{
|
|
|
|
m_ratsnestClusters = SearchClusters( CSM_RATSNEST );
|
|
|
|
return m_ratsnestClusters;
|
2017-06-23 11:56:28 +00:00
|
|
|
}
|
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-07-01 21:54:17 +00:00
|
|
|
void CN_CONNECTIVITY_ALGO::MarkNetAsDirty( int aNet )
|
2017-03-22 13:43:10 +00:00
|
|
|
{
|
2017-07-01 21:54:17 +00:00
|
|
|
if( aNet < 0 )
|
2017-03-22 13:43:10 +00:00
|
|
|
return;
|
|
|
|
|
2017-06-23 17:22:44 +00:00
|
|
|
if( (int) m_dirtyNets.size() <= aNet )
|
2018-04-06 12:57:12 +00:00
|
|
|
{
|
|
|
|
int lastNet = m_dirtyNets.size() - 1;
|
|
|
|
|
|
|
|
if( lastNet < 0 )
|
|
|
|
lastNet = 0;
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
m_dirtyNets.resize( aNet + 1 );
|
|
|
|
|
2018-04-06 12:57:12 +00:00
|
|
|
for( int i = lastNet; i < aNet + 1; i++ )
|
|
|
|
m_dirtyNets[i] = true;
|
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
m_dirtyNets[aNet] = true;
|
2017-03-22 13:43:10 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
void CN_VISITOR::checkZoneItemConnection( CN_ZONE* aZone, CN_ITEM* aItem )
|
|
|
|
{
|
2019-08-23 16:43:34 +00:00
|
|
|
if( aZone->Net() != aItem->Net() && !aItem->CanChangeNet() )
|
|
|
|
return;
|
2018-05-21 00:06:01 +00:00
|
|
|
|
2019-10-04 10:44:19 +00:00
|
|
|
if( !aZone->BBox().Intersects( aItem->BBox() ) )
|
2018-05-21 00:06:01 +00:00
|
|
|
return;
|
|
|
|
|
2020-08-05 22:39:54 +00:00
|
|
|
CN_ZONE* zoneItem = static_cast<CN_ZONE*> ( aZone );
|
|
|
|
int accuracy = 0;
|
|
|
|
|
2020-08-14 03:30:56 +00:00
|
|
|
if( aItem->Parent()->Type() == PCB_VIA_T
|
|
|
|
|| aItem->Parent()->Type() == PCB_TRACE_T
|
|
|
|
|| aItem->Parent()->Type() == PCB_ARC_T )
|
|
|
|
accuracy = ( static_cast<TRACK*>( aItem->Parent() )->GetWidth() + 1 ) / 2;
|
2019-08-23 16:43:34 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < aItem->AnchorCount(); ++i )
|
2018-05-21 00:06:01 +00:00
|
|
|
{
|
2020-08-05 22:39:54 +00:00
|
|
|
if( zoneItem->ContainsPoint( aItem->GetAnchor( i ), accuracy ) )
|
2019-08-23 16:43:34 +00:00
|
|
|
{
|
|
|
|
zoneItem->Connect( aItem );
|
|
|
|
aItem->Connect( zoneItem );
|
|
|
|
return;
|
|
|
|
}
|
2018-05-21 00:06:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CN_VISITOR::checkZoneZoneConnection( CN_ZONE* aZoneA, CN_ZONE* aZoneB )
|
|
|
|
{
|
2020-08-07 22:57:59 +00:00
|
|
|
const auto parentA = static_cast<const ZONE_CONTAINER*>( aZoneA->Parent() );
|
|
|
|
const auto parentB = static_cast<const ZONE_CONTAINER*>( aZoneB->Parent() );
|
2018-05-21 00:06:01 +00:00
|
|
|
|
2020-08-07 22:57:59 +00:00
|
|
|
if( aZoneB == aZoneA || parentA == parentB )
|
2018-05-21 00:06:01 +00:00
|
|
|
return;
|
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
if( aZoneA->Layer() != aZoneB->Layer() )
|
|
|
|
return;
|
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
if( aZoneB->Net() != aZoneA->Net() )
|
|
|
|
return; // we only test zones belonging to the same net
|
|
|
|
|
2020-08-07 22:57:59 +00:00
|
|
|
const BOX2I& boxA = aZoneA->BBox();
|
|
|
|
const BOX2I& boxB = aZoneB->BBox();
|
|
|
|
|
|
|
|
int radiusA = 0;
|
|
|
|
int radiusB = 0;
|
|
|
|
|
|
|
|
if( parentA->GetFilledPolysUseThickness() )
|
|
|
|
radiusA = ( parentA->GetMinThickness() + 1 ) / 2;
|
|
|
|
|
|
|
|
if( parentB->GetFilledPolysUseThickness() )
|
|
|
|
radiusB = ( parentB->GetMinThickness() + 1 ) / 2;
|
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( aZoneA->Layer() );
|
|
|
|
|
2020-08-07 22:57:59 +00:00
|
|
|
const auto& outline = parentA->GetFilledPolysList( layer ).COutline( aZoneA->SubpolyIndex() );
|
2018-05-21 00:06:01 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < outline.PointCount(); i++ )
|
|
|
|
{
|
2020-08-07 22:57:59 +00:00
|
|
|
if( !boxB.Contains( outline.CPoint( i ) ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( aZoneB->ContainsPoint( outline.CPoint( i ), radiusA ) )
|
2018-05-21 00:06:01 +00:00
|
|
|
{
|
2018-10-13 00:06:10 +00:00
|
|
|
aZoneA->Connect( aZoneB );
|
|
|
|
aZoneB->Connect( aZoneA );
|
2018-05-21 00:06:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
const auto& outline2 =
|
2020-08-07 22:57:59 +00:00
|
|
|
parentB->GetFilledPolysList( layer ).COutline( aZoneB->SubpolyIndex() );
|
2018-05-21 00:06:01 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < outline2.PointCount(); i++ )
|
|
|
|
{
|
2020-08-07 22:57:59 +00:00
|
|
|
if( !boxA.Contains( outline2.CPoint( i ) ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( aZoneA->ContainsPoint( outline2.CPoint( i ), radiusB ) )
|
2018-05-21 00:06:01 +00:00
|
|
|
{
|
2018-10-13 00:06:10 +00:00
|
|
|
aZoneA->Connect( aZoneB );
|
|
|
|
aZoneB->Connect( aZoneA );
|
2018-05-21 00:06:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CN_VISITOR::operator()( CN_ITEM* aCandidate )
|
|
|
|
{
|
2020-07-25 11:58:17 +00:00
|
|
|
const BOARD_CONNECTED_ITEM* parentA = aCandidate->Parent();
|
|
|
|
const BOARD_CONNECTED_ITEM* parentB = m_item->Parent();
|
2018-05-21 00:06:01 +00:00
|
|
|
|
|
|
|
if( !aCandidate->Valid() || !m_item->Valid() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( parentA == parentB )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( !( parentA->GetLayerSet() & parentB->GetLayerSet() ).any() )
|
|
|
|
return true;
|
|
|
|
|
2018-07-06 21:55:25 +00:00
|
|
|
// If both m_item and aCandidate are marked dirty, they will both be searched
|
|
|
|
// Since we are reciprocal in our connection, we arbitrarily pick one of the connections
|
|
|
|
// to conduct the expensive search
|
|
|
|
if( aCandidate->Dirty() && aCandidate < m_item )
|
|
|
|
return true;
|
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
// We should handle zone-zone connection separately
|
2018-09-29 17:58:31 +00:00
|
|
|
if ( parentA->Type() == PCB_ZONE_AREA_T && parentB->Type() == PCB_ZONE_AREA_T )
|
2018-05-21 00:06:01 +00:00
|
|
|
{
|
|
|
|
checkZoneZoneConnection( static_cast<CN_ZONE*>( m_item ),
|
|
|
|
static_cast<CN_ZONE*>( aCandidate ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-29 17:58:31 +00:00
|
|
|
if( parentA->Type() == PCB_ZONE_AREA_T )
|
2018-05-21 00:06:01 +00:00
|
|
|
{
|
|
|
|
checkZoneItemConnection( static_cast<CN_ZONE*>( aCandidate ), m_item );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-29 17:58:31 +00:00
|
|
|
if( parentB->Type() == PCB_ZONE_AREA_T )
|
2018-05-21 00:06:01 +00:00
|
|
|
{
|
|
|
|
checkZoneItemConnection( static_cast<CN_ZONE*>( m_item ), aCandidate );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-08-14 03:30:56 +00:00
|
|
|
int accuracyA = 0;
|
|
|
|
int accuracyB = 0;
|
|
|
|
|
|
|
|
if( parentA->Type() == PCB_VIA_T
|
|
|
|
|| parentA->Type() == PCB_TRACE_T
|
|
|
|
|| parentA->Type() == PCB_ARC_T)
|
|
|
|
accuracyA = ( static_cast<const TRACK*>( parentA )->GetWidth() + 1 ) / 2;
|
|
|
|
|
|
|
|
if( parentB->Type() == PCB_VIA_T
|
|
|
|
|| parentB->Type() == PCB_TRACE_T
|
|
|
|
|| parentB->Type() == PCB_ARC_T )
|
|
|
|
accuracyB = ( static_cast<const TRACK*>( parentB )->GetWidth() + 1 ) / 2;
|
|
|
|
|
2018-05-21 00:06:01 +00:00
|
|
|
// Items do not necessarily have reciprocity as we only check for anchors
|
|
|
|
// therefore, we check HitTest both directions A->B & B->A
|
2019-09-19 19:43:24 +00:00
|
|
|
for( int i = 0; i < aCandidate->AnchorCount(); ++i )
|
2018-05-21 00:06:01 +00:00
|
|
|
{
|
2020-08-14 03:30:56 +00:00
|
|
|
if( parentB->HitTest( wxPoint( aCandidate->GetAnchor( i ) ), accuracyA ) )
|
2019-09-19 19:43:24 +00:00
|
|
|
{
|
|
|
|
m_item->Connect( aCandidate );
|
|
|
|
aCandidate->Connect( m_item );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( int i = 0; i < m_item->AnchorCount(); ++i )
|
|
|
|
{
|
2020-08-14 03:30:56 +00:00
|
|
|
if( parentA->HitTest( wxPoint( m_item->GetAnchor( i ) ), accuracyB ) )
|
2019-09-19 19:43:24 +00:00
|
|
|
{
|
|
|
|
m_item->Connect( aCandidate );
|
|
|
|
aCandidate->Connect( m_item );
|
|
|
|
return true;
|
|
|
|
}
|
2018-05-21 00:06:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
void CN_CONNECTIVITY_ALGO::Clear()
|
|
|
|
{
|
|
|
|
m_ratsnestClusters.clear();
|
|
|
|
m_connClusters.clear();
|
|
|
|
m_itemMap.clear();
|
2018-05-21 00:06:01 +00:00
|
|
|
m_itemList.Clear();
|
2017-03-22 13:43:10 +00:00
|
|
|
|
|
|
|
}
|
2017-03-28 16:30:49 +00:00
|
|
|
|
2017-11-23 16:20:27 +00:00
|
|
|
void CN_CONNECTIVITY_ALGO::SetProgressReporter( PROGRESS_REPORTER* aReporter )
|
|
|
|
{
|
|
|
|
m_progressReporter = aReporter;
|
|
|
|
}
|