Optimize testCourtyardClearances when moving footprints (33%->0.69%)
Check bounding boxes without hidden text first before trying to check courtyards. See https://gitlab.com/kicad/code/kicad/-/issues/18148
This commit is contained in:
parent
dc56364cf2
commit
4bf8ed32cd
|
@ -33,23 +33,29 @@
|
||||||
void DRC_INTERACTIVE_COURTYARD_CLEARANCE::testCourtyardClearances()
|
void DRC_INTERACTIVE_COURTYARD_CLEARANCE::testCourtyardClearances()
|
||||||
{
|
{
|
||||||
std::vector<BOX2I> fpBBBoxes( m_FpInMove.size() );
|
std::vector<BOX2I> fpBBBoxes( m_FpInMove.size() );
|
||||||
std::vector<BOX2I> frontBBBoxes( m_FpInMove.size() );
|
BOX2I movingBBox;
|
||||||
std::vector<BOX2I> backBBBoxes( m_FpInMove.size() );
|
|
||||||
|
|
||||||
// GetCourtyard updates courtyard caches if needed
|
|
||||||
for( size_t i = 0; i < m_FpInMove.size(); i++ )
|
for( size_t i = 0; i < m_FpInMove.size(); i++ )
|
||||||
{
|
{
|
||||||
FOOTPRINT* fpB = m_FpInMove[i];
|
FOOTPRINT* fpB = m_FpInMove[i];
|
||||||
fpBBBoxes[i] = fpB->GetBoundingBox();
|
|
||||||
frontBBBoxes[i] = fpB->GetCourtyard( F_CrtYd ).BBoxFromCaches();
|
BOX2I bbox = fpB->GetBoundingBox( true, false );
|
||||||
backBBBoxes[i] = fpB->GetCourtyard( B_CrtYd ).BBoxFromCaches();
|
movingBBox.Merge( bbox );
|
||||||
|
fpBBBoxes[i] = bbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
movingBBox.Inflate( m_largestCourtyardClearance );
|
||||||
|
|
||||||
for( FOOTPRINT* fpA: m_board->Footprints() )
|
for( FOOTPRINT* fpA: m_board->Footprints() )
|
||||||
{
|
{
|
||||||
if( fpA->IsSelected() )
|
if( fpA->IsSelected() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
BOX2I fpABBox = fpA->GetBoundingBox( true, false );
|
||||||
|
|
||||||
|
if( !movingBBox.Intersects( fpABBox ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
const SHAPE_POLY_SET& frontA = fpA->GetCourtyard( F_CrtYd );
|
const SHAPE_POLY_SET& frontA = fpA->GetCourtyard( F_CrtYd );
|
||||||
const SHAPE_POLY_SET& backA = fpA->GetCourtyard( B_CrtYd );
|
const SHAPE_POLY_SET& backA = fpA->GetCourtyard( B_CrtYd );
|
||||||
|
|
||||||
|
@ -63,16 +69,16 @@ void DRC_INTERACTIVE_COURTYARD_CLEARANCE::testCourtyardClearances()
|
||||||
frontABBox.Inflate( m_largestCourtyardClearance );
|
frontABBox.Inflate( m_largestCourtyardClearance );
|
||||||
backABBox.Inflate( m_largestCourtyardClearance );
|
backABBox.Inflate( m_largestCourtyardClearance );
|
||||||
|
|
||||||
BOX2I fpABBox = fpA->GetBoundingBox();
|
|
||||||
|
|
||||||
for( size_t inMoveId = 0; inMoveId < m_FpInMove.size(); inMoveId++ )
|
for( size_t inMoveId = 0; inMoveId < m_FpInMove.size(); inMoveId++ )
|
||||||
{
|
{
|
||||||
FOOTPRINT* fpB = m_FpInMove[inMoveId];
|
FOOTPRINT* fpB = m_FpInMove[inMoveId];
|
||||||
const SHAPE_POLY_SET& frontB = fpB->GetCachedCourtyard( F_CrtYd );
|
const SHAPE_POLY_SET& frontB = fpB->GetCourtyard( F_CrtYd );
|
||||||
const SHAPE_POLY_SET& backB = fpB->GetCachedCourtyard( B_CrtYd );
|
const SHAPE_POLY_SET& backB = fpB->GetCourtyard( B_CrtYd );
|
||||||
|
|
||||||
const BOX2I fpBBBox = fpBBBoxes[inMoveId];
|
const BOX2I fpBBBox = fpBBBoxes[inMoveId];
|
||||||
const BOX2I frontBBBox = frontBBBoxes[inMoveId];
|
const BOX2I frontBBBox = frontB.BBoxFromCaches();
|
||||||
const BOX2I backBBBox = backBBBoxes[inMoveId];
|
const BOX2I backBBBox = backB.BBoxFromCaches();
|
||||||
|
|
||||||
int clearance;
|
int clearance;
|
||||||
int actual;
|
int actual;
|
||||||
VECTOR2I pos;
|
VECTOR2I pos;
|
||||||
|
|
|
@ -1243,9 +1243,7 @@ const BOX2I FOOTPRINT::GetBoundingBox() const
|
||||||
|
|
||||||
const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const
|
const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const
|
||||||
{
|
{
|
||||||
std::vector<PCB_TEXT*> texts;
|
|
||||||
const BOARD* board = GetBoard();
|
const BOARD* board = GetBoard();
|
||||||
bool isFPEdit = board && board->IsFootprintHolder();
|
|
||||||
|
|
||||||
if( board )
|
if( board )
|
||||||
{
|
{
|
||||||
|
@ -1266,6 +1264,9 @@ const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<PCB_TEXT*> texts;
|
||||||
|
bool isFPEdit = board && board->IsFootprintHolder();
|
||||||
|
|
||||||
BOX2I bbox( m_pos );
|
BOX2I bbox( m_pos );
|
||||||
bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox
|
bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue