|
|
@ -54,9 +54,9 @@ NODE::NODE() |
|
|
|
{ |
|
|
|
m_depth = 0; |
|
|
|
m_root = this; |
|
|
|
m_parent = NULL; |
|
|
|
m_parent = nullptr; |
|
|
|
m_maxClearance = 800000; // fixme: depends on how thick traces are.
|
|
|
|
m_ruleResolver = NULL; |
|
|
|
m_ruleResolver = nullptr; |
|
|
|
m_index = new INDEX; |
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
@ -97,6 +97,7 @@ NODE::~NODE() |
|
|
|
delete m_index; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int NODE::GetClearance( const ITEM* aA, const ITEM* aB ) const |
|
|
|
{ |
|
|
|
if( !m_ruleResolver ) |
|
|
@ -107,12 +108,12 @@ int NODE::GetClearance( const ITEM* aA, const ITEM* aB ) const |
|
|
|
|
|
|
|
|
|
|
|
int NODE::GetHoleClearance( const ITEM* aA, const ITEM* aB ) const |
|
|
|
{ |
|
|
|
if( !m_ruleResolver ) |
|
|
|
return 0; |
|
|
|
{ |
|
|
|
if( !m_ruleResolver ) |
|
|
|
return 0; |
|
|
|
|
|
|
|
return m_ruleResolver->HoleClearance( aA, aB ); |
|
|
|
} |
|
|
|
return m_ruleResolver->HoleClearance( aA, aB ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int NODE::GetHoleToHoleClearance( const ITEM* aA, const ITEM* aB ) const |
|
|
@ -171,8 +172,8 @@ void NODE::unlinkParent() |
|
|
|
|
|
|
|
OBSTACLE_VISITOR::OBSTACLE_VISITOR( const ITEM* aItem ) : |
|
|
|
m_item( aItem ), |
|
|
|
m_node( NULL ), |
|
|
|
m_override( NULL ) |
|
|
|
m_node( nullptr ), |
|
|
|
m_override( nullptr ) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
@ -240,6 +241,7 @@ struct NODE::DEFAULT_OBSTACLE_VISITOR : public OBSTACLE_VISITOR |
|
|
|
|
|
|
|
obs.m_item = aCandidate; |
|
|
|
obs.m_head = m_item; |
|
|
|
obs.m_distFirst = INT_MAX; |
|
|
|
m_tab.push_back( obs ); |
|
|
|
|
|
|
|
m_matchCount++; |
|
|
@ -262,7 +264,7 @@ int NODE::QueryColliding( const ITEM* aItem, NODE::OBSTACLES& aObstacles, int aK |
|
|
|
#endif
|
|
|
|
|
|
|
|
visitor.SetCountLimit( aLimitCount ); |
|
|
|
visitor.SetWorld( this, NULL ); |
|
|
|
visitor.SetWorld( this, nullptr ); |
|
|
|
|
|
|
|
// first, look for colliding items in the local index
|
|
|
|
m_index->Query( aItem, m_maxClearance, visitor ); |
|
|
@ -297,11 +299,12 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aLine, int aKindMask, |
|
|
|
return OPT_OBSTACLE(); |
|
|
|
|
|
|
|
OBSTACLE nearest; |
|
|
|
nearest.m_item = NULL; |
|
|
|
nearest.m_item = nullptr; |
|
|
|
nearest.m_distFirst = INT_MAX; |
|
|
|
|
|
|
|
auto updateNearest = |
|
|
|
[&]( const SHAPE_LINE_CHAIN::INTERSECTION& pt, ITEM* obstacle, const SHAPE_LINE_CHAIN& hull, bool isHole ) |
|
|
|
[&]( const SHAPE_LINE_CHAIN::INTERSECTION& pt, ITEM* obstacle, |
|
|
|
const SHAPE_LINE_CHAIN& hull, bool isHole ) |
|
|
|
{ |
|
|
|
int dist = aLine->CLine().PathLength( pt.p, pt.index_their ); |
|
|
|
|
|
|
@ -347,6 +350,7 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aLine, int aKindMask, |
|
|
|
{ |
|
|
|
const VIA& via = aLine->Via(); |
|
|
|
// Don't use via.Drill(); it doesn't include the plating thickness
|
|
|
|
|
|
|
|
int viaHoleRadius = static_cast<const SHAPE_CIRCLE*>( via.Hole() )->GetRadius(); |
|
|
|
|
|
|
|
int viaClearance = GetClearance( obstacle.m_item, &via ) + via.Diameter() / 2; |
|
|
@ -361,7 +365,7 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aLine, int aKindMask, |
|
|
|
intersectingPts.clear(); |
|
|
|
HullIntersection( obstacleHull, aLine->CLine(), intersectingPts ); |
|
|
|
|
|
|
|
// obstacleHull.Intersect( aLine->CLine(), intersectingPts, true );
|
|
|
|
// obstacleHull.Intersect( aLine->CLine(), intersectingPts, true );
|
|
|
|
|
|
|
|
for( const SHAPE_LINE_CHAIN::INTERSECTION& ip : intersectingPts ) |
|
|
|
updateNearest( ip, obstacle.m_item, obstacleHull, false ); |
|
|
@ -474,7 +478,7 @@ struct HIT_VISITOR : public OBSTACLE_VISITOR |
|
|
|
const VECTOR2I& m_point; |
|
|
|
|
|
|
|
HIT_VISITOR( ITEM_SET& aTab, const VECTOR2I& aPoint ) : |
|
|
|
OBSTACLE_VISITOR( NULL ), |
|
|
|
OBSTACLE_VISITOR( nullptr ), |
|
|
|
m_items( aTab ), |
|
|
|
m_point( aPoint ) |
|
|
|
{} |
|
|
@ -504,14 +508,14 @@ const ITEM_SET NODE::HitTest( const VECTOR2I& aPoint ) const |
|
|
|
// fixme: we treat a point as an infinitely small circle - this is inefficient.
|
|
|
|
SHAPE_CIRCLE s( aPoint, 0 ); |
|
|
|
HIT_VISITOR visitor( items, aPoint ); |
|
|
|
visitor.SetWorld( this, NULL ); |
|
|
|
visitor.SetWorld( this, nullptr ); |
|
|
|
|
|
|
|
m_index->Query( &s, m_maxClearance, visitor ); |
|
|
|
|
|
|
|
if( !isRoot() ) // fixme: could be made cleaner
|
|
|
|
{ |
|
|
|
ITEM_SET items_root; |
|
|
|
visitor.SetWorld( m_root, NULL ); |
|
|
|
visitor.SetWorld( m_root, nullptr ); |
|
|
|
HIT_VISITOR visitor_root( items_root, aPoint ); |
|
|
|
m_root->m_index->Query( &s, m_maxClearance, visitor_root ); |
|
|
|
|
|
|
@ -687,7 +691,7 @@ void NODE::doRemove( ITEM* aItem ) |
|
|
|
// the item belongs to this particular branch: un-reference it
|
|
|
|
if( aItem->BelongsTo( this ) ) |
|
|
|
{ |
|
|
|
aItem->SetOwner( NULL ); |
|
|
|
aItem->SetOwner( nullptr ); |
|
|
|
m_root->m_garbageItems.insert( aItem ); |
|
|
|
} |
|
|
|
} |
|
|
@ -899,7 +903,7 @@ void NODE::followLine( LINKED_ITEM* aCurrent, bool aScanDirection, int& aPos, in |
|
|
|
if( count && guard == p ) |
|
|
|
{ |
|
|
|
if( aPos >= 0 && aPos < aLimit ) |
|
|
|
aSegments[aPos] = NULL; |
|
|
|
aSegments[aPos] = nullptr; |
|
|
|
|
|
|
|
aGuardHit = true; |
|
|
|
break; |
|
|
@ -948,7 +952,7 @@ const LINE NODE::AssembleLine( LINKED_ITEM* aSeg, int* aOriginSegmentIndex, |
|
|
|
|
|
|
|
int n = 0; |
|
|
|
|
|
|
|
LINKED_ITEM* prev_seg = NULL; |
|
|
|
LINKED_ITEM* prev_seg = nullptr; |
|
|
|
bool originSet = false; |
|
|
|
|
|
|
|
SHAPE_LINE_CHAIN& line = pl.Line(); |
|
|
@ -1068,9 +1072,13 @@ void NODE::FixupVirtualVias() |
|
|
|
for( const auto& lnk : joint.second.LinkList() ) |
|
|
|
{ |
|
|
|
if( lnk.item->OfKind( ITEM::VIA_T ) ) |
|
|
|
{ |
|
|
|
n_vias++; |
|
|
|
} |
|
|
|
else if( lnk.item->OfKind( ITEM::SOLID_T ) ) |
|
|
|
{ |
|
|
|
n_solid++; |
|
|
|
} |
|
|
|
else if( const auto t = dyn_cast<PNS::SEGMENT*>( lnk.item ) ) |
|
|
|
{ |
|
|
|
int w = t->Width(); |
|
|
@ -1117,7 +1125,7 @@ JOINT* NODE::FindJoint( const VECTOR2I& aPos, int aLayer, int aNet ) |
|
|
|
} |
|
|
|
|
|
|
|
if( f == end ) |
|
|
|
return NULL; |
|
|
|
return nullptr; |
|
|
|
|
|
|
|
while( f != end ) |
|
|
|
{ |
|
|
@ -1127,7 +1135,7 @@ JOINT* NODE::FindJoint( const VECTOR2I& aPos, int aLayer, int aNet ) |
|
|
|
++f; |
|
|
|
} |
|
|
|
|
|
|
|
return NULL; |
|
|
|
return nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1372,7 +1380,7 @@ void NODE::KillChildren() |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NODE::AllItemsInNet( int aNet, std::set<ITEM*>& aItems, int aKindMask) |
|
|
|
void NODE::AllItemsInNet( int aNet, std::set<ITEM*>& aItems, int aKindMask ) |
|
|
|
{ |
|
|
|
INDEX::NET_ITEMS_LIST* l_cur = m_index->GetItemsForNet( aNet ); |
|
|
|
|
|
|
@ -1552,7 +1560,7 @@ ITEM *NODE::FindItemByParent( const BOARD_ITEM* aParent ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return NULL; |
|
|
|
return nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
} |