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.

1348 lines
39 KiB

14 years ago
14 years ago
8 years ago
12 years ago
12 years ago
12 years ago
13 years ago
12 years ago
12 years ago
13 years ago
14 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file class_zone.cpp
  27. * @brief Implementation of class to handle copper zones.
  28. */
  29. #include <fctsys.h>
  30. #include <trigo.h>
  31. #include <pcb_screen.h>
  32. #include <class_drawpanel.h>
  33. #include <kicad_string.h>
  34. #include <richio.h>
  35. #include <macros.h>
  36. #include <pcb_base_frame.h>
  37. #include <msgpanel.h>
  38. #include <bitmaps.h>
  39. #include <convert_to_biu.h>
  40. #include <class_board.h>
  41. #include <class_zone.h>
  42. #include <pcbnew.h>
  43. #include <zones.h>
  44. #include <math_for_graphics.h>
  45. #include <polygon_test_point_inside.h>
  46. ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) :
  47. BOARD_CONNECTED_ITEM( aBoard, PCB_ZONE_AREA_T )
  48. {
  49. m_CornerSelection = nullptr; // no corner is selected
  50. m_IsFilled = false; // fill status : true when the zone is filled
  51. m_FillMode = ZFM_POLYGONS;
  52. m_hatchStyle = DIAGONAL_EDGE;
  53. m_hatchPitch = GetDefaultHatchPitch();
  54. m_hv45 = false;
  55. m_priority = 0;
  56. m_cornerSmoothingType = ZONE_SETTINGS::SMOOTHING_NONE;
  57. SetIsKeepout( false );
  58. SetDoNotAllowCopperPour( false ); // has meaning only if m_isKeepout == true
  59. SetDoNotAllowVias( true ); // has meaning only if m_isKeepout == true
  60. SetDoNotAllowTracks( true ); // has meaning only if m_isKeepout == true
  61. m_cornerRadius = 0;
  62. SetLocalFlags( 0 ); // flags tempoarry used in zone calculations
  63. m_Poly = new SHAPE_POLY_SET(); // Outlines
  64. aBoard->GetZoneSettings().ExportSetting( *this );
  65. }
  66. ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) :
  67. BOARD_CONNECTED_ITEM( aZone )
  68. {
  69. // Should the copy be on the same net?
  70. SetNetCode( aZone.GetNetCode() );
  71. m_Poly = new SHAPE_POLY_SET( *aZone.m_Poly );
  72. // For corner moving, corner index to drag, or nullptr if no selection
  73. m_CornerSelection = nullptr;
  74. m_IsFilled = aZone.m_IsFilled;
  75. m_ZoneClearance = aZone.m_ZoneClearance; // clearance value
  76. m_ZoneMinThickness = aZone.m_ZoneMinThickness;
  77. m_FillMode = aZone.m_FillMode; // Filling mode (segments/polygons)
  78. m_hv45 = aZone.m_hv45;
  79. m_priority = aZone.m_priority;
  80. m_ArcToSegmentsCount = aZone.m_ArcToSegmentsCount;
  81. m_PadConnection = aZone.m_PadConnection;
  82. m_ThermalReliefGap = aZone.m_ThermalReliefGap;
  83. m_ThermalReliefCopperBridge = aZone.m_ThermalReliefCopperBridge;
  84. m_FilledPolysList.Append( aZone.m_FilledPolysList );
  85. m_FillSegmList = aZone.m_FillSegmList; // vector <> copy
  86. m_isKeepout = aZone.m_isKeepout;
  87. m_doNotAllowCopperPour = aZone.m_doNotAllowCopperPour;
  88. m_doNotAllowVias = aZone.m_doNotAllowVias;
  89. m_doNotAllowTracks = aZone.m_doNotAllowTracks;
  90. m_cornerSmoothingType = aZone.m_cornerSmoothingType;
  91. m_cornerRadius = aZone.m_cornerRadius;
  92. m_hatchStyle = aZone.m_hatchStyle;
  93. m_hatchPitch = aZone.m_hatchPitch;
  94. m_HatchLines = aZone.m_HatchLines;
  95. SetLayerSet( aZone.GetLayerSet() );
  96. SetLocalFlags( aZone.GetLocalFlags() );
  97. }
  98. ZONE_CONTAINER& ZONE_CONTAINER::operator=( const ZONE_CONTAINER& aOther )
  99. {
  100. BOARD_CONNECTED_ITEM::operator=( aOther );
  101. // Replace the outlines for aOther outlines.
  102. delete m_Poly;
  103. m_Poly = new SHAPE_POLY_SET( *aOther.m_Poly );
  104. m_CornerSelection = nullptr; // for corner moving, corner index to (null if no selection)
  105. m_ZoneClearance = aOther.m_ZoneClearance; // clearance value
  106. m_ZoneMinThickness = aOther.m_ZoneMinThickness;
  107. m_FillMode = aOther.m_FillMode; // filling mode (segments/polygons)
  108. m_ArcToSegmentsCount = aOther.m_ArcToSegmentsCount;
  109. m_PadConnection = aOther.m_PadConnection;
  110. m_ThermalReliefGap = aOther.m_ThermalReliefGap;
  111. m_ThermalReliefCopperBridge = aOther.m_ThermalReliefCopperBridge;
  112. SetHatchStyle( aOther.GetHatchStyle() );
  113. SetHatchPitch( aOther.GetHatchPitch() );
  114. m_HatchLines = aOther.m_HatchLines; // copy vector <SEG>
  115. m_FilledPolysList.RemoveAllContours();
  116. m_FilledPolysList.Append( aOther.m_FilledPolysList );
  117. m_FillSegmList.clear();
  118. m_FillSegmList = aOther.m_FillSegmList;
  119. SetLayerSet( aOther.GetLayerSet() );
  120. return *this;
  121. }
  122. ZONE_CONTAINER::~ZONE_CONTAINER()
  123. {
  124. delete m_Poly;
  125. delete m_CornerSelection;
  126. }
  127. EDA_ITEM* ZONE_CONTAINER::Clone() const
  128. {
  129. return new ZONE_CONTAINER( *this );
  130. }
  131. bool ZONE_CONTAINER::UnFill()
  132. {
  133. bool change = ( !m_FilledPolysList.IsEmpty() ) ||
  134. ( m_FillSegmList.size() > 0 );
  135. m_FilledPolysList.RemoveAllContours();
  136. m_FillSegmList.clear();
  137. m_IsFilled = false;
  138. return change;
  139. }
  140. const wxPoint ZONE_CONTAINER::GetPosition() const
  141. {
  142. return (wxPoint) GetCornerPosition( 0 );
  143. }
  144. PCB_LAYER_ID ZONE_CONTAINER::GetLayer() const
  145. {
  146. return BOARD_ITEM::GetLayer();
  147. }
  148. bool ZONE_CONTAINER::IsOnCopperLayer() const
  149. {
  150. if( GetIsKeepout() )
  151. {
  152. return ( m_layerSet & LSET::AllCuMask() ).count() > 0;
  153. }
  154. else
  155. {
  156. return IsCopperLayer( GetLayer() );
  157. }
  158. }
  159. bool ZONE_CONTAINER::CommonLayerExists( const LSET aLayerSet ) const
  160. {
  161. LSET common = GetLayerSet() & aLayerSet;
  162. return common.count() > 0;
  163. }
  164. void ZONE_CONTAINER::SetLayer( PCB_LAYER_ID aLayer )
  165. {
  166. SetLayerSet( LSET( aLayer ) );
  167. m_Layer = aLayer;
  168. }
  169. void ZONE_CONTAINER::SetLayerSet( LSET aLayerSet )
  170. {
  171. if( GetIsKeepout() )
  172. {
  173. // Keepouts can only exist on copper layers
  174. aLayerSet &= LSET::AllCuMask();
  175. }
  176. if( aLayerSet.count() == 0 )
  177. {
  178. return;
  179. }
  180. m_layerSet = aLayerSet;
  181. // Set the single layer to the first selected layer
  182. m_Layer = aLayerSet.Seq()[0];
  183. }
  184. LSET ZONE_CONTAINER::GetLayerSet() const
  185. {
  186. // TODO - Enable multi-layer zones for all zone types
  187. // not just keepout zones
  188. if( GetIsKeepout() )
  189. {
  190. return m_layerSet;
  191. }
  192. else
  193. {
  194. return LSET( m_Layer );
  195. }
  196. }
  197. void ZONE_CONTAINER::ViewGetLayers( int aLayers[], int& aCount ) const
  198. {
  199. if( GetIsKeepout() )
  200. {
  201. LSEQ layers = m_layerSet.Seq();
  202. for( unsigned int idx = 0; idx < layers.size(); idx++ )
  203. {
  204. aLayers[idx] = layers[idx];
  205. }
  206. aCount = layers.size();
  207. }
  208. else
  209. {
  210. aLayers[0] = m_Layer;
  211. aCount = 1;
  212. }
  213. }
  214. bool ZONE_CONTAINER::IsOnLayer( PCB_LAYER_ID aLayer ) const
  215. {
  216. if( GetIsKeepout() )
  217. {
  218. return m_layerSet.test( aLayer );
  219. }
  220. return BOARD_ITEM::IsOnLayer( aLayer );
  221. }
  222. void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode,
  223. const wxPoint& offset )
  224. {
  225. if( !DC )
  226. return;
  227. wxPoint seg_start, seg_end;
  228. PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
  229. BOARD* brd = GetBoard();
  230. auto frame = static_cast<PCB_BASE_FRAME*> ( panel->GetParent() );
  231. PCB_LAYER_ID draw_layer = UNDEFINED_LAYER;
  232. LSET layers = GetLayerSet() & brd->GetVisibleLayers();
  233. // If there are no visible layers and the zone is not highlighted, return
  234. if( layers.count() == 0 && !( aDrawMode & GR_HIGHLIGHT ) )
  235. {
  236. return;
  237. }
  238. /* Keepout zones can exist on multiple layers
  239. * Thus, determining which color to use to render them is a bit tricky.
  240. * In descending order of priority:
  241. *
  242. * 1. If in GR_HIGHLIGHT mode:
  243. * a. If zone is on selected layer, use layer color!
  244. * b. Else, use grey
  245. * 1. Not in GR_HIGHLIGHT mode
  246. * a. If zone is on selected layer, use layer color
  247. * b. Else, use color of top-most (visible) layer
  248. *
  249. */
  250. if( GetIsKeepout() )
  251. {
  252. // At least one layer must be provided!
  253. assert( GetLayerSet().count() > 0 );
  254. // Not on any visible layer?
  255. if( layers.count() == 0 && !( aDrawMode & GR_HIGHLIGHT ) )
  256. {
  257. return;
  258. }
  259. // Is keepout zone present on the selected layer?
  260. if( layers.test( curr_layer ) )
  261. {
  262. draw_layer = curr_layer;
  263. }
  264. else
  265. {
  266. // Select the first (top) visible layer
  267. if( layers.count() > 0 )
  268. {
  269. draw_layer = layers.Seq()[0];
  270. }
  271. else
  272. {
  273. draw_layer = GetLayerSet().Seq()[0];
  274. }
  275. }
  276. }
  277. /* Non-keepout zones are easier to deal with
  278. */
  279. else
  280. {
  281. if( brd->IsLayerVisible( GetLayer() ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
  282. {
  283. return;
  284. }
  285. draw_layer = GetLayer();
  286. }
  287. assert( draw_layer != UNDEFINED_LAYER );
  288. auto color = frame->Settings().Colors().GetLayerColor( draw_layer );
  289. GRSetDrawMode( DC, aDrawMode );
  290. auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
  291. if( displ_opts->m_ContrastModeDisplay )
  292. {
  293. if( !IsOnLayer( curr_layer ) )
  294. {
  295. color = COLOR4D( DARKDARKGRAY );
  296. }
  297. }
  298. if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
  299. {
  300. color.SetToLegacyHighlightColor();
  301. }
  302. color.a = 0.588;
  303. // draw the lines
  304. std::vector<wxPoint> lines;
  305. lines.reserve( (GetNumCorners() * 2) + 2 );
  306. // Iterate through the segments of the outline
  307. for( auto iterator = m_Poly->IterateSegmentsWithHoles(); iterator; iterator++ )
  308. {
  309. // Create the segment
  310. SEG segment = *iterator;
  311. lines.push_back( static_cast<wxPoint>( segment.A ) + offset );
  312. lines.push_back( static_cast<wxPoint>( segment.B ) + offset );
  313. }
  314. GRLineArray( panel->GetClipBox(), DC, lines, 0, color );
  315. // draw hatches
  316. lines.clear();
  317. lines.reserve( (m_HatchLines.size() * 2) + 2 );
  318. for( unsigned ic = 0; ic < m_HatchLines.size(); ic++ )
  319. {
  320. seg_start = static_cast<wxPoint>( m_HatchLines[ic].A ) + offset;
  321. seg_end = static_cast<wxPoint>( m_HatchLines[ic].B ) + offset;
  322. lines.push_back( seg_start );
  323. lines.push_back( seg_end );
  324. }
  325. GRLineArray( panel->GetClipBox(), DC, lines, 0, color );
  326. }
  327. void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
  328. wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset )
  329. {
  330. static std::vector <wxPoint> CornersBuffer;
  331. auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
  332. // outline_mode is false to show filled polys,
  333. // and true to show polygons outlines only (test and debug purposes)
  334. bool outline_mode = displ_opts->m_DisplayZonesMode == 2 ? true : false;
  335. if( DC == NULL )
  336. return;
  337. if( displ_opts->m_DisplayZonesMode == 1 ) // Do not show filled areas
  338. return;
  339. if( m_FilledPolysList.IsEmpty() ) // Nothing to draw
  340. return;
  341. BOARD* brd = GetBoard();
  342. PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
  343. auto frame = static_cast<PCB_BASE_FRAME*> ( panel->GetParent() );
  344. auto color = frame->Settings().Colors().GetLayerColor( GetLayer() );
  345. if( brd->IsLayerVisible( GetLayer() ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
  346. return;
  347. GRSetDrawMode( DC, aDrawMode );
  348. if( displ_opts->m_ContrastModeDisplay )
  349. {
  350. if( !IsOnLayer( curr_layer ) )
  351. color = COLOR4D( DARKDARKGRAY );
  352. }
  353. if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
  354. color.SetToLegacyHighlightColor();
  355. color.a = 0.588;
  356. for ( int ic = 0; ic < m_FilledPolysList.OutlineCount(); ic++ )
  357. {
  358. const SHAPE_LINE_CHAIN& path = m_FilledPolysList.COutline( ic );
  359. CornersBuffer.clear();
  360. wxPoint p0;
  361. for( int j = 0; j < path.PointCount(); j++ )
  362. {
  363. const VECTOR2I& corner = path.CPoint( j );
  364. wxPoint coord( corner.x + offset.x, corner.y + offset.y );
  365. if( j == 0 )
  366. p0 = coord;
  367. CornersBuffer.push_back( coord );
  368. }
  369. CornersBuffer.push_back( p0 );
  370. // Draw outlines:
  371. if( ( m_ZoneMinThickness > 1 ) || outline_mode )
  372. {
  373. int ilim = CornersBuffer.size() - 1;
  374. for( int is = 0, ie = ilim; is <= ilim; ie = is, is++ )
  375. {
  376. int x0 = CornersBuffer[is].x;
  377. int y0 = CornersBuffer[is].y;
  378. int x1 = CornersBuffer[ie].x;
  379. int y1 = CornersBuffer[ie].y;
  380. // Draw only basic outlines, not extra segments.
  381. if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
  382. GRCSegm( panel->GetClipBox(), DC,
  383. x0, y0, x1, y1,
  384. m_ZoneMinThickness, color );
  385. else
  386. GRFillCSegm( panel->GetClipBox(), DC,
  387. x0, y0, x1, y1, m_ZoneMinThickness, color );
  388. }
  389. }
  390. // Draw areas:
  391. if( m_FillMode == ZFM_POLYGONS && !outline_mode )
  392. GRPoly( panel->GetClipBox(), DC, CornersBuffer.size(), &CornersBuffer[0],
  393. true, 0, color, color );
  394. }
  395. if( m_FillMode == 1 && !outline_mode ) // filled with segments
  396. {
  397. for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
  398. {
  399. wxPoint start = (wxPoint) ( m_FillSegmList[ic].A + VECTOR2I(offset) );
  400. wxPoint end = (wxPoint) ( m_FillSegmList[ic].B + VECTOR2I(offset) );
  401. if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
  402. GRCSegm( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y,
  403. m_ZoneMinThickness, color );
  404. else
  405. GRFillCSegm( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y,
  406. m_ZoneMinThickness, color );
  407. }
  408. }
  409. }
  410. const EDA_RECT ZONE_CONTAINER::GetBoundingBox() const
  411. {
  412. const int PRELOAD = 0x7FFFFFFF; // Biggest integer (32 bits)
  413. int ymax = -PRELOAD;
  414. int ymin = PRELOAD;
  415. int xmin = PRELOAD;
  416. int xmax = -PRELOAD;
  417. int count = GetNumCorners();
  418. for( int i = 0; i<count; ++i )
  419. {
  420. wxPoint corner = static_cast<wxPoint>( GetCornerPosition( i ) );
  421. ymax = std::max( ymax, corner.y );
  422. xmax = std::max( xmax, corner.x );
  423. ymin = std::min( ymin, corner.y );
  424. xmin = std::min( xmin, corner.x );
  425. }
  426. EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
  427. return ret;
  428. }
  429. void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC,
  430. GR_DRAWMODE draw_mode )
  431. {
  432. GR_DRAWMODE current_gr_mode = draw_mode;
  433. bool is_close_segment = false;
  434. if( !DC )
  435. return;
  436. PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
  437. auto frame = static_cast<PCB_BASE_FRAME*> ( panel->GetParent() );
  438. auto color = frame->Settings().Colors().GetLayerColor( GetLayer() );
  439. auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
  440. if( displ_opts->m_ContrastModeDisplay )
  441. {
  442. if( !IsOnLayer( curr_layer ) )
  443. color = COLOR4D( DARKDARKGRAY );
  444. }
  445. // Object to iterate through the corners of the outlines
  446. SHAPE_POLY_SET::ITERATOR iterator = m_Poly->Iterate();
  447. // Segment start and end
  448. VECTOR2I seg_start, seg_end;
  449. // Remember the first point of this contour
  450. VECTOR2I contour_first_point = *iterator;
  451. // Iterate through all the corners of the outlines and build the segments to draw
  452. while( iterator )
  453. {
  454. // Get the first point of the current segment
  455. seg_start = *iterator;
  456. // Get the last point of the current segment, handling the case where the end of the
  457. // contour is reached, when the last point of the segment is the first point of the
  458. // contour
  459. if( !iterator.IsEndContour() )
  460. {
  461. // Set GR mode to default
  462. current_gr_mode = draw_mode;
  463. SHAPE_POLY_SET::ITERATOR iterator_copy = iterator;
  464. iterator_copy++;
  465. if( iterator_copy.IsEndContour() )
  466. current_gr_mode = GR_XOR;
  467. is_close_segment = false;
  468. iterator++;
  469. seg_end = *iterator;
  470. }
  471. else
  472. {
  473. is_close_segment = true;
  474. seg_end = contour_first_point;
  475. // Reassign first point of the contour to the next contour start
  476. iterator++;
  477. if( iterator )
  478. contour_first_point = *iterator;
  479. // Set GR mode to XOR
  480. current_gr_mode = GR_XOR;
  481. }
  482. GRSetDrawMode( DC, current_gr_mode );
  483. if( is_close_segment )
  484. GRLine( panel->GetClipBox(), DC, seg_start.x, seg_start.y, seg_end.x, seg_end.y, 0,
  485. WHITE );
  486. else
  487. GRLine( panel->GetClipBox(), DC, seg_start.x, seg_start.y, seg_end.x, seg_end.y, 0,
  488. color );
  489. }
  490. }
  491. int ZONE_CONTAINER::GetThermalReliefGap( D_PAD* aPad ) const
  492. {
  493. if( aPad == NULL || aPad->GetThermalGap() == 0 )
  494. return m_ThermalReliefGap;
  495. else
  496. return aPad->GetThermalGap();
  497. }
  498. int ZONE_CONTAINER::GetThermalReliefCopperBridge( D_PAD* aPad ) const
  499. {
  500. if( aPad == NULL || aPad->GetThermalWidth() == 0 )
  501. return m_ThermalReliefCopperBridge;
  502. else
  503. return aPad->GetThermalWidth();
  504. }
  505. void ZONE_CONTAINER::SetCornerRadius( unsigned int aRadius )
  506. {
  507. m_cornerRadius = aRadius;
  508. }
  509. bool ZONE_CONTAINER::HitTest( const wxPoint& aPosition ) const
  510. {
  511. // Normally accuracy is zoom-relative, but for the generic HitTest we just use
  512. // a fixed (small) value.
  513. int accuracy = Millimeter2iu( 0.05 );
  514. return HitTestForCorner( aPosition, accuracy * 2 ) || HitTestForEdge( aPosition, accuracy );
  515. }
  516. void ZONE_CONTAINER::SetSelectedCorner( const wxPoint& aPosition, int aAccuracy )
  517. {
  518. SHAPE_POLY_SET::VERTEX_INDEX corner;
  519. // If there is some corner to be selected, assign it to m_CornerSelection
  520. if( HitTestForCorner( aPosition, aAccuracy * 2, corner )
  521. || HitTestForEdge( aPosition, aAccuracy, corner ) )
  522. {
  523. if( m_CornerSelection == nullptr )
  524. m_CornerSelection = new SHAPE_POLY_SET::VERTEX_INDEX;
  525. *m_CornerSelection = corner;
  526. }
  527. }
  528. bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos, int aAccuracy,
  529. SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const
  530. {
  531. return m_Poly->CollideVertex( VECTOR2I( refPos ), aCornerHit, aAccuracy );
  532. }
  533. bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos, int aAccuracy ) const
  534. {
  535. SHAPE_POLY_SET::VERTEX_INDEX dummy;
  536. return HitTestForCorner( refPos, aAccuracy, dummy );
  537. }
  538. bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos, int aAccuracy,
  539. SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const
  540. {
  541. return m_Poly->CollideEdge( VECTOR2I( refPos ), aCornerHit, aAccuracy );
  542. }
  543. bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos, int aAccuracy ) const
  544. {
  545. SHAPE_POLY_SET::VERTEX_INDEX dummy;
  546. return HitTestForEdge( refPos, aAccuracy, dummy );
  547. }
  548. bool ZONE_CONTAINER::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
  549. {
  550. // Calculate bounding box for zone
  551. EDA_RECT bbox = GetBoundingBox();
  552. bbox.Normalize();
  553. EDA_RECT arect = aRect;
  554. arect.Normalize();
  555. arect.Inflate( aAccuracy );
  556. if( aContained )
  557. {
  558. return arect.Contains( bbox );
  559. }
  560. else // Test for intersection between aBox and the polygon
  561. // For a polygon, using its bounding box has no sense here
  562. {
  563. // Fast test: if aBox is outside the polygon bounding box,
  564. // rectangles cannot intersect
  565. if( !arect.Intersects( bbox ) )
  566. return false;
  567. // aBox is inside the polygon bounding box,
  568. // and can intersect the polygon: use a fine test.
  569. // aBox intersects the polygon if at least one aBox corner
  570. // is inside the polygon
  571. /*
  572. wxPoint origin = arect.GetOrigin();
  573. int w = arect.GetWidth();
  574. int h = arect.GetHeight();
  575. if ( HitTestInsideZone( origin ) ||
  576. HitTestInsideZone( origin + wxPoint( w, 0 ) ) ||
  577. HitTestInsideZone( origin + wxPoint( w, h ) ) ||
  578. HitTestInsideZone( origin + wxPoint( 0, h ) ) )
  579. {
  580. return true;
  581. }
  582. */
  583. // No corner inside aBox, but outlines can intersect aBox
  584. // if one of outline corners is inside aBox
  585. int count = m_Poly->TotalVertices();
  586. for( int ii =0; ii < count; ii++ )
  587. {
  588. auto vertex = m_Poly->Vertex( ii );
  589. auto vertexNext = m_Poly->Vertex( ( ii + 1 ) % count );
  590. // Test if the point is within the rect
  591. if( arect.Contains( ( wxPoint ) vertex ) )
  592. {
  593. return true;
  594. }
  595. // Test if this edge intersects the rect
  596. if( arect.Intersects( ( wxPoint ) vertex, ( wxPoint ) vertexNext ) )
  597. {
  598. return true;
  599. }
  600. }
  601. return false;
  602. }
  603. }
  604. int ZONE_CONTAINER::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
  605. {
  606. int myClearance = m_ZoneClearance;
  607. #if 1 // Maybe the netclass clearance should not come into play for a zone?
  608. // At least the policy decision can be controlled by the zone
  609. // itself, i.e. here. On reasons of insufficient documentation,
  610. // the user will be less bewildered if we simply respect the
  611. // "zone clearance" setting in the zone properties dialog. (At least
  612. // until there is a UI boolean for this.)
  613. NETCLASSPTR myClass = GetNetClass();
  614. if( myClass )
  615. myClearance = std::max( myClearance, myClass->GetClearance() );
  616. #endif
  617. if( aItem )
  618. {
  619. int hisClearance = aItem->GetClearance( NULL );
  620. myClearance = std::max( hisClearance, myClearance );
  621. }
  622. return myClearance;
  623. }
  624. bool ZONE_CONTAINER::HitTestFilledArea( const wxPoint& aRefPos ) const
  625. {
  626. return m_FilledPolysList.Contains( VECTOR2I( aRefPos.x, aRefPos.y ) );
  627. }
  628. void ZONE_CONTAINER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
  629. {
  630. wxString msg;
  631. msg = _( "Zone Outline" );
  632. // Display Cutout instead of Outline for holes inside a zone
  633. // i.e. when num contour !=0
  634. // Check whether the selected corner is in a hole; i.e., in any contour but the first one.
  635. if( m_CornerSelection != nullptr && m_CornerSelection->m_contour > 0 )
  636. msg << wxT( " " ) << _( "(Cutout)" );
  637. aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
  638. if( GetIsKeepout() )
  639. {
  640. msg.Empty();
  641. if( GetDoNotAllowVias() )
  642. AccumulateDescription( msg, _( "No via" ) );
  643. if( GetDoNotAllowTracks() )
  644. AccumulateDescription( msg, _("No track") );
  645. if( GetDoNotAllowCopperPour() )
  646. AccumulateDescription( msg, _("No copper pour") );
  647. aList.push_back( MSG_PANEL_ITEM( _( "Keepout" ), msg, RED ) );
  648. }
  649. else if( IsOnCopperLayer() )
  650. {
  651. if( GetNetCode() >= 0 )
  652. {
  653. NETINFO_ITEM* net = GetNet();
  654. if( net )
  655. msg = net->GetNetname();
  656. else // Should not occur
  657. msg = _( "<unknown>" );
  658. }
  659. else // a netcode < 0 is an error
  660. msg = wxT( "<error>" );
  661. aList.push_back( MSG_PANEL_ITEM( _( "NetName" ), msg, RED ) );
  662. // Display net code : (useful in test or debug)
  663. msg.Printf( wxT( "%d" ), GetNetCode() );
  664. aList.push_back( MSG_PANEL_ITEM( _( "NetCode" ), msg, RED ) );
  665. // Display priority level
  666. msg.Printf( wxT( "%d" ), GetPriority() );
  667. aList.push_back( MSG_PANEL_ITEM( _( "Priority" ), msg, BLUE ) );
  668. }
  669. else
  670. {
  671. aList.push_back( MSG_PANEL_ITEM( _( "Non Copper Zone" ), wxEmptyString, RED ) );
  672. }
  673. aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BROWN ) );
  674. msg.Printf( wxT( "%d" ), (int) m_Poly->TotalVertices() );
  675. aList.push_back( MSG_PANEL_ITEM( _( "Corners" ), msg, BLUE ) );
  676. if( m_FillMode )
  677. msg = _( "Segments" );
  678. else
  679. msg = _( "Polygons" );
  680. aList.push_back( MSG_PANEL_ITEM( _( "Fill Mode" ), msg, BROWN ) );
  681. // Useful for statistics :
  682. msg.Printf( wxT( "%d" ), (int) m_HatchLines.size() );
  683. aList.push_back( MSG_PANEL_ITEM( _( "Hatch Lines" ), msg, BLUE ) );
  684. if( !m_FilledPolysList.IsEmpty() )
  685. {
  686. msg.Printf( wxT( "%d" ), m_FilledPolysList.TotalVertices() );
  687. aList.push_back( MSG_PANEL_ITEM( _( "Corner Count" ), msg, BLUE ) );
  688. }
  689. }
  690. /* Geometric transforms: */
  691. void ZONE_CONTAINER::Move( const wxPoint& offset )
  692. {
  693. /* move outlines */
  694. m_Poly->Move( VECTOR2I( offset ) );
  695. Hatch();
  696. m_FilledPolysList.Move( VECTOR2I( offset.x, offset.y ) );
  697. for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
  698. {
  699. m_FillSegmList[ic].A += VECTOR2I(offset);
  700. m_FillSegmList[ic].B += VECTOR2I(offset);
  701. }
  702. }
  703. void ZONE_CONTAINER::MoveEdge( const wxPoint& offset, int aEdge )
  704. {
  705. int next_corner;
  706. if( m_Poly->GetNeighbourIndexes( aEdge, nullptr, &next_corner ) )
  707. {
  708. m_Poly->Vertex( aEdge ) += VECTOR2I( offset );
  709. m_Poly->Vertex( next_corner ) += VECTOR2I( offset );
  710. Hatch();
  711. }
  712. }
  713. void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle )
  714. {
  715. wxPoint pos;
  716. for( auto iterator = m_Poly->IterateWithHoles(); iterator; iterator++ )
  717. {
  718. pos = static_cast<wxPoint>( *iterator );
  719. RotatePoint( &pos, centre, angle );
  720. iterator->x = pos.x;
  721. iterator->y = pos.y;
  722. }
  723. Hatch();
  724. /* rotate filled areas: */
  725. for( auto ic = m_FilledPolysList.Iterate(); ic; ++ic )
  726. RotatePoint( &ic->x, &ic->y, centre.x, centre.y, angle );
  727. for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
  728. {
  729. wxPoint a( m_FillSegmList[ic].A );
  730. RotatePoint( &a, centre, angle );
  731. m_FillSegmList[ic].A = a;
  732. wxPoint b( m_FillSegmList[ic].B );
  733. RotatePoint( &b, centre, angle );
  734. m_FillSegmList[ic].B = a;
  735. }
  736. }
  737. void ZONE_CONTAINER::Flip( const wxPoint& aCentre )
  738. {
  739. Mirror( aCentre );
  740. int copperLayerCount = GetBoard()->GetCopperLayerCount();
  741. if( GetIsKeepout() )
  742. {
  743. SetLayerSet( FlipLayerMask( GetLayerSet(), copperLayerCount ) );
  744. }
  745. else
  746. {
  747. SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
  748. }
  749. }
  750. void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
  751. {
  752. for( auto iterator = m_Poly->IterateWithHoles(); iterator; iterator++ )
  753. {
  754. int py = mirror_ref.y - iterator->y;
  755. iterator->y = py + mirror_ref.y;
  756. }
  757. Hatch();
  758. for( auto ic = m_FilledPolysList.Iterate(); ic; ++ic )
  759. {
  760. int py = mirror_ref.y - ic->y;
  761. ic->y = py + mirror_ref.y;
  762. }
  763. for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
  764. {
  765. MIRROR( m_FillSegmList[ic].A.y, mirror_ref.y );
  766. MIRROR( m_FillSegmList[ic].B.y, mirror_ref.y );
  767. }
  768. }
  769. ZoneConnection ZONE_CONTAINER::GetPadConnection( D_PAD* aPad ) const
  770. {
  771. if( aPad == NULL || aPad->GetZoneConnection() == PAD_ZONE_CONN_INHERITED )
  772. return m_PadConnection;
  773. else
  774. return aPad->GetZoneConnection();
  775. }
  776. void ZONE_CONTAINER::AddPolygon( std::vector< wxPoint >& aPolygon )
  777. {
  778. if( aPolygon.empty() )
  779. return;
  780. SHAPE_LINE_CHAIN outline;
  781. // Create an outline and populate it with the points of aPolygon
  782. for( unsigned i = 0; i < aPolygon.size(); i++ )
  783. {
  784. outline.Append( VECTOR2I( aPolygon[i] ) );
  785. }
  786. outline.SetClosed( true );
  787. // Add the outline as a new polygon in the polygon set
  788. if( m_Poly->OutlineCount() == 0 )
  789. m_Poly->AddOutline( outline );
  790. else
  791. m_Poly->AddHole( outline );
  792. }
  793. bool ZONE_CONTAINER::AppendCorner( wxPoint aPosition, int aHoleIdx, bool aAllowDuplication )
  794. {
  795. // Ensure the main outline exists:
  796. if( m_Poly->OutlineCount() == 0 )
  797. m_Poly->NewOutline();
  798. // If aHoleIdx >= 0, the corner musty be added to the hole, index aHoleIdx.
  799. // (remember: the index of the first hole is 0)
  800. // Return error if if does dot exist.
  801. if( aHoleIdx >= m_Poly->HoleCount( 0 ) )
  802. return false;
  803. m_Poly->Append( aPosition.x, aPosition.y, -1, aHoleIdx, aAllowDuplication );
  804. return true;
  805. }
  806. wxString ZONE_CONTAINER::GetSelectMenuText( EDA_UNITS_T aUnits ) const
  807. {
  808. wxString text;
  809. // Check whether the selected contour is a hole (contour index > 0)
  810. if( m_CornerSelection != nullptr && m_CornerSelection->m_contour > 0 )
  811. text << wxT( " " ) << _( "(Cutout)" );
  812. if( GetIsKeepout() )
  813. text << wxT( " " ) << _( "(Keepout)" );
  814. else
  815. text << GetNetnameMsg();
  816. return wxString::Format( _( "Zone Outline %s on %s" ), text, GetLayerName() );
  817. }
  818. int ZONE_CONTAINER::GetHatchPitch() const
  819. {
  820. return m_hatchPitch;
  821. }
  822. void ZONE_CONTAINER::SetHatch( int aHatchStyle, int aHatchPitch, bool aRebuildHatch )
  823. {
  824. SetHatchPitch( aHatchPitch );
  825. m_hatchStyle = (ZONE_CONTAINER::HATCH_STYLE) aHatchStyle;
  826. if( aRebuildHatch )
  827. Hatch();
  828. }
  829. void ZONE_CONTAINER::SetHatchPitch( int aPitch )
  830. {
  831. m_hatchPitch = aPitch;
  832. }
  833. void ZONE_CONTAINER::UnHatch()
  834. {
  835. m_HatchLines.clear();
  836. }
  837. // Creates hatch lines inside the outline of the complex polygon
  838. // sort function used in ::Hatch to sort points by descending wxPoint.x values
  839. bool sortEndsByDescendingX( const VECTOR2I& ref, const VECTOR2I& tst )
  840. {
  841. return tst.x < ref.x;
  842. }
  843. void ZONE_CONTAINER::Hatch()
  844. {
  845. UnHatch();
  846. if( m_hatchStyle == NO_HATCH || m_hatchPitch == 0 || m_Poly->IsEmpty() )
  847. return;
  848. // define range for hatch lines
  849. int min_x = m_Poly->Vertex( 0 ).x;
  850. int max_x = m_Poly->Vertex( 0 ).x;
  851. int min_y = m_Poly->Vertex( 0 ).y;
  852. int max_y = m_Poly->Vertex( 0 ).y;
  853. for( auto iterator = m_Poly->IterateWithHoles(); iterator; iterator++ )
  854. {
  855. if( iterator->x < min_x )
  856. min_x = iterator->x;
  857. if( iterator->x > max_x )
  858. max_x = iterator->x;
  859. if( iterator->y < min_y )
  860. min_y = iterator->y;
  861. if( iterator->y > max_y )
  862. max_y = iterator->y;
  863. }
  864. // Calculate spacing between 2 hatch lines
  865. int spacing;
  866. if( m_hatchStyle == DIAGONAL_EDGE )
  867. spacing = m_hatchPitch;
  868. else
  869. spacing = m_hatchPitch * 2;
  870. // set the "length" of hatch lines (the length on horizontal axis)
  871. int hatch_line_len = m_hatchPitch;
  872. // To have a better look, give a slope depending on the layer
  873. LAYER_NUM layer = GetLayer();
  874. int slope_flag = (layer & 1) ? 1 : -1; // 1 or -1
  875. double slope = 0.707106 * slope_flag; // 45 degrees slope
  876. int max_a, min_a;
  877. if( slope_flag == 1 )
  878. {
  879. max_a = KiROUND( max_y - slope * min_x );
  880. min_a = KiROUND( min_y - slope * max_x );
  881. }
  882. else
  883. {
  884. max_a = KiROUND( max_y - slope * max_x );
  885. min_a = KiROUND( min_y - slope * min_x );
  886. }
  887. min_a = (min_a / spacing) * spacing;
  888. // calculate an offset depending on layer number,
  889. // for a better look of hatches on a multilayer board
  890. int offset = (layer * 7) / 8;
  891. min_a += offset;
  892. // loop through hatch lines
  893. #define MAXPTS 200 // Usually we store only few values per one hatch line
  894. // depending on the complexity of the zone outline
  895. static std::vector<VECTOR2I> pointbuffer;
  896. pointbuffer.clear();
  897. pointbuffer.reserve( MAXPTS + 2 );
  898. for( int a = min_a; a < max_a; a += spacing )
  899. {
  900. // get intersection points for this hatch line
  901. // Note: because we should have an even number of intersections with the
  902. // current hatch line and the zone outline (a closed polygon,
  903. // or a set of closed polygons), if an odd count is found
  904. // we skip this line (should not occur)
  905. pointbuffer.clear();
  906. // Iterate through all vertices
  907. for( auto iterator = m_Poly->IterateSegmentsWithHoles(); iterator; iterator++ )
  908. {
  909. double x, y, x2, y2;
  910. int ok;
  911. SEG segment = *iterator;
  912. ok = FindLineSegmentIntersection( a, slope,
  913. segment.A.x, segment.A.y,
  914. segment.B.x, segment.B.y,
  915. &x, &y, &x2, &y2 );
  916. if( ok )
  917. {
  918. VECTOR2I point( KiROUND( x ), KiROUND( y ) );
  919. pointbuffer.push_back( point );
  920. }
  921. if( ok == 2 )
  922. {
  923. VECTOR2I point( KiROUND( x2 ), KiROUND( y2 ) );
  924. pointbuffer.push_back( point );
  925. }
  926. if( pointbuffer.size() >= MAXPTS ) // overflow
  927. {
  928. wxASSERT( 0 );
  929. break;
  930. }
  931. }
  932. // ensure we have found an even intersection points count
  933. // because intersections are the ends of segments
  934. // inside the polygon(s) and a segment has 2 ends.
  935. // if not, this is a strange case (a bug ?) so skip this hatch
  936. if( pointbuffer.size() % 2 != 0 )
  937. continue;
  938. // sort points in order of descending x (if more than 2) to
  939. // ensure the starting point and the ending point of the same segment
  940. // are stored one just after the other.
  941. if( pointbuffer.size() > 2 )
  942. sort( pointbuffer.begin(), pointbuffer.end(), sortEndsByDescendingX );
  943. // creates lines or short segments inside the complex polygon
  944. for( unsigned ip = 0; ip < pointbuffer.size(); ip += 2 )
  945. {
  946. int dx = pointbuffer[ip + 1].x - pointbuffer[ip].x;
  947. // Push only one line for diagonal hatch,
  948. // or for small lines < twice the line length
  949. // else push 2 small lines
  950. if( m_hatchStyle == DIAGONAL_FULL || std::abs( dx ) < 2 * hatch_line_len )
  951. {
  952. m_HatchLines.push_back( SEG( pointbuffer[ip], pointbuffer[ip + 1] ) );
  953. }
  954. else
  955. {
  956. double dy = pointbuffer[ip + 1].y - pointbuffer[ip].y;
  957. slope = dy / dx;
  958. if( dx > 0 )
  959. dx = hatch_line_len;
  960. else
  961. dx = -hatch_line_len;
  962. int x1 = KiROUND( pointbuffer[ip].x + dx );
  963. int x2 = KiROUND( pointbuffer[ip + 1].x - dx );
  964. int y1 = KiROUND( pointbuffer[ip].y + dx * slope );
  965. int y2 = KiROUND( pointbuffer[ip + 1].y - dx * slope );
  966. m_HatchLines.push_back(SEG(pointbuffer[ip].x, pointbuffer[ip].y, x1, y1));
  967. m_HatchLines.push_back( SEG( pointbuffer[ip+1].x, pointbuffer[ip+1].y, x2, y2 ) );
  968. }
  969. }
  970. }
  971. }
  972. int ZONE_CONTAINER::GetDefaultHatchPitch()
  973. {
  974. return Mils2iu( 20 );
  975. }
  976. BITMAP_DEF ZONE_CONTAINER::GetMenuImage() const
  977. {
  978. return add_zone_xpm;
  979. }
  980. void ZONE_CONTAINER::SwapData( BOARD_ITEM* aImage )
  981. {
  982. assert( aImage->Type() == PCB_ZONE_AREA_T );
  983. std::swap( *((ZONE_CONTAINER*) this), *((ZONE_CONTAINER*) aImage) );
  984. }
  985. void ZONE_CONTAINER::CacheTriangulation()
  986. {
  987. m_FilledPolysList.CacheTriangulation();
  988. }
  989. bool ZONE_CONTAINER::BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly ) const
  990. {
  991. if( GetNumCorners() <= 2 ) // malformed zone. polygon calculations do not like it ...
  992. return false;
  993. // Make a smoothed polygon out of the user-drawn polygon if required
  994. switch( m_cornerSmoothingType )
  995. {
  996. case ZONE_SETTINGS::SMOOTHING_CHAMFER:
  997. aSmoothedPoly = m_Poly->Chamfer( m_cornerRadius );
  998. break;
  999. case ZONE_SETTINGS::SMOOTHING_FILLET:
  1000. // Note: we're now using m_ArcToSegmentsCount only as a hint to determine accuracy
  1001. // vs. speed.
  1002. if( m_ArcToSegmentsCount > SEGMENT_COUNT_CROSSOVER )
  1003. aSmoothedPoly = m_Poly->Fillet( m_cornerRadius, ARC_HIGH_DEF );
  1004. else
  1005. aSmoothedPoly = m_Poly->Fillet( m_cornerRadius, ARC_LOW_DEF );
  1006. break;
  1007. default:
  1008. // Acute angles between adjacent edges can create issues in calculations,
  1009. // in inflate/deflate outlines transforms, especially when the angle is very small.
  1010. // We can avoid issues by creating a very small chamfer which remove acute angles,
  1011. // or left it without chamfer and use only CPOLYGONS_LIST::InflateOutline to create
  1012. // clearance areas
  1013. aSmoothedPoly = m_Poly->Chamfer( Millimeter2iu( 0.0 ) );
  1014. break;
  1015. }
  1016. return true;
  1017. };
  1018. /* Function TransformOutlinesShapeWithClearanceToPolygon
  1019. * Convert the zone filled areas polygons to polygons
  1020. * inflated (optional) by max( aClearanceValue, the zone clearance)
  1021. * and copy them in aCornerBuffer
  1022. * param aClearanceValue = the clearance around polygons
  1023. * param aAddClearance = true to add a clearance area to the polygon
  1024. * false to create the outline polygon.
  1025. */
  1026. void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon(
  1027. SHAPE_POLY_SET& aCornerBuffer, int aMinClearanceValue, bool aUseNetClearance ) const
  1028. {
  1029. // Creates the zone outline polygon (with holes if any)
  1030. SHAPE_POLY_SET polybuffer;
  1031. BuildSmoothedPoly( polybuffer );
  1032. // add clearance to outline
  1033. int clearance = aMinClearanceValue;
  1034. if( aUseNetClearance && IsOnCopperLayer() )
  1035. {
  1036. clearance = GetClearance();
  1037. if( aMinClearanceValue > clearance )
  1038. clearance = aMinClearanceValue;
  1039. }
  1040. // Calculate the polygon with clearance
  1041. // holes are linked to the main outline, so only one polygon is created.
  1042. if( clearance )
  1043. polybuffer.Inflate( clearance, ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF );
  1044. polybuffer.Fracture( SHAPE_POLY_SET::PM_FAST );
  1045. aCornerBuffer.Append( polybuffer );
  1046. }