You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

581 lines
19 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2021 KiCad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <vector>
  25. #include <export_to_pcbnew.h>
  26. #include <confirm.h>
  27. #include <string_utils.h>
  28. #include <locale_io.h>
  29. #include <macros.h>
  30. #include <trigo.h>
  31. #include <gerbview_frame.h>
  32. #include <gerber_file_image.h>
  33. #include <gerber_file_image_list.h>
  34. #include <build_version.h>
  35. #include <wildcards_and_files_ext.h>
  36. #include "excellon_image.h"
  37. // Imported function
  38. extern const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber );
  39. GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName )
  40. {
  41. m_gerbview_frame = aFrame;
  42. m_pcb_file_name = aFileName;
  43. m_fp = nullptr;
  44. m_pcbCopperLayersCount = 2;
  45. }
  46. GBR_TO_PCB_EXPORTER::~GBR_TO_PCB_EXPORTER()
  47. {
  48. }
  49. bool GBR_TO_PCB_EXPORTER::ExportPcb( const LAYER_NUM* aLayerLookUpTable, int aCopperLayers )
  50. {
  51. LOCALE_IO toggle; // toggles on, then off, the C locale.
  52. m_fp = wxFopen( m_pcb_file_name, wxT( "wt" ) );
  53. if( m_fp == nullptr )
  54. {
  55. wxString msg;
  56. msg.Printf( _( "Failed to create file '%s'." ), m_pcb_file_name );
  57. DisplayError( m_gerbview_frame, msg );
  58. return false;
  59. }
  60. m_pcbCopperLayersCount = aCopperLayers;
  61. writePcbHeader( aLayerLookUpTable );
  62. // create an image of gerber data
  63. const int pcbCopperLayerMax = 31;
  64. GERBER_FILE_IMAGE_LIST* images = m_gerbview_frame->GetGerberLayout()->GetImagesList();
  65. // First collect all the holes. We'll use these to generate pads, vias, etc.
  66. for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
  67. {
  68. EXCELLON_IMAGE* excellon = dynamic_cast<EXCELLON_IMAGE*>( images->GetGbrImage( layer ) );
  69. if( excellon == nullptr ) // Layer not yet used or not a drill image
  70. continue;
  71. for( GERBER_DRAW_ITEM* gerb_item : excellon->GetItems() )
  72. collect_hole( gerb_item );
  73. }
  74. // Next: non copper layers:
  75. for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
  76. {
  77. GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
  78. if( gerber == nullptr ) // Graphic layer not yet used
  79. continue;
  80. LAYER_NUM pcb_layer_number = aLayerLookUpTable[layer];
  81. if( !IsPcbLayer( pcb_layer_number ) )
  82. continue;
  83. if( pcb_layer_number <= pcbCopperLayerMax ) // copper layer
  84. continue;
  85. for( GERBER_DRAW_ITEM* gerb_item : gerber->GetItems() )
  86. export_non_copper_item( gerb_item, pcb_layer_number );
  87. }
  88. // Copper layers
  89. for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
  90. {
  91. GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
  92. if( gerber == nullptr ) // Graphic layer not yet used
  93. continue;
  94. LAYER_NUM pcb_layer_number = aLayerLookUpTable[layer];
  95. if( pcb_layer_number < 0 || pcb_layer_number > pcbCopperLayerMax )
  96. continue;
  97. for( GERBER_DRAW_ITEM* gerb_item : gerber->GetItems() )
  98. export_copper_item( gerb_item, pcb_layer_number );
  99. }
  100. // Now write out the holes we collected earlier as vias
  101. for( const EXPORT_VIA& via : m_vias )
  102. export_via( via );
  103. fprintf( m_fp, ")\n" );
  104. fclose( m_fp );
  105. m_fp = nullptr;
  106. return true;
  107. }
  108. void GBR_TO_PCB_EXPORTER::export_non_copper_item( const GERBER_DRAW_ITEM* aGbrItem,
  109. LAYER_NUM aLayer )
  110. {
  111. // used when a D_CODE is not found. default D_CODE to draw a flashed item
  112. static D_CODE dummyD_CODE( 0 );
  113. wxPoint seg_start = aGbrItem->m_Start;
  114. wxPoint seg_end = aGbrItem->m_End;
  115. D_CODE* d_codeDescr = aGbrItem->GetDcodeDescr();
  116. SHAPE_POLY_SET polygon;
  117. if( d_codeDescr == nullptr )
  118. d_codeDescr = &dummyD_CODE;
  119. switch( aGbrItem->m_Shape )
  120. {
  121. case GBR_POLYGON:
  122. writePcbPolygon( aGbrItem->m_Polygon, aLayer );
  123. break;
  124. case GBR_SPOT_CIRCLE:
  125. {
  126. VECTOR2I center = aGbrItem->GetABPosition( seg_start );
  127. int radius = d_codeDescr->m_Size.x / 2;
  128. writePcbFilledCircle( center, radius, aLayer );
  129. }
  130. break;
  131. case GBR_SPOT_RECT:
  132. case GBR_SPOT_OVAL:
  133. case GBR_SPOT_POLY:
  134. case GBR_SPOT_MACRO:
  135. d_codeDescr->ConvertShapeToPolygon();
  136. writePcbPolygon( d_codeDescr->m_Polygon, aLayer, aGbrItem->GetABPosition( seg_start ) );
  137. break;
  138. case GBR_ARC:
  139. {
  140. double a = atan2( (double) ( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y ),
  141. (double) ( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
  142. double b = atan2( (double) ( aGbrItem->m_End.y - aGbrItem->m_ArcCentre.y ),
  143. (double) ( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) );
  144. double angle = RAD2DEG(b - a);
  145. seg_start = aGbrItem->m_ArcCentre;
  146. // Ensure arc orientation is CCW
  147. if( angle < 0 )
  148. angle += 360.0;
  149. // Reverse Y axis:
  150. seg_start.y = -seg_start.y;
  151. seg_end.y = -seg_end.y;
  152. if( angle == 360.0 || angle == 0 )
  153. {
  154. fprintf( m_fp, "(gr_circle (center %s %s) (end %s %s) (layer %s) (width %s))\n",
  155. Double2Str( MapToPcbUnits(seg_start.x) ).c_str(),
  156. Double2Str( MapToPcbUnits(seg_start.y) ).c_str(),
  157. Double2Str( MapToPcbUnits(seg_end.x) ).c_str(),
  158. Double2Str( MapToPcbUnits(seg_end.y) ).c_str(),
  159. TO_UTF8( GetPCBDefaultLayerName( aLayer ) ),
  160. Double2Str( MapToPcbUnits( aGbrItem->m_Size.x ) ).c_str()
  161. );
  162. }
  163. else
  164. {
  165. fprintf( m_fp, "(gr_arc (start %s %s) (end %s %s) (angle %s) (layer %s) (width %s))\n",
  166. Double2Str( MapToPcbUnits(seg_start.x) ).c_str(),
  167. Double2Str( MapToPcbUnits(seg_start.y) ).c_str(),
  168. Double2Str( MapToPcbUnits(seg_end.x) ).c_str(),
  169. Double2Str( MapToPcbUnits(seg_end.y) ).c_str(),
  170. Double2Str( angle ).c_str(),
  171. TO_UTF8( GetPCBDefaultLayerName( aLayer ) ),
  172. Double2Str( MapToPcbUnits( aGbrItem->m_Size.x ) ).c_str()
  173. );
  174. }
  175. }
  176. break;
  177. case GBR_CIRCLE:
  178. // Reverse Y axis:
  179. seg_start.y = -seg_start.y;
  180. seg_end.y = -seg_end.y;
  181. fprintf( m_fp, "(gr_circle (start %s %s) (end %s %s) (layer %s) (width %s))\n",
  182. Double2Str( MapToPcbUnits( seg_start.x ) ).c_str(),
  183. Double2Str( MapToPcbUnits( seg_start.y ) ).c_str(),
  184. Double2Str( MapToPcbUnits( seg_end.x ) ).c_str(),
  185. Double2Str( MapToPcbUnits( seg_end.y ) ).c_str(),
  186. TO_UTF8( GetPCBDefaultLayerName( aLayer ) ),
  187. Double2Str( MapToPcbUnits( aGbrItem->m_Size.x ) ).c_str() );
  188. break;
  189. case GBR_SEGMENT:
  190. // Reverse Y axis:
  191. seg_start.y = -seg_start.y;
  192. seg_end.y = -seg_end.y;
  193. fprintf( m_fp, "(gr_line (start %s %s) (end %s %s) (layer %s) (width %s))\n",
  194. Double2Str( MapToPcbUnits( seg_start.x ) ).c_str(),
  195. Double2Str( MapToPcbUnits( seg_start.y ) ).c_str(),
  196. Double2Str( MapToPcbUnits( seg_end.x ) ).c_str(),
  197. Double2Str( MapToPcbUnits( seg_end.y ) ).c_str(),
  198. TO_UTF8( GetPCBDefaultLayerName( aLayer ) ),
  199. Double2Str( MapToPcbUnits( aGbrItem->m_Size.x ) ).c_str() );
  200. break;
  201. }
  202. }
  203. void GBR_TO_PCB_EXPORTER::collect_hole( const GERBER_DRAW_ITEM* aGbrItem )
  204. {
  205. int size = std::min( aGbrItem->m_Size.x, aGbrItem->m_Size.y );
  206. m_vias.emplace_back( aGbrItem->m_Start, size + 1, size );
  207. }
  208. void GBR_TO_PCB_EXPORTER::export_via( const EXPORT_VIA& aVia )
  209. {
  210. wxPoint via_pos = aVia.m_Pos;
  211. // Reverse Y axis:
  212. via_pos.y = -via_pos.y;
  213. // Layers are Front to Back
  214. fprintf( m_fp, " (via (at %s %s) (size %s) (drill %s)",
  215. Double2Str( MapToPcbUnits( via_pos.x ) ).c_str(),
  216. Double2Str( MapToPcbUnits( via_pos.y ) ).c_str(),
  217. Double2Str( MapToPcbUnits( aVia.m_Size ) ).c_str(),
  218. Double2Str( MapToPcbUnits( aVia.m_Drill ) ).c_str() );
  219. fprintf( m_fp, " (layers %s %s))\n",
  220. TO_UTF8( GetPCBDefaultLayerName( F_Cu ) ),
  221. TO_UTF8( GetPCBDefaultLayerName( B_Cu ) ) );
  222. }
  223. void GBR_TO_PCB_EXPORTER::export_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
  224. {
  225. switch( aGbrItem->m_Shape )
  226. {
  227. case GBR_SPOT_CIRCLE:
  228. case GBR_SPOT_RECT:
  229. case GBR_SPOT_OVAL:
  230. export_flashed_copper_item( aGbrItem, aLayer );
  231. break;
  232. case GBR_ARC:
  233. export_segarc_copper_item( aGbrItem, aLayer );
  234. break;
  235. case GBR_POLYGON:
  236. // One can use a polygon or a zone to output a Gerber region.
  237. // none are perfect.
  238. // The current way is use a polygon, as the zone export
  239. // is experimental and only for tests.
  240. #if 1
  241. writePcbPolygon( aGbrItem->m_Polygon, aLayer );
  242. #else
  243. // Only for tests:
  244. writePcbZoneItem( aGbrItem, aLayer );
  245. #endif
  246. break;
  247. default:
  248. export_segline_copper_item( aGbrItem, aLayer );
  249. break;
  250. }
  251. }
  252. void GBR_TO_PCB_EXPORTER::export_segline_copper_item( const GERBER_DRAW_ITEM* aGbrItem,
  253. LAYER_NUM aLayer )
  254. {
  255. wxPoint seg_start, seg_end;
  256. seg_start = aGbrItem->m_Start;
  257. seg_end = aGbrItem->m_End;
  258. // Reverse Y axis:
  259. seg_start.y = -seg_start.y;
  260. seg_end.y = -seg_end.y;
  261. writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
  262. }
  263. void GBR_TO_PCB_EXPORTER::writeCopperLineItem( const wxPoint& aStart,
  264. const wxPoint& aEnd,
  265. int aWidth, LAYER_NUM aLayer )
  266. {
  267. fprintf( m_fp, "(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n",
  268. Double2Str( MapToPcbUnits(aStart.x) ).c_str(),
  269. Double2Str( MapToPcbUnits(aStart.y) ).c_str(),
  270. Double2Str( MapToPcbUnits(aEnd.x) ).c_str(),
  271. Double2Str( MapToPcbUnits(aEnd.y) ).c_str(),
  272. Double2Str( MapToPcbUnits( aWidth ) ).c_str(),
  273. TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
  274. }
  275. void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( const GERBER_DRAW_ITEM* aGbrItem,
  276. LAYER_NUM aLayer )
  277. {
  278. double a = atan2( (double) ( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y ),
  279. (double) ( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
  280. double b = atan2( (double) ( aGbrItem->m_End.y - aGbrItem->m_ArcCentre.y ),
  281. (double) ( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) );
  282. wxPoint start = aGbrItem->m_Start;
  283. wxPoint end = aGbrItem->m_End;
  284. /* Because Pcbnew does not know arcs in tracks,
  285. * approximate arc by segments (SEG_COUNT__CIRCLE segment per 360 deg)
  286. * The arc is drawn anticlockwise from the start point to the end point.
  287. */
  288. #define SEG_COUNT_CIRCLE 16
  289. #define DELTA_ANGLE 2 * M_PI / SEG_COUNT_CIRCLE
  290. // calculate the number of segments from a to b.
  291. // we want CNT_PER_360 segments fo a circle
  292. if( a > b )
  293. b += 2 * M_PI;
  294. wxPoint curr_start = start;
  295. wxPoint seg_start, seg_end;
  296. int ii = 1;
  297. for( double rot = a; rot < (b - DELTA_ANGLE); rot += DELTA_ANGLE, ii++ )
  298. {
  299. seg_start = curr_start;
  300. wxPoint curr_end = start;
  301. RotatePoint( &curr_end, aGbrItem->m_ArcCentre,
  302. -RAD2DECIDEG( DELTA_ANGLE * ii ) );
  303. seg_end = curr_end;
  304. // Reverse Y axis:
  305. seg_start.y = -seg_start.y;
  306. seg_end.y = -seg_end.y;
  307. writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
  308. curr_start = curr_end;
  309. }
  310. if( end != curr_start )
  311. {
  312. seg_start = curr_start;
  313. seg_end = end;
  314. // Reverse Y axis:
  315. seg_start.y = -seg_start.y;
  316. seg_end.y = -seg_end.y;
  317. writeCopperLineItem( seg_start, seg_end, aGbrItem->m_Size.x, aLayer );
  318. }
  319. }
  320. void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( const GERBER_DRAW_ITEM* aGbrItem,
  321. LAYER_NUM aLayer )
  322. {
  323. static D_CODE flashed_item_D_CODE( 0 );
  324. D_CODE* d_codeDescr = aGbrItem->GetDcodeDescr();
  325. SHAPE_POLY_SET polygon;
  326. if( d_codeDescr == nullptr )
  327. d_codeDescr = &flashed_item_D_CODE;
  328. if( aGbrItem->m_Shape == GBR_SPOT_CIRCLE )
  329. {
  330. // See if there's a via that we can enlarge to fit this flashed item
  331. for( EXPORT_VIA& via : m_vias )
  332. {
  333. if( via.m_Pos == aGbrItem->m_Start )
  334. {
  335. via.m_Size = std::max( via.m_Size, aGbrItem->m_Size.x );
  336. return;
  337. }
  338. }
  339. }
  340. wxPoint offset = aGbrItem->GetABPosition( aGbrItem->m_Start );
  341. if( aGbrItem->m_Shape == GBR_SPOT_CIRCLE ) // export it as filled circle
  342. {
  343. VECTOR2I center = offset;
  344. int radius = d_codeDescr->m_Size.x / 2;
  345. writePcbFilledCircle( center, radius, aLayer );
  346. return;
  347. }
  348. d_codeDescr->ConvertShapeToPolygon();
  349. writePcbPolygon( d_codeDescr->m_Polygon, aLayer, offset );
  350. }
  351. void GBR_TO_PCB_EXPORTER::writePcbFilledCircle( const VECTOR2I& aCenterPosition, int aRadius,
  352. LAYER_NUM aLayer )
  353. {
  354. fprintf( m_fp, "(gr_circle (center %s %s) (end %s %s)",
  355. Double2Str( MapToPcbUnits( aCenterPosition.x ) ).c_str(),
  356. Double2Str( MapToPcbUnits( aCenterPosition.y ) ).c_str(),
  357. Double2Str( MapToPcbUnits( aCenterPosition.x + aRadius ) ).c_str(),
  358. Double2Str( MapToPcbUnits( aCenterPosition.y ) ).c_str() );
  359. fprintf( m_fp, "(layer %s) (width 0) (fill solid) )\n",
  360. TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
  361. }
  362. void GBR_TO_PCB_EXPORTER::writePcbHeader( const LAYER_NUM* aLayerLookUpTable )
  363. {
  364. fprintf( m_fp, "(kicad_pcb (version 4) (generator gerbview)\n\n" );
  365. // Write layers section
  366. fprintf( m_fp, " (layers \n" );
  367. for( int ii = 0; ii < m_pcbCopperLayersCount; ii++ )
  368. {
  369. int id = ii;
  370. if( ii == m_pcbCopperLayersCount-1)
  371. id = B_Cu;
  372. fprintf( m_fp, " (%d %s signal)\n", id, TO_UTF8( GetPCBDefaultLayerName( id ) ) );
  373. }
  374. for( int ii = B_Adhes; ii < PCB_LAYER_ID_COUNT; ii++ )
  375. {
  376. if( GetPCBDefaultLayerName( ii ).IsEmpty() ) // Layer not available for export
  377. continue;
  378. fprintf( m_fp, " (%d %s user)\n", ii, TO_UTF8( GetPCBDefaultLayerName( ii ) ) );
  379. }
  380. fprintf( m_fp, " )\n\n" );
  381. }
  382. void GBR_TO_PCB_EXPORTER::writePcbPolygon( const SHAPE_POLY_SET& aPolys, LAYER_NUM aLayer,
  383. const wxPoint& aOffset )
  384. {
  385. SHAPE_POLY_SET polys = aPolys;
  386. // Cleanup the polygon
  387. polys.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
  388. // Ensure the polygon is valid:
  389. if( polys.OutlineCount() == 0 )
  390. return;
  391. polys.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
  392. SHAPE_LINE_CHAIN& poly = polys.Outline( 0 );
  393. fprintf( m_fp, "(gr_poly (pts " );
  394. #define MAX_COORD_CNT 4
  395. int jj = MAX_COORD_CNT;
  396. int cnt_max = poly.PointCount() -1;
  397. // Do not generate last corner, if it is the same point as the first point:
  398. if( poly.CPoint( 0 ) == poly.CPoint( cnt_max ) )
  399. cnt_max--;
  400. for( int ii = 0; ii <= cnt_max; ii++ )
  401. {
  402. if( --jj == 0 )
  403. {
  404. jj = MAX_COORD_CNT;
  405. fprintf( m_fp, "\n" );
  406. }
  407. fprintf( m_fp, " (xy %s %s)",
  408. Double2Str( MapToPcbUnits( poly.CPoint( ii ).x + aOffset.x ) ).c_str(),
  409. Double2Str( MapToPcbUnits( -poly.CPoint( ii ).y + aOffset.y ) ).c_str() );
  410. }
  411. fprintf( m_fp, ")" );
  412. if( jj != MAX_COORD_CNT )
  413. fprintf( m_fp, "\n" );
  414. fprintf( m_fp, "(layer %s) (width 0) )\n", TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
  415. }
  416. void GBR_TO_PCB_EXPORTER::writePcbZoneItem( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
  417. {
  418. SHAPE_POLY_SET polys = aGbrItem->m_Polygon;
  419. polys.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
  420. if( polys.OutlineCount() == 0 )
  421. return;
  422. fprintf( m_fp, "(zone (net 0) (net_name \"\") (layer %s) (tstamp 0000000) (hatch edge 0.508)\n",
  423. TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
  424. fprintf( m_fp, " (connect_pads (clearance 0.0))\n" );
  425. fprintf( m_fp, " (min_thickness 0.1) (filled_areas_thickness no)\n"
  426. " (fill (thermal_gap 0.3) (thermal_bridge_width 0.3))\n" );
  427. // Now, write the zone outlines with holes.
  428. // first polygon is the main outline, next are holes
  429. // One cannot know the initial zone outline.
  430. // However most of (if not all) holes are just items with clearance,
  431. // not really a hole in the initial zone outline.
  432. // So we build a zone outline only with no hole.
  433. fprintf( m_fp, " (polygon\n (pts" );
  434. SHAPE_LINE_CHAIN& poly = polys.Outline( 0 );
  435. #define MAX_COORD_CNT 4
  436. int jj = MAX_COORD_CNT;
  437. int cnt_max = poly.PointCount() -1;
  438. // Do not generate last corner, if it is the same point as the first point:
  439. if( poly.CPoint( 0 ) == poly.CPoint( cnt_max ) )
  440. cnt_max--;
  441. for( int ii = 0; ii <= cnt_max; ii++ )
  442. {
  443. if( --jj == 0 )
  444. {
  445. jj = MAX_COORD_CNT;
  446. fprintf( m_fp, "\n " );
  447. }
  448. fprintf( m_fp, " (xy %s %s)", Double2Str( MapToPcbUnits( poly.CPoint( ii ).x ) ).c_str(),
  449. Double2Str( MapToPcbUnits( -poly.CPoint( ii ).y ) ).c_str() );
  450. }
  451. fprintf( m_fp, ")\n" );
  452. fprintf( m_fp, " )\n)\n" );
  453. }