Browse Source

Pcbnew: fix teardrop generation for pads having different shapes by layer.

Teardrop generator used pad::HitTest not testing the hit of a specific layer.
It created false test for some complex pads. Now use a test specific to a layer.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21560

(cherry picked from commit 963aa47778)
9.0
jean-pierre charras 2 months ago
parent
commit
b204742fe3
  1. 14
      pcbnew/pad.cpp
  2. 5
      pcbnew/pad.h
  3. 7
      pcbnew/teardrop/teardrop.cpp
  4. 4
      pcbnew/teardrop/teardrop_utils.cpp

14
pcbnew/pad.cpp

@ -1445,6 +1445,20 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>&
}
bool PAD::HitTest( const VECTOR2I& aPosition, int aAccuracy, PCB_LAYER_ID aLayer ) const
{
VECTOR2I delta = aPosition - GetPosition();
int boundingRadius = GetBoundingRadius() + aAccuracy;
if( delta.SquaredEuclideanNorm() > SEG::Square( boundingRadius ) )
return false;
bool contains = GetEffectivePolygon( aLayer, ERROR_INSIDE )->Contains( aPosition, -1, aAccuracy );
return contains;
}
bool PAD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
{
VECTOR2I delta = aPosition - GetPosition();

5
pcbnew/pad.h

@ -822,6 +822,11 @@ public:
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
/**
* return true if hit test on the specified layer
*/
bool HitTest( const VECTOR2I& aPosition, int aAccuracy, PCB_LAYER_ID aLayer ) const;
/**
* Recombines the pad with other graphical shapes in the footprint
*

7
pcbnew/teardrop/teardrop.cpp

@ -236,8 +236,11 @@ void TEARDROP_MANAGER::UpdateTeardrops( BOARD_COMMIT& aCommit,
continue;
}
if( pad->HitTest( track->GetStart() ) && pad->HitTest( track->GetEnd() ) )
// The track is entirely inside the pad; cannot create a teardrop
bool startHitsPad = pad->HitTest( track->GetStart(), 0, track->GetLayer() );
bool endHitsPad = pad->HitTest( track->GetEnd(), 0, track->GetLayer() );
// if the track is entirely inside the pad, cannot create a teardrop
if( startHitsPad && endHitsPad )
continue;
// Skip case where pad and the track are within a copper zone with the same net

4
pcbnew/teardrop/teardrop_utils.cpp

@ -717,10 +717,10 @@ bool TEARDROP_MANAGER::computeTeardropPolygon( const TEARDROP_PARAMETERS& aParam
{
PAD* pad = static_cast<PAD*>( aOther );
if( pad->HitTest( pointA ) )
if( pad->HitTest( pointA, 0, layer ) )
return false;
if( pad->HitTest( pointB ) )
if( pad->HitTest( pointB, 0, layer ) )
return false;
}

Loading…
Cancel
Save