Fix logic bug in DRC RTree handler.
Return value from visitor is whether or not to keep searching, not whether or not there was a collision.
This commit is contained in:
parent
4702e279b9
commit
36ceb8075e
|
@ -328,13 +328,11 @@ public:
|
||||||
typedef std::pair<PCB_LAYER_ID, PCB_LAYER_ID> LAYER_PAIR;
|
typedef std::pair<PCB_LAYER_ID, PCB_LAYER_ID> LAYER_PAIR;
|
||||||
|
|
||||||
int QueryCollidingPairs( DRC_RTREE* aRefTree,
|
int QueryCollidingPairs( DRC_RTREE* aRefTree,
|
||||||
std::vector<LAYER_PAIR> aLayers,
|
std::vector<LAYER_PAIR> aLayers,
|
||||||
std::function<bool( const LAYER_PAIR&, ITEM_WITH_SHAPE*, ITEM_WITH_SHAPE* )> aVisitor,
|
std::function<bool( const LAYER_PAIR&,
|
||||||
|
ITEM_WITH_SHAPE*, ITEM_WITH_SHAPE*,
|
||||||
// std::function<bool( const LAYER_PAIR&, BOARD_ITEM*, BOARD_ITEM*, int&, DRC_CONSTRAINT& )> aResolver,
|
bool* aCollision )> aVisitor,
|
||||||
// std::function<bool( BOARD_ITEM*, BOARD_ITEM*, int, int&, DRC_CONSTRAINT&)> aVisitor,
|
int aMaxClearance )
|
||||||
int aMaxClearance
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// keep track of BOARD_ITEMs pairs that have been already found to collide (some items
|
// keep track of BOARD_ITEMs pairs that have been already found to collide (some items
|
||||||
// might be build of COMPOUND/triangulated shapes and a single subshape collision
|
// might be build of COMPOUND/triangulated shapes and a single subshape collision
|
||||||
|
@ -354,27 +352,29 @@ public:
|
||||||
int min[2] = { box.GetX(), box.GetY() };
|
int min[2] = { box.GetX(), box.GetY() };
|
||||||
int max[2] = { box.GetRight(), box.GetBottom() };
|
int max[2] = { box.GetRight(), box.GetBottom() };
|
||||||
|
|
||||||
auto visit = [&] ( ITEM_WITH_SHAPE* aItemToTest ) -> bool
|
auto visit =
|
||||||
{
|
[&]( ITEM_WITH_SHAPE* aItemToTest ) -> bool
|
||||||
const std::pair<BOARD_ITEM*, BOARD_ITEM*> chkCompoundPair( refItem->parent, aItemToTest->parent );
|
{
|
||||||
|
const std::pair<BOARD_ITEM*, BOARD_ITEM*>
|
||||||
|
chkCompoundPair( refItem->parent, aItemToTest->parent );
|
||||||
|
|
||||||
// don't report multiple collisions for compound or triangulated shapes
|
// don't report multiple collisions for compound or triangulated shapes
|
||||||
if( collidingCompounds.find( chkCompoundPair ) != collidingCompounds.end() )
|
if( alg::contains( collidingCompounds, chkCompoundPair ) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// don't collide items against themselves
|
// don't collide items against themselves
|
||||||
if( refLayer == targetLayer && aItemToTest->parent == refItem->parent )
|
if( refLayer == targetLayer && aItemToTest->parent == refItem->parent )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool colliding = aVisitor( refLayerIter, refItem, aItemToTest );
|
bool collisionDetected = false;
|
||||||
|
bool continueSearch = aVisitor( refLayerIter, refItem, aItemToTest,
|
||||||
|
&collisionDetected );
|
||||||
|
|
||||||
if( colliding )
|
if( collisionDetected )
|
||||||
{
|
collidingCompounds.insert( chkCompoundPair );
|
||||||
collidingCompounds.insert( chkCompoundPair );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return continueSearch;
|
||||||
};
|
};
|
||||||
|
|
||||||
this->m_tree[targetLayer]->Search( min, max, visit );
|
this->m_tree[targetLayer]->Search( min, max, visit );
|
||||||
};
|
};
|
||||||
|
|
|
@ -122,9 +122,8 @@ bool test::DRC_TEST_PROVIDER_SILK_TO_PAD::Run()
|
||||||
};
|
};
|
||||||
|
|
||||||
auto checkClearance =
|
auto checkClearance =
|
||||||
[&]( const DRC_RTREE::LAYER_PAIR& aLayers,
|
[&]( const DRC_RTREE::LAYER_PAIR& aLayers, DRC_RTREE::ITEM_WITH_SHAPE* aRefItem,
|
||||||
DRC_RTREE::ITEM_WITH_SHAPE* aRefItem,
|
DRC_RTREE::ITEM_WITH_SHAPE* aTestItem, bool* aCollisionDetected ) -> bool
|
||||||
DRC_RTREE::ITEM_WITH_SHAPE* aTestItem ) -> bool
|
|
||||||
{
|
{
|
||||||
if( m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_OVER_PAD ) )
|
if( m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_OVER_PAD ) )
|
||||||
return false;
|
return false;
|
||||||
|
@ -156,6 +155,7 @@ bool test::DRC_TEST_PROVIDER_SILK_TO_PAD::Run()
|
||||||
|
|
||||||
reportViolation( drcItem, (wxPoint) pos );
|
reportViolation( drcItem, (wxPoint) pos );
|
||||||
|
|
||||||
|
*aCollisionDetected = true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -107,9 +107,8 @@ bool DRC_TEST_PROVIDER_SILK_TO_SILK::Run()
|
||||||
};
|
};
|
||||||
|
|
||||||
auto checkClearance =
|
auto checkClearance =
|
||||||
[&]( const DRC_RTREE::LAYER_PAIR& aLayers,
|
[&]( const DRC_RTREE::LAYER_PAIR& aLayers, DRC_RTREE::ITEM_WITH_SHAPE* aRefItem,
|
||||||
DRC_RTREE::ITEM_WITH_SHAPE* aRefItem,
|
DRC_RTREE::ITEM_WITH_SHAPE* aTestItem, bool* aCollisionDetected ) -> bool
|
||||||
DRC_RTREE::ITEM_WITH_SHAPE* aTestItem ) -> bool
|
|
||||||
{
|
{
|
||||||
if( m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_CLEARANCE ) )
|
if( m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_CLEARANCE ) )
|
||||||
return false;
|
return false;
|
||||||
|
@ -123,7 +122,7 @@ bool DRC_TEST_PROVIDER_SILK_TO_SILK::Run()
|
||||||
|
|
||||||
accountCheck( constraint );
|
accountCheck( constraint );
|
||||||
|
|
||||||
// only check for silkscreen collisions belonging to different modules or
|
// only check for silkscreen collisions belonging to different footprints or
|
||||||
// overlapping texts
|
// overlapping texts
|
||||||
|
|
||||||
KICAD_T typeRef = aRefItem->parent->Type();
|
KICAD_T typeRef = aRefItem->parent->Type();
|
||||||
|
@ -180,6 +179,7 @@ bool DRC_TEST_PROVIDER_SILK_TO_SILK::Run()
|
||||||
|
|
||||||
reportViolation( drcItem, (wxPoint) pos );
|
reportViolation( drcItem, (wxPoint) pos );
|
||||||
|
|
||||||
|
*aCollisionDetected = true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue