Organizing connectivity
Moved large routines out of headers in into cpp. Moved trivial routines into headers.
This commit is contained in:
parent
cfaf7c1f23
commit
59adb109a6
|
@ -34,31 +34,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
bool operator<( const CN_ANCHOR_PTR& a, const CN_ANCHOR_PTR& b )
|
||||
{
|
||||
if( a->Pos().x == b->Pos().x )
|
||||
return a->Pos().y < b->Pos().y;
|
||||
else
|
||||
return a->Pos().x < b->Pos().x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CN_CONNECTIVITY_ALGO::CN_CONNECTIVITY_ALGO()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CN_CONNECTIVITY_ALGO::~CN_CONNECTIVITY_ALGO()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
bool CN_CONNECTIVITY_ALGO::Remove( BOARD_ITEM* aItem )
|
||||
{
|
||||
markItemNetAsDirty( aItem );
|
||||
|
|
|
@ -172,8 +172,8 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
CN_CONNECTIVITY_ALGO();
|
||||
~CN_CONNECTIVITY_ALGO();
|
||||
CN_CONNECTIVITY_ALGO() {}
|
||||
~CN_CONNECTIVITY_ALGO() { Clear(); }
|
||||
|
||||
bool ItemExists( const BOARD_CONNECTED_ITEM* aItem )
|
||||
{
|
||||
|
|
|
@ -121,6 +121,88 @@ void CN_ITEM::RemoveInvalidRefs()
|
|||
}
|
||||
|
||||
|
||||
CN_ITEM* CN_LIST::Add( D_PAD* pad )
|
||||
{
|
||||
auto item = new CN_ITEM( pad, false, 1 );
|
||||
item->AddAnchor( pad->ShapePos() );
|
||||
item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
|
||||
|
||||
switch( pad->GetAttribute() )
|
||||
{
|
||||
case PAD_ATTRIB_SMD:
|
||||
case PAD_ATTRIB_HOLE_NOT_PLATED:
|
||||
case PAD_ATTRIB_CONN:
|
||||
{
|
||||
LSET lmsk = pad->GetLayerSet();
|
||||
|
||||
for( int i = 0; i <= MAX_CU_LAYERS; i++ )
|
||||
{
|
||||
if( lmsk[i] )
|
||||
{
|
||||
item->SetLayer( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
addItemtoTree( item );
|
||||
m_items.push_back( item );
|
||||
SetDirty();
|
||||
return item;
|
||||
}
|
||||
|
||||
CN_ITEM* CN_LIST::Add( TRACK* track )
|
||||
{
|
||||
auto item = new CN_ITEM( track, true );
|
||||
m_items.push_back( item );
|
||||
item->AddAnchor( track->GetStart() );
|
||||
item->AddAnchor( track->GetEnd() );
|
||||
item->SetLayer( track->GetLayer() );
|
||||
addItemtoTree( item );
|
||||
SetDirty();
|
||||
return item;
|
||||
}
|
||||
|
||||
CN_ITEM* CN_LIST::Add( VIA* via )
|
||||
{
|
||||
auto item = new CN_ITEM( via, true, 1 );
|
||||
|
||||
m_items.push_back( item );
|
||||
item->AddAnchor( via->GetStart() );
|
||||
item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
|
||||
addItemtoTree( item );
|
||||
SetDirty();
|
||||
return item;
|
||||
}
|
||||
|
||||
const std::vector<CN_ITEM*> CN_LIST::Add( ZONE_CONTAINER* zone )
|
||||
{
|
||||
const auto& polys = zone->GetFilledPolysList();
|
||||
|
||||
std::vector<CN_ITEM*> rv;
|
||||
|
||||
for( int j = 0; j < polys.OutlineCount(); j++ )
|
||||
{
|
||||
CN_ZONE* zitem = new CN_ZONE( zone, false, j );
|
||||
const auto& outline = zone->GetFilledPolysList().COutline( j );
|
||||
|
||||
for( int k = 0; k < outline.PointCount(); k++ )
|
||||
zitem->AddAnchor( outline.CPoint( k ) );
|
||||
|
||||
m_items.push_back( zitem );
|
||||
zitem->SetLayer( zone->GetLayer() );
|
||||
addItemtoTree( zitem );
|
||||
rv.push_back( zitem );
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
void CN_LIST::RemoveInvalidItems( std::vector<CN_ITEM*>& aGarbage )
|
||||
{
|
||||
|
@ -140,7 +222,6 @@ void CN_LIST::RemoveInvalidItems( std::vector<CN_ITEM*>& aGarbage )
|
|||
|
||||
m_items.resize( lastItem - m_items.begin() );
|
||||
|
||||
// fixme: mem leaks
|
||||
for( auto item : m_items )
|
||||
item->RemoveInvalidRefs();
|
||||
|
||||
|
|
|
@ -427,7 +427,10 @@ public:
|
|||
CN_ITEM* operator[] ( int aIndex ) { return m_items[aIndex]; }
|
||||
|
||||
template <class T>
|
||||
void FindNearby( CN_ITEM *aItem, T aFunc );
|
||||
void FindNearby( CN_ITEM *aItem, T aFunc )
|
||||
{
|
||||
m_index.Query( aItem->BBox(), aItem->Layers(), aFunc );
|
||||
}
|
||||
|
||||
void SetHasInvalid( bool aInvalid = true )
|
||||
{
|
||||
|
@ -467,95 +470,15 @@ public:
|
|||
return m_items.size();
|
||||
}
|
||||
|
||||
CN_ITEM* Add( D_PAD* pad )
|
||||
{
|
||||
auto item = new CN_ITEM( pad, false, 1 );
|
||||
item->AddAnchor( pad->ShapePos() );
|
||||
item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
|
||||
CN_ITEM* Add( D_PAD* pad );
|
||||
|
||||
switch( pad->GetAttribute() )
|
||||
{
|
||||
case PAD_ATTRIB_SMD:
|
||||
case PAD_ATTRIB_HOLE_NOT_PLATED:
|
||||
case PAD_ATTRIB_CONN:
|
||||
{
|
||||
LSET lmsk = pad->GetLayerSet();
|
||||
CN_ITEM* Add( TRACK* track );
|
||||
|
||||
for( int i = 0; i <= MAX_CU_LAYERS; i++ )
|
||||
{
|
||||
if( lmsk[i] )
|
||||
{
|
||||
item->SetLayer( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
CN_ITEM* Add( VIA* via );
|
||||
|
||||
addItemtoTree( item );
|
||||
m_items.push_back( item );
|
||||
SetDirty();
|
||||
return item;
|
||||
}
|
||||
|
||||
CN_ITEM* Add( TRACK* track )
|
||||
{
|
||||
auto item = new CN_ITEM( track, true );
|
||||
m_items.push_back( item );
|
||||
item->AddAnchor( track->GetStart() );
|
||||
item->AddAnchor( track->GetEnd() );
|
||||
item->SetLayer( track->GetLayer() );
|
||||
addItemtoTree( item );
|
||||
SetDirty();
|
||||
return item;
|
||||
}
|
||||
|
||||
CN_ITEM* Add( VIA* via )
|
||||
{
|
||||
auto item = new CN_ITEM( via, true, 1 );
|
||||
|
||||
m_items.push_back( item );
|
||||
item->AddAnchor( via->GetStart() );
|
||||
item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
|
||||
addItemtoTree( item );
|
||||
SetDirty();
|
||||
return item;
|
||||
}
|
||||
|
||||
const std::vector<CN_ITEM*> Add( ZONE_CONTAINER* zone )
|
||||
{
|
||||
const auto& polys = zone->GetFilledPolysList();
|
||||
|
||||
std::vector<CN_ITEM*> rv;
|
||||
|
||||
for( int j = 0; j < polys.OutlineCount(); j++ )
|
||||
{
|
||||
CN_ZONE* zitem = new CN_ZONE( zone, false, j );
|
||||
const auto& outline = zone->GetFilledPolysList().COutline( j );
|
||||
|
||||
for( int k = 0; k < outline.PointCount(); k++ )
|
||||
zitem->AddAnchor( outline.CPoint( k ) );
|
||||
|
||||
m_items.push_back( zitem );
|
||||
zitem->SetLayer( zone->GetLayer() );
|
||||
addItemtoTree( zitem );
|
||||
rv.push_back( zitem );
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
const std::vector<CN_ITEM*> Add( ZONE_CONTAINER* zone );
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void CN_LIST::FindNearby( CN_ITEM *aItem, T aFunc )
|
||||
{
|
||||
m_index.Query( aItem->BBox(), aItem->Layers(), aFunc );
|
||||
}
|
||||
|
||||
class CN_CLUSTER
|
||||
{
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue