fix issues in DRC and fill zone, related to recent changes in code.

Note also: the actual clearance between 2 pads when < minimal clearance
is incorrectly calculated.
This commit is contained in:
jean-pierre charras 2020-06-30 12:50:31 +02:00
parent bb1afb747a
commit 42296d7eb9
3 changed files with 18 additions and 9 deletions

View File

@ -305,7 +305,7 @@ void D_PAD::BuildEffectiveShapes() const
if( board )
maxError = board->GetDesignSettings().m_MaxError;
TransformRoundChamferedRectToPolygon( outline, wxPoint(0,0), GetSize(), m_Orient,
TransformRoundChamferedRectToPolygon( outline, shapePos, GetSize(), m_Orient,
GetRoundRectCornerRadius(), GetChamferRectRatio(),
GetChamferPositions(), maxError );

View File

@ -259,10 +259,12 @@ private:
* @param aRefPad The reference pad to check
* @param aPad Another pad to check against
* @param aMinClearance is the minimum allowed distance between the pads
* @param aActual [out] it the actual distance (only guaranteed to be set for violations)
* @return bool - true if clearance between aRefPad and aPad is >= aMinClearance, else false
* @param aActualDist [out] it the actual distance
* (only guaranteed to be set for violations)
* @return true if clearance between aRefPad and aPad is >= aMinClearance, else false
*/
bool checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance, int* aActual );
bool checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad,
int aMinClearance, int* aActualDist );
/**

View File

@ -687,7 +687,7 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS
}
bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance, int* aActual )
bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance, int* aActualDist )
{
int center2center = KiROUND( EuclideanNorm( aPad->ShapePos() - aRefPad->ShapePos() ) );
@ -698,8 +698,10 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance
// JEY TODO:
// TOM TODO: MTV only works as a proxy for actual-distance for convex shapes
VECTOR2I mtv;
VECTOR2I maxMtv( 0, 0 );
VECTOR2I mtv; // minimum translation vector calculated by Collide()
VECTOR2I maxMtv( 0, 0 ); // is the move distance between 2 shapes calculated
// by Collide to do not have a collision
bool shapes_collide = false;
for( const std::shared_ptr<SHAPE>& aShape : aRefPad->GetEffectiveShapes() )
{
@ -707,15 +709,20 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance
{
if( aShape->Collide( bShape.get(), aMinClearance, mtv ) )
{
shapes_collide = true;
if( mtv.SquaredEuclideanNorm() > maxMtv.SquaredEuclideanNorm() )
maxMtv = mtv;
}
}
}
if( maxMtv.x > 0 || maxMtv.y > 0 )
if( shapes_collide )
{
*aActual = std::max( 0, aMinClearance - maxMtv.EuclideanNorm() );
// returns the actual clearance (clearance < aMinClearance) for diags:
if( aActualDist )
*aActualDist = std::max( 0, aMinClearance - maxMtv.EuclideanNorm() );
return false;
}