router: NODE|ITEM::QueryColliding() now can override clearance

Needed for clustering algorithm (to be committed later... ;-)
This commit is contained in:
Tomasz Wlostowski 2022-06-03 22:59:58 +02:00
parent aca9cce5d5
commit 54f4f765b9
4 changed files with 16 additions and 14 deletions

View File

@ -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<const LINE*>( 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<const LINE*>( aOther );
if( line->EndsWithVia() && line->Via().collideSimple( this, aNode, aDifferentNetsOnly ) )
if( line->EndsWithVia() && line->Via().collideSimple( this, aNode, aDifferentNetsOnly, aOverrideClearance ) )
return true;
}

View File

@ -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;

View File

@ -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() );

View File

@ -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<JOINT*>& aJoints,
LAYER_RANGE aLayerMask = LAYER_RANGE::All(), int aKindMask = ITEM::ANY_T );