PNS: Allow for approximation error in hull clearance

Also revert to using exact hulls for non-compound shapes

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

(cherry picked from commit 96f9f2c658)
This commit is contained in:
Jon Evans 2023-10-13 03:55:34 +01:00 committed by Jeff Young
parent f89803eb64
commit 629eccaf09
3 changed files with 27 additions and 4 deletions

View File

@ -1155,10 +1155,24 @@ std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE_BASE::syncPad( PAD* aPad )
if( aPad->GetDrillSize().x > 0 )
solid->SetHole( new PNS::HOLE( aPad->GetEffectiveHoleShape()->Clone() ) );
std::shared_ptr<SHAPE_POLY_SET> shape = aPad->GetEffectivePolygon();
std::shared_ptr<SHAPE> shape = aPad->GetEffectiveShape( UNDEFINED_LAYER,
FLASHING::ALWAYS_FLASHED );
std::shared_ptr<SHAPE_POLY_SET> polygon = aPad->GetEffectivePolygon();
if( shape->OutlineCount() )
solid->SetShape( new SHAPE_SIMPLE( shape->Outline( 0 ) ) );
if( shape->HasIndexableSubshapes() && polygon->OutlineCount() )
{
solid->SetShape( new SHAPE_SIMPLE( polygon->Outline( 0 ) ) );
// GetEffectivePolygon may produce an approximation of the shape, so we need to account for
// this when building hulls around this shape.
solid->SetExtraClearance( m_board->GetDesignSettings().m_MaxError );
}
else
{
// Prefer using the original shape if it's not a compound shape; the hulls for
// circular and rectangular pads can be exact.
solid->SetShape( shape->Clone() );
}
return solid;
}

View File

@ -48,6 +48,8 @@ const SHAPE_LINE_CHAIN SOLID::Hull( int aClearance, int aWalkaroundThickness, in
if( !m_shape )
return SHAPE_LINE_CHAIN();
aClearance += ExtraClearance();
if( m_shape->Type() == SH_COMPOUND )
{
SHAPE_COMPOUND* cmpnd = static_cast<SHAPE_COMPOUND*>( m_shape );

View File

@ -38,7 +38,8 @@ public:
SOLID() :
ITEM( SOLID_T ),
m_shape( nullptr ),
m_hole( nullptr )
m_hole( nullptr ),
m_extraClearance( 0 )
{
m_movable = false;
m_padToDie = 0;
@ -64,6 +65,7 @@ public:
m_pos = aSolid.m_pos;
m_padToDie = aSolid.m_padToDie;
m_orientation = aSolid.m_orientation;
m_extraClearance = aSolid.m_extraClearance;
}
SOLID& operator=( const SOLID& aB )
@ -77,6 +79,7 @@ public:
m_pos = aB.m_pos;
m_padToDie = aB.m_padToDie;
m_orientation = aB.m_orientation;
m_extraClearance = aB.m_extraClearance;
return *this;
}
@ -136,6 +139,9 @@ public:
virtual bool HasHole() const override { return m_hole != nullptr; }
virtual HOLE *Hole() const override { return m_hole; }
int ExtraClearance() const { return m_extraClearance; }
void SetExtraClearance( int aClearance ) { m_extraClearance = aClearance; }
private:
VECTOR2I m_pos;
SHAPE* m_shape;
@ -143,6 +149,7 @@ private:
int m_padToDie;
EDA_ANGLE m_orientation;
HOLE* m_hole;
int m_extraClearance;
};
}