pcbnew: Prevent degenerate values in Eagle import

Importing Eagle files allowed for invalid zone values for clearance and
minimum width that triggered asserts in the 3d-viewer.

Fixes: lp:1801188
* https://bugs.launchpad.net/kicad/+bug/1801188
This commit is contained in:
Seth Hillbrand 2018-11-04 10:59:36 -08:00
parent 93d3e4ccf8
commit df562b7ec0
2 changed files with 6 additions and 4 deletions

View File

@ -752,8 +752,9 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const DRAWSEGMENT* aDrawSeg
PCB_LAYER_ID aLayerId, PCB_LAYER_ID aLayerId,
int aClearanceValue ) int aClearanceValue )
{ {
// The full width of the lines to create: // The full width of the lines to create
const int linewidth = aDrawSegment->GetWidth() + (2 * aClearanceValue); // The extra 1 protects the inner/outer radius values from degeneracy
const int linewidth = aDrawSegment->GetWidth() + (2 * aClearanceValue) + 1;
switch( aDrawSegment->GetShape() ) switch( aDrawSegment->GetShape() )
{ {

View File

@ -1174,7 +1174,8 @@ ZONE_CONTAINER* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
// clearances, etc. // clearances, etc.
zone->SetArcSegmentCount( 32 ); // @todo: should be a constructor default? zone->SetArcSegmentCount( 32 ); // @todo: should be a constructor default?
zone->SetMinThickness( p.width.ToPcbUnits() ); zone->SetMinThickness( std::max<int>(
ZONE_THICKNESS_MIN_VALUE_MIL*IU_PER_MILS, p.width.ToPcbUnits() ) );
// FIXME: KiCad zones have very rounded corners compared to eagle. // FIXME: KiCad zones have very rounded corners compared to eagle.
// This means that isolation amounts that work well in eagle // This means that isolation amounts that work well in eagle
@ -1182,7 +1183,7 @@ ZONE_CONTAINER* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
if( p.isolate ) if( p.isolate )
zone->SetZoneClearance( p.isolate->ToPcbUnits() ); zone->SetZoneClearance( p.isolate->ToPcbUnits() );
else else
zone->SetZoneClearance( 0 ); zone->SetZoneClearance( 1 ); // @todo: set minimum clearance value based on board settings
// missing == yes per DTD. // missing == yes per DTD.
bool thermals = !p.thermals || *p.thermals; bool thermals = !p.thermals || *p.thermals;