Check return value for zone fill in VRML exporter

If the zone fill failed, then don't add the zone to the
exported VRML because it might not be correct.

Also test that the Python command in DIALOG_SCRIPTING worked.
This dialog actually isn't used anywhere currently, so it
could in theory be removed - but it is simple enough and
it provides a decent testing dialog that it is more work to remove
it.
This commit is contained in:
Ian McInerney 2020-09-21 12:32:30 +01:00
parent 70a7d1bc7c
commit b1160660d9
2 changed files with 10 additions and 4 deletions

View File

@ -48,7 +48,8 @@ DIALOG_SCRIPTING::DIALOG_SCRIPTING( wxWindow* parent )
void DIALOG_SCRIPTING::OnRunButtonClick( wxCommandEvent& event )
{
wxCharBuffer buffer = m_txScript->GetValue().ToUTF8();
PyRun_SimpleString(buffer.data());
int retv = PyRun_SimpleString( buffer.data()) ;
if( retv != 0 )
wxLogError( "Python error %d occurred running command:\n\n`%s`", retv, buffer );
}

View File

@ -1017,7 +1017,10 @@ static void export_vrml_zones( MODEL_VRML& aModel, BOARD* aPcb, COMMIT* aCommit
{
ZONE_FILLER filler( aPcb, aCommit );
zone->SetFillMode( ZONE_FILL_MODE::POLYGONS ); // use filled polygons
filler.Fill( { zone } );
// If the zone fill failed, don't try adding it to the export
if( !filler.Fill( { zone } ) )
continue;
}
const SHAPE_POLY_SET& poly = zone->GetFilledPolysList( layer );
@ -1032,8 +1035,10 @@ static void export_vrml_zones( MODEL_VRML& aModel, BOARD* aPcb, COMMIT* aCommit
{
if( !vl->AddVertex( seg, (double) outline.CPoint( j ).x * BOARD_SCALE,
-( (double) outline.CPoint( j ).y * BOARD_SCALE ) ) )
{
throw( std::runtime_error( vl->GetError() ) );
}
}
vl->EnsureWinding( seg, false );
}