From 54f4f765b91c088ab40db303737b3ac453bb35bd Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 3 Jun 2022 22:59:58 +0200 Subject: [PATCH] router: NODE|ITEM::QueryColliding() now can override clearance Needed for clustering algorithm (to be committed later... ;-) --- pcbnew/router/pns_item.cpp | 12 ++++++------ pcbnew/router/pns_item.h | 4 ++-- pcbnew/router/pns_node.cpp | 12 +++++++----- pcbnew/router/pns_node.h | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/pcbnew/router/pns_item.cpp b/pcbnew/router/pns_item.cpp index f7ca5e48d9..08ff7c1e54 100644 --- a/pcbnew/router/pns_item.cpp +++ b/pcbnew/router/pns_item.cpp @@ -29,7 +29,7 @@ typedef VECTOR2I::extended_type ecoord; namespace PNS { -bool ITEM::collideSimple( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOnly ) const +bool ITEM::collideSimple( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOnly, int aOverrideClearance ) const { const ROUTER_IFACE* iface = ROUTER::GetInstance()->GetInterface(); const SHAPE* shapeA = Shape(); @@ -123,14 +123,14 @@ bool ITEM::collideSimple( const ITEM* aOther, const NODE* aNode, bool aDifferent if( !Layers().IsMultilayer() && !iface->IsFlashedOnLayer( aOther, Layer()) ) return false; - int clearance = aNode->GetClearance( this, aOther ); + int clearance = aOverrideClearance >= 0 ? aOverrideClearance : aNode->GetClearance( this, aOther ); return shapeA->Collide( shapeB, clearance + lineWidthA + lineWidthB ); } -bool ITEM::Collide( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOnly ) const +bool ITEM::Collide( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOnly, int aOverrideClearance ) const { - if( collideSimple( aOther, aNode, aDifferentNetsOnly ) ) + if( collideSimple( aOther, aNode, aDifferentNetsOnly, aOverrideClearance ) ) return true; // Special cases for "head" lines with vias attached at the end. Note that this does not @@ -141,7 +141,7 @@ bool ITEM::Collide( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOn { const LINE* line = static_cast( this ); - if( line->EndsWithVia() && line->Via().collideSimple( aOther, aNode, aDifferentNetsOnly ) ) + if( line->EndsWithVia() && line->Via().collideSimple( aOther, aNode, aDifferentNetsOnly, aOverrideClearance ) ) return true; } @@ -149,7 +149,7 @@ bool ITEM::Collide( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOn { const LINE* line = static_cast( aOther ); - if( line->EndsWithVia() && line->Via().collideSimple( this, aNode, aDifferentNetsOnly ) ) + if( line->EndsWithVia() && line->Via().collideSimple( this, aNode, aDifferentNetsOnly, aOverrideClearance ) ) return true; } diff --git a/pcbnew/router/pns_item.h b/pcbnew/router/pns_item.h index d02a081f9a..db2a7f78d0 100644 --- a/pcbnew/router/pns_item.h +++ b/pcbnew/router/pns_item.h @@ -192,7 +192,7 @@ public: * @param aOther is the item to check collision against. * @return true, if a collision was found. */ - bool Collide( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOnly = true ) const; + bool Collide( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOnly = true, int aOverrideClearance = -1 ) const; /** * Return the geometrical shape of the item. Used for collision detection and spatial indexing. @@ -241,7 +241,7 @@ public: bool IsCompoundShapePrimitive() const { return m_isCompoundShapePrimitive; } private: - bool collideSimple( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOnly ) const; + bool collideSimple( const ITEM* aOther, const NODE* aNode, bool aDifferentNetsOnly, int aOverrideClearance ) const; protected: PnsKind m_kind; diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index d652d420f0..205b4a6ae1 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -217,15 +217,17 @@ struct NODE::DEFAULT_OBSTACLE_VISITOR : public OBSTACLE_VISITOR int m_limitCount; int m_matchCount; bool m_differentNetsOnly; + int m_overrideClearance; DEFAULT_OBSTACLE_VISITOR( NODE::OBSTACLES& aTab, const ITEM* aItem, int aKindMask, - bool aDifferentNetsOnly ) : + bool aDifferentNetsOnly, int aOverrideClearance ) : OBSTACLE_VISITOR( aItem ), m_tab( aTab ), m_kindMask( aKindMask ), m_limitCount( -1 ), m_matchCount( 0 ), - m_differentNetsOnly( aDifferentNetsOnly ) + m_differentNetsOnly( aDifferentNetsOnly ), + m_overrideClearance( aOverrideClearance ) { } @@ -246,7 +248,7 @@ struct NODE::DEFAULT_OBSTACLE_VISITOR : public OBSTACLE_VISITOR if( visit( aCandidate ) ) return true; - if( !aCandidate->Collide( m_item, m_node, m_differentNetsOnly ) ) + if( !aCandidate->Collide( m_item, m_node, m_differentNetsOnly, m_overrideClearance ) ) return true; OBSTACLE obs; @@ -267,13 +269,13 @@ struct NODE::DEFAULT_OBSTACLE_VISITOR : public OBSTACLE_VISITOR int NODE::QueryColliding( const ITEM* aItem, NODE::OBSTACLES& aObstacles, int aKindMask, - int aLimitCount, bool aDifferentNetsOnly ) + int aLimitCount, bool aDifferentNetsOnly, int aOverrideClearance ) { /// By default, virtual items cannot collide if( aItem->IsVirtual() ) return 0; - DEFAULT_OBSTACLE_VISITOR visitor( aObstacles, aItem, aKindMask, aDifferentNetsOnly ); + DEFAULT_OBSTACLE_VISITOR visitor( aObstacles, aItem, aKindMask, aDifferentNetsOnly, aOverrideClearance ); #ifdef DEBUG assert( allocNodes.find( this ) != allocNodes.end() ); diff --git a/pcbnew/router/pns_node.h b/pcbnew/router/pns_node.h index d88a26cf9f..695cf8dae0 100644 --- a/pcbnew/router/pns_node.h +++ b/pcbnew/router/pns_node.h @@ -212,7 +212,7 @@ public: * @return number of obstacles found */ int QueryColliding( const ITEM* aItem, OBSTACLES& aObstacles, int aKindMask = ITEM::ANY_T, - int aLimitCount = -1, bool aDifferentNetsOnly = true ); + int aLimitCount = -1, bool aDifferentNetsOnly = true, int aOverrideClearance = -1 ); int QueryJoints( const BOX2I& aBox, std::vector& aJoints, LAYER_RANGE aLayerMask = LAYER_RANGE::All(), int aKindMask = ITEM::ANY_T );