Protect custom rule function caches from transient items.
This commit is contained in:
parent
94a23971cc
commit
0fde88eefc
|
@ -57,7 +57,11 @@
|
||||||
#define MALFORMED_F_COURTYARD (1 << 20)
|
#define MALFORMED_F_COURTYARD (1 << 20)
|
||||||
#define MALFORMED_B_COURTYARD (1 << 21)
|
#define MALFORMED_B_COURTYARD (1 << 21)
|
||||||
#define MALFORMED_COURTYARDS ( MALFORMED_F_COURTYARD | MALFORMED_B_COURTYARD )
|
#define MALFORMED_COURTYARDS ( MALFORMED_F_COURTYARD | MALFORMED_B_COURTYARD )
|
||||||
// 22 and 23 are unused
|
|
||||||
|
#define ROUTER_TRANSIENT (1 << 22) ///< transient items that should NOT be cached
|
||||||
|
|
||||||
|
// 23 is unused
|
||||||
|
|
||||||
#define HOLE_PROXY (1 << 24) ///< Indicates the BOARD_ITEM is a proxy for its hole
|
#define HOLE_PROXY (1 << 24) ///< Indicates the BOARD_ITEM is a proxy for its hole
|
||||||
#define IS_ROLLOVER (1 << 25) ///< Rollover active. Used for hyperlink highlighting.
|
#define IS_ROLLOVER (1 << 25) ///< Rollover active. Used for hyperlink highlighting.
|
||||||
#define SHOW_ELEC_TYPE (1 << 25) ///< Show pin electrical type. Shared with IS_ROLLOVER.
|
#define SHOW_ELEC_TYPE (1 << 25) ///< Show pin electrical type. Shared with IS_ROLLOVER.
|
||||||
|
|
|
@ -275,15 +275,20 @@ static void intersectsCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||||
PTR_PTR_CACHE_KEY key = { fp, item };
|
PTR_PTR_CACHE_KEY key = { fp, item };
|
||||||
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
||||||
|
|
||||||
auto i = board->m_IntersectsCourtyardCache.find( key );
|
if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
|
||||||
|
{
|
||||||
|
auto i = board->m_IntersectsCourtyardCache.find( key );
|
||||||
|
|
||||||
if( i != board->m_IntersectsCourtyardCache.end() )
|
if( i != board->m_IntersectsCourtyardCache.end() )
|
||||||
return i->second;
|
return i->second;
|
||||||
|
}
|
||||||
|
|
||||||
bool res = collidesWithCourtyard( item, itemShape, context, fp, F_Cu )
|
bool res = collidesWithCourtyard( item, itemShape, context, fp, F_Cu )
|
||||||
|| collidesWithCourtyard( item, itemShape, context, fp, B_Cu );
|
|| collidesWithCourtyard( item, itemShape, context, fp, B_Cu );
|
||||||
|
|
||||||
board->m_IntersectsCourtyardCache[ key ] = res;
|
if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
|
||||||
|
board->m_IntersectsCourtyardCache[ key ] = res;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
} ) )
|
} ) )
|
||||||
{
|
{
|
||||||
|
@ -330,14 +335,19 @@ static void intersectsFrontCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||||
PTR_PTR_CACHE_KEY key = { fp, item };
|
PTR_PTR_CACHE_KEY key = { fp, item };
|
||||||
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
||||||
|
|
||||||
auto i = board->m_IntersectsFCourtyardCache.find( key );
|
if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
|
||||||
|
{
|
||||||
|
auto i = board->m_IntersectsFCourtyardCache.find( key );
|
||||||
|
|
||||||
if( i != board->m_IntersectsFCourtyardCache.end() )
|
if( i != board->m_IntersectsFCourtyardCache.end() )
|
||||||
return i->second;
|
return i->second;
|
||||||
|
}
|
||||||
|
|
||||||
bool res = collidesWithCourtyard( item, itemShape, context, fp, F_Cu );
|
bool res = collidesWithCourtyard( item, itemShape, context, fp, F_Cu );
|
||||||
|
|
||||||
board->m_IntersectsFCourtyardCache[ key ] = res;
|
if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
|
||||||
|
board->m_IntersectsFCourtyardCache[ key ] = res;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
} ) )
|
} ) )
|
||||||
{
|
{
|
||||||
|
@ -384,14 +394,19 @@ static void intersectsBackCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||||
PTR_PTR_CACHE_KEY key = { fp, item };
|
PTR_PTR_CACHE_KEY key = { fp, item };
|
||||||
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
||||||
|
|
||||||
auto i = board->m_IntersectsBCourtyardCache.find( key );
|
if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
|
||||||
|
{
|
||||||
|
auto i = board->m_IntersectsBCourtyardCache.find( key );
|
||||||
|
|
||||||
if( i != board->m_IntersectsBCourtyardCache.end() )
|
if( i != board->m_IntersectsBCourtyardCache.end() )
|
||||||
return i->second;
|
return i->second;
|
||||||
|
}
|
||||||
|
|
||||||
bool res = collidesWithCourtyard( item, itemShape, context, fp, B_Cu );
|
bool res = collidesWithCourtyard( item, itemShape, context, fp, B_Cu );
|
||||||
|
|
||||||
board->m_IntersectsBCourtyardCache[ key ] = res;
|
if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
|
||||||
|
board->m_IntersectsBCourtyardCache[ key ] = res;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
} ) )
|
} ) )
|
||||||
{
|
{
|
||||||
|
@ -636,6 +651,7 @@ static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||||
|
|
||||||
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
||||||
LSET testLayers;
|
LSET testLayers;
|
||||||
|
PTR_PTR_LAYER_CACHE_KEY key;
|
||||||
|
|
||||||
if( aLayer != UNDEFINED_LAYER )
|
if( aLayer != UNDEFINED_LAYER )
|
||||||
testLayers.set( aLayer );
|
testLayers.set( aLayer );
|
||||||
|
@ -644,16 +660,20 @@ static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||||
|
|
||||||
for( PCB_LAYER_ID layer : testLayers.UIOrder() )
|
for( PCB_LAYER_ID layer : testLayers.UIOrder() )
|
||||||
{
|
{
|
||||||
PTR_PTR_LAYER_CACHE_KEY key = { aArea, item, layer };
|
if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
|
||||||
|
{
|
||||||
|
key = { aArea, item, layer };
|
||||||
|
|
||||||
auto i = board->m_IntersectsAreaCache.find( key );
|
auto i = board->m_IntersectsAreaCache.find( key );
|
||||||
|
|
||||||
if( i != board->m_IntersectsAreaCache.end() && i->second )
|
if( i != board->m_IntersectsAreaCache.end() && i->second )
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool collides = collidesWithArea( item, context, aArea );
|
bool collides = collidesWithArea( item, context, aArea );
|
||||||
|
|
||||||
board->m_IntersectsAreaCache[ key ] = collides;
|
if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
|
||||||
|
board->m_IntersectsAreaCache[ key ] = collides;
|
||||||
|
|
||||||
if( collides )
|
if( collides )
|
||||||
return true;
|
return true;
|
||||||
|
@ -716,10 +736,13 @@ static void enclosedByAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||||
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
|
||||||
PTR_PTR_LAYER_CACHE_KEY key = { aArea, item, layer };
|
PTR_PTR_LAYER_CACHE_KEY key = { aArea, item, layer };
|
||||||
|
|
||||||
auto i = board->m_EnclosedByAreaCache.find( key );
|
if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
|
||||||
|
{
|
||||||
|
auto i = board->m_EnclosedByAreaCache.find( key );
|
||||||
|
|
||||||
if( i != board->m_EnclosedByAreaCache.end() )
|
if( i != board->m_EnclosedByAreaCache.end() )
|
||||||
return i->second;
|
return i->second;
|
||||||
|
}
|
||||||
|
|
||||||
SHAPE_POLY_SET itemShape;
|
SHAPE_POLY_SET itemShape;
|
||||||
bool enclosedByArea;
|
bool enclosedByArea;
|
||||||
|
@ -740,7 +763,8 @@ static void enclosedByAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||||
enclosedByArea = itemShape.IsEmpty();
|
enclosedByArea = itemShape.IsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
board->m_EnclosedByAreaCache[ key ] = enclosedByArea;
|
if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
|
||||||
|
board->m_EnclosedByAreaCache[ key ] = enclosedByArea;
|
||||||
|
|
||||||
return enclosedByArea;
|
return enclosedByArea;
|
||||||
} ) )
|
} ) )
|
||||||
|
|
|
@ -159,6 +159,15 @@ PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard,
|
||||||
m_dummyArcs{ { aBoard }, { aBoard } },
|
m_dummyArcs{ { aBoard }, { aBoard } },
|
||||||
m_dummyVias{ { aBoard }, { aBoard } }
|
m_dummyVias{ { aBoard }, { aBoard } }
|
||||||
{
|
{
|
||||||
|
for( PCB_TRACK& track : m_dummyTracks )
|
||||||
|
track.SetFlags( ROUTER_TRANSIENT );
|
||||||
|
|
||||||
|
for( PCB_ARC& arc : m_dummyArcs )
|
||||||
|
arc.SetFlags( ROUTER_TRANSIENT );
|
||||||
|
|
||||||
|
for ( PCB_VIA& via : m_dummyVias )
|
||||||
|
via.SetFlags( ROUTER_TRANSIENT );
|
||||||
|
|
||||||
if( aBoard )
|
if( aBoard )
|
||||||
m_clearanceEpsilon = aBoard->GetDesignSettings().GetDRCEpsilon();
|
m_clearanceEpsilon = aBoard->GetDesignSettings().GetDRCEpsilon();
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue