diff --git a/pcbnew/router/pns_item.cpp b/pcbnew/router/pns_item.cpp index f3cbb1df76..9068c2de64 100644 --- a/pcbnew/router/pns_item.cpp +++ b/pcbnew/router/pns_item.cpp @@ -2,7 +2,7 @@ * KiRouter - a push-and-(sometimes-)shove PCB router * * Copyright (C) 2013-2014 CERN - * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. * Author: Tomasz Wlostowski * * This program is free software: you can redistribute it and/or modify it @@ -129,7 +129,19 @@ bool ITEM::collideSimple( const ITEM* aOther, const NODE* aNode, bool aDifferent return false; int clearance = aOverrideClearance >= 0 ? aOverrideClearance : aNode->GetClearance( this, aOther ); - return shapeA->Collide( shapeB, clearance + lineWidthA + lineWidthB ); + + if( m_parent && m_parent->GetLayer() == Edge_Cuts ) + { + int actual; + VECTOR2I pos; + + return( shapeA->Collide( shapeB, clearance + lineWidthA, &actual, &pos ) + && !aNode->QueryEdgeExclusions( pos ) ); + } + else + { + return shapeA->Collide( shapeB, clearance + lineWidthA + lineWidthB ); + } } diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 93fdb2ac9a..0f3a928efd 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1285,6 +1285,13 @@ void PNS_KICAD_IFACE_BASE::SyncWorld( PNS::NODE *aWorld ) aWorld->Add( std::move( solid ) ); worstClearance = std::max( worstClearance, pad->GetLocalClearance() ); + + if( pad->GetProperty() == PAD_PROP::CASTELLATED ) + { + std::unique_ptr hole; + hole.reset( new SHAPE_SEGMENT( *pad->GetEffectiveHoleShape() ) ); + aWorld->AddEdgeExclusion( std::move( hole ) ); + } } syncTextItem( aWorld, &footprint->Reference(), footprint->Reference().GetLayer() ); diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index 6c74067500..cacc759eb4 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -2,7 +2,7 @@ * KiRouter - a push-and-(sometimes-)shove PCB router * * Copyright (C) 2013-2019 CERN - * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @@ -717,6 +717,24 @@ void NODE::Add( std::unique_ptr< ITEM > aItem, bool aAllowRedundant ) } +void NODE::AddEdgeExclusion( std::unique_ptr aShape ) +{ + m_edgeExclusions.push_back( std::move( aShape ) ); +} + + +bool NODE::QueryEdgeExclusions( const VECTOR2I& aPos ) const +{ + for( const std::unique_ptr& edgeExclusion : m_edgeExclusions ) + { + if( edgeExclusion->Collide( aPos ) ) + return true; + } + + return false; +} + + void NODE::doRemove( ITEM* aItem ) { // case 1: removing an item that is stored in the root node from any branch: diff --git a/pcbnew/router/pns_node.h b/pcbnew/router/pns_node.h index 0ed7f1f662..2f1740c783 100644 --- a/pcbnew/router/pns_node.h +++ b/pcbnew/router/pns_node.h @@ -2,7 +2,7 @@ * KiRouter - a push-and-(sometimes-)shove PCB router * * Copyright (C) 2013-2014 CERN - * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @@ -278,6 +278,10 @@ public: void Add( LINE& aLine, bool aAllowRedundant = false ); + void AddEdgeExclusion( std::unique_ptr aShape ); + + bool QueryEdgeExclusions( const VECTOR2I& aPos ) const; + /** * Remove an item from this branch. */ @@ -484,6 +488,8 @@ private: int m_depth; ///< depth of the node (number of parent nodes in the ///< inheritance chain) + std::vector< std::unique_ptr > m_edgeExclusions; + std::unordered_set m_garbageItems; COLLISION_QUERY_SCOPE m_collisionQueryScope;