1254
/* This function is not used in SPECCTRA export,
1255
* but uses a lot of functions from it
1256
* and is used to extract a board outlines (3D view, automatic zones build ...)
1257
* makes the board perimeter for the DSN file by filling the BOUNDARY element.
1258
* Any closed outline inside the main outline is a hole
1259
* All contours should be closed, i.e. valid closed polygon vertices
1261
bool SPECCTRA_DB::GetBoardPolygonOutlines( BOARD* aBoard,
1262
CPOLYGONS_LIST& aOutlines,
1263
CPOLYGONS_LIST& aHoles,
1264
wxString* aErrorText )
1266
bool success = true;
1267
double specctra2UIfactor = IU_PER_MM / 1000.0; // Specctra unite = micron
1272
pcb->structure = new STRUCTURE( pcb );
1276
BOUNDARY* boundary = new BOUNDARY( 0 );
1277
pcb->structure->SetBOUNDARY( boundary );
1281
fillBOUNDARY( aBoard, boundary );
1282
std::vector<double> buffer;
1283
boundary->GetCorners( buffer );
1285
for( unsigned ii = 0; ii < buffer.size(); ii+=2 )
1287
corner.x = buffer[ii] * specctra2UIfactor;
1288
corner.y = - buffer[ii+1] * specctra2UIfactor;
1289
aOutlines.Append( corner );
1292
aOutlines.CloseLastContour();
1294
// Export holes, stored as keepouts polygonal shapes.
1295
// by fillBOUNDARY()
1296
KEEPOUTS& holes = pcb->structure->keepouts;
1298
for( KEEPOUTS::iterator i=holes.begin(); i!=holes.end(); ++i )
1300
KEEPOUT& keepout = *i;
1301
PATH* poly_hole = (PATH*)keepout.shape;
1302
POINTS& plist = poly_hole->GetPoints();
1303
for( unsigned ii = 0; ii < plist.size(); ii+=2 )
1305
corner.x = plist[ii].x * specctra2UIfactor;
1306
corner.y = - plist[ii].y * specctra2UIfactor;
1307
aHoles.Append( corner );
1309
aHoles.CloseLastContour();
1312
catch( IO_ERROR ioe )
1314
// Creates a valid polygon outline is not possible.
1315
// So uses the board edge cuts bounding box to create a
1316
// rectangular outline
1317
// (when no edge cuts items, fillBOUNDARY biuld n outline
1318
// from global bounding box
1321
*aErrorText = ioe.errorText;
1323
EDA_RECT bbbox = aBoard->ComputeBoundingBox( true );
1324
corner.x = bbbox.GetOrigin().x;
1325
corner.y = bbbox.GetOrigin().y;
1326
aOutlines.Append( corner );
1328
corner.x = bbbox.GetOrigin().x;
1329
corner.y = bbbox.GetEnd().y;
1330
aOutlines.Append( corner );
1332
corner.x = bbbox.GetEnd().x;
1333
corner.y = bbbox.GetEnd().y;
1334
aOutlines.Append( corner );
1336
corner.x = bbbox.GetEnd().x;
1337
corner.y = bbbox.GetOrigin().y;
1338
aOutlines.Append( corner );
1340
aOutlines.CloseLastContour();
1255
1347
typedef std::set<std::string> STRINGSET;
1256
1348
typedef std::pair<STRINGSET::iterator, bool> STRINGSET_PAIR;