PNS: Put polygon error outside pad shapes

Fixes https://gitlab.com/kicad/code/kicad/-/issues/7672
This commit is contained in:
Jon Evans 2021-03-29 19:49:59 -04:00
parent 6cbc3fb97d
commit 78a60e9dfb
1 changed files with 11 additions and 5 deletions

View File

@ -905,13 +905,19 @@ std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE_BASE::syncPad( PAD* aPad )
// router, otherwise it won't know how to correctly build walkaround 'hulls' for the pad // router, otherwise it won't know how to correctly build walkaround 'hulls' for the pad
// primitives - it can recognize only simple shapes, but not COMPOUNDs made of multiple shapes. // primitives - it can recognize only simple shapes, but not COMPOUNDs made of multiple shapes.
// The proper way to fix this would be to implement SHAPE_COMPOUND::ConvertToSimplePolygon(), // The proper way to fix this would be to implement SHAPE_COMPOUND::ConvertToSimplePolygon(),
// but the complexity of pad polygonization code (see PAD::GetEffectivePolygon), including approximation // but the complexity of pad polygonization code (see PAD::GetEffectivePolygon), including
// error handling makes me slightly scared to do it right now. // approximation error handling makes me slightly scared to do it right now.
// NOTE: PAD::GetEffectivePolygon puts the error on the inside, but we want the error on
// the outside so that the collision hull is larger than the pad
SHAPE_POLY_SET outline;
aPad->TransformShapeWithClearanceToPolygon( outline, UNDEFINED_LAYER, 0, ARC_HIGH_DEF,
ERROR_OUTSIDE );
const std::shared_ptr<SHAPE_POLY_SET>& outline = aPad->GetEffectivePolygon();
SHAPE_SIMPLE* shape = new SHAPE_SIMPLE(); SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
for( auto iter = outline->CIterate( 0 ); iter; iter++ ) for( auto iter = outline.CIterate( 0 ); iter; iter++ )
shape->Append( *iter ); shape->Append( *iter );
solid->SetShape( shape ); solid->SetShape( shape );