KiCad PCB EDA Suite
zone_filler.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014-2017 CERN
5  * Copyright (C) 2014-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Tomasz W┼éostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * 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 #include <cstdint>
27 #include <thread>
28 #include <mutex>
29 #include <algorithm>
30 #include <future>
31 
32 #include <class_board.h>
33 #include <class_zone.h>
34 #include <class_module.h>
35 #include <class_edge_mod.h>
36 #include <class_drawsegment.h>
37 #include <class_track.h>
38 #include <class_pcb_text.h>
39 #include <class_pcb_target.h>
40 
42 #include <board_commit.h>
43 
45 
47 #include <geometry/shape_file_io.h>
48 #include <geometry/convex_hull.h>
50 #include <confirm.h>
51 
52 #include "zone_filler.h"
53 
54 
56 {
57 public:
59  {
60  m_reporter = aReporter;
61 
62  if( aReporter )
63  aReporter->Hide();
64  }
65 
67  {
68  if( m_reporter )
69  m_reporter->Show();
70  }
71 
72 private:
74 };
75 
76 
77 extern void CreateThermalReliefPadPolygon( SHAPE_POLY_SET& aCornerBuffer,
78  const D_PAD& aPad, int aThermalGap, int aCopperThickness,
79  int aMinThicknessValue, int aCircleToSegmentsCount,
80  double aCorrectionFactor, double aThermalRot );
81 
82 static double s_thermalRot = 450; // angle of stubs in thermal reliefs for round pads
83 static const bool s_DumpZonesWhenFilling = false;
84 
85 
86 ZONE_FILLER::ZONE_FILLER( BOARD* aBoard, COMMIT* aCommit ) :
87  m_board( aBoard ), m_commit( aCommit ), m_progressReporter( nullptr )
88 {
89 }
90 
91 
93 {
94 }
95 
96 
98 {
99  m_progressReporter = aReporter;
100 }
101 
102 
103 bool ZONE_FILLER::Fill( const std::vector<ZONE_CONTAINER*>& aZones, bool aCheck )
104 {
105  std::vector<CN_ZONE_ISOLATED_ISLAND_LIST> toFill;
106  auto connectivity = m_board->GetConnectivity();
107 
108  std::unique_lock<std::mutex> lock( connectivity->GetLock(), std::try_to_lock );
109 
110  if( !lock )
111  return false;
112 
113  if( m_progressReporter )
114  {
115  m_progressReporter->Report( _( "Checking zone fills..." ) );
116  m_progressReporter->SetMaxProgress( toFill.size() );
117  }
118 
119  for( auto zone : aZones )
120  {
121  // Keepout zones are not filled
122  if( zone->GetIsKeepout() )
123  continue;
124 
125  if( m_commit )
126  m_commit->Modify( zone );
127 
128  // calculate the hash value for filled areas. it will be used later
129  // to know if the current filled areas are up to date
130  zone->BuildHashValue();
131 
132  // Add the zone to the list of zones to test or refill
133  toFill.emplace_back( CN_ZONE_ISOLATED_ISLAND_LIST(zone) );
134 
135  // Remove existing fill first to prevent drawing invalid polygons
136  // on some platforms
137  zone->UnFill();
138  }
139 
140  std::atomic<size_t> nextItem( 0 );
141  size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency(), toFill.size() );
142  std::vector<std::future<size_t>> returns( parallelThreadCount );
143 
144  auto fill_lambda = [&] ( PROGRESS_REPORTER* aReporter ) -> size_t
145  {
146  size_t num = 0;
147 
148  for( size_t i = nextItem++; i < toFill.size(); i = nextItem++ )
149  {
150  ZONE_CONTAINER* zone = toFill[i].m_zone;
151  SHAPE_POLY_SET rawPolys, finalPolys;
152  fillSingleZone( zone, rawPolys, finalPolys );
153 
154  zone->SetRawPolysList( rawPolys );
155  zone->SetFilledPolysList( finalPolys );
156  zone->SetIsFilled( true );
157 
158  if( m_progressReporter )
160 
161  num++;
162  }
163 
164  return num;
165  };
166 
167  if( parallelThreadCount <= 1 )
168  fill_lambda( m_progressReporter );
169  else
170  {
171  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
172  returns[ii] = std::async( std::launch::async, fill_lambda, m_progressReporter );
173 
174  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
175  {
176  // Here we balance returns with a 100ms timeout to allow UI updating
177  std::future_status status;
178  do
179  {
180  if( m_progressReporter )
182 
183  status = returns[ii].wait_for( std::chrono::milliseconds( 100 ) );
184  } while( status != std::future_status::ready );
185  }
186  }
187 
188  // Now update the connectivity to check for copper islands
189  if( m_progressReporter )
190  {
192  m_progressReporter->Report( _( "Removing insulated copper islands..." ) );
194  }
195 
196  connectivity->SetProgressReporter( m_progressReporter );
197  connectivity->FindIsolatedCopperIslands( toFill );
198 
199  // Now remove insulated copper islands and islands outside the board edge
200  bool outOfDate = false;
201  SHAPE_POLY_SET boardOutline;
202  bool clip_to_brd_outlines = m_board->GetBoardPolygonOutlines( boardOutline );
203 
204  for( auto& zone : toFill )
205  {
206  std::sort( zone.m_islands.begin(), zone.m_islands.end(), std::greater<int>() );
207  SHAPE_POLY_SET poly = zone.m_zone->GetFilledPolysList();
208 
209  // Remove solid areas outside the board cutouts and the insulated islands
210  // only zones with net code > 0 can have insulated islands by definition
211  if( zone.m_zone->GetNetCode() > 0 )
212  {
213  // solid areas outside the board cutouts are also removed, because they are usually
214  // insulated islands
215  for( auto idx : zone.m_islands )
216  {
217  poly.DeletePolygon( idx );
218  }
219  }
220  // Zones with no net can have areas outside the board cutouts.
221  // Please, use only this clipping for no-net zones: this is a very time consumming
222  // calculation (x 5 in a test case if made for all zones), mainly due to poly.Fracture
223  else if( clip_to_brd_outlines )
224  {
225  poly.BooleanIntersection( boardOutline, SHAPE_POLY_SET::PM_FAST );
226  poly.Fracture( SHAPE_POLY_SET::PM_FAST );
227  }
228 
229  zone.m_zone->SetFilledPolysList( poly );
230 
231  if( aCheck && zone.m_zone->GetHashValue() != poly.GetHash() )
232  outOfDate = true;
233  }
234 
235  if( aCheck && outOfDate )
236  {
238  KIDIALOG dlg( m_progressReporter->GetParent(),
239  _( "Zone fills are out-of-date. Refill?" ),
240  _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
241  dlg.SetOKCancelLabels( _( "Refill" ), _( "Continue without Refill" ) );
242  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
243 
244  if( dlg.ShowModal() == wxID_CANCEL )
245  {
246  if( m_commit )
247  m_commit->Revert();
248 
249  connectivity->SetProgressReporter( nullptr );
250  return false;
251  }
252  }
253 
254  if( m_progressReporter )
255  {
257  m_progressReporter->Report( _( "Performing polygon fills..." ) );
258  m_progressReporter->SetMaxProgress( toFill.size() );
259  }
260 
261 
262  nextItem = 0;
263 
264  auto tri_lambda = [&] ( PROGRESS_REPORTER* aReporter ) -> size_t
265  {
266  size_t num = 0;
267 
268  for( size_t i = nextItem++; i < toFill.size(); i = nextItem++ )
269  {
270  toFill[i].m_zone->CacheTriangulation();
271  num++;
272 
273  if( m_progressReporter )
275  }
276 
277  return num;
278  };
279 
280  if( parallelThreadCount <= 1 )
281  tri_lambda( m_progressReporter );
282  else
283  {
284  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
285  returns[ii] = std::async( std::launch::async, tri_lambda, m_progressReporter );
286 
287  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
288  {
289  // Here we balance returns with a 100ms timeout to allow UI updating
290  std::future_status status;
291  do
292  {
293  if( m_progressReporter )
295 
296  status = returns[ii].wait_for( std::chrono::milliseconds( 100 ) );
297  } while( status != std::future_status::ready );
298  }
299  }
300 
301  if( m_progressReporter )
302  {
304  m_progressReporter->Report( _( "Committing changes..." ) );
306  }
307 
308  connectivity->SetProgressReporter( nullptr );
309 
310  if( m_commit )
311  {
312  m_commit->Push( _( "Fill Zone(s)" ), false );
313  }
314  else
315  {
316  for( auto& i : toFill )
317  connectivity->Update( i.m_zone );
318 
319  connectivity->RecalculateRatsnest();
320  }
321 
322  return true;
323 }
324 
325 
327  SHAPE_POLY_SET& aFeatures ) const
328 {
329  // Set the number of segments in arc approximations
330  // Since we can no longer edit the segment count in pcbnew, we set
331  // the fill to our high-def count to avoid jagged knock-outs
332  // However, if the user has edited their zone to increase the segment count,
333  // we keep this preference
334  int segsPerCircle = std::max( aZone->GetArcSegmentCount(), ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF );
335 
336  /* calculates the coeff to compensate radius reduction of holes clearance
337  * due to the segment approx.
338  * For a circle the min radius is radius * cos( 2PI / segsPerCircle / 2)
339  * correctionFactor is 1 /cos( PI/segsPerCircle )
340  */
341  double correctionFactor = GetCircletoPolyCorrectionFactor( segsPerCircle );
342 
343  aFeatures.RemoveAllContours();
344 
345  int zone_clearance = aZone->GetClearance();
346  int edgeClearance = m_board->GetDesignSettings().m_CopperEdgeClearance;
347  int zone_to_edgecut_clearance = std::max( aZone->GetZoneClearance(), edgeClearance );
348 
349  // When removing holes, the holes must be expanded by outline_half_thickness
350  // to take in account the thickness of the zone outlines
351  int outline_half_thickness = aZone->GetMinThickness() / 2;
352  zone_clearance += outline_half_thickness;
353  zone_to_edgecut_clearance += outline_half_thickness;
354 
355  /* store holes (i.e. tracks and pads areas as polygons outlines)
356  * in a polygon list
357  */
358 
359  /* items ouside the zone bounding box are skipped
360  * the bounding box is the zone bounding box + the biggest clearance found in Netclass list
361  */
362  EDA_RECT item_boundingbox;
363  EDA_RECT zone_boundingbox = aZone->GetBoundingBox();
364  int biggest_clearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
365  biggest_clearance = std::max( biggest_clearance, zone_clearance );
366  zone_boundingbox.Inflate( biggest_clearance );
367 
368  /*
369  * First : Add pads. Note: pads having the same net as zone are left in zone.
370  * Thermal shapes will be created later if necessary
371  */
372 
373  /* Use a dummy pad to calculate hole clearance when a pad is not on all copper layers
374  * and this pad has a hole
375  * This dummy pad has the size and shape of the hole
376  * Therefore, this dummy pad is a circle or an oval.
377  * A pad must have a parent because some functions expect a non null parent
378  * to find the parent board, and some other data
379  */
380  MODULE dummymodule( m_board ); // Creates a dummy parent
381  D_PAD dummypad( &dummymodule );
382 
383  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
384  {
385  D_PAD* nextpad;
386 
387  for( D_PAD* pad = module->PadsList(); pad != NULL; pad = nextpad )
388  {
389  nextpad = pad->Next(); // pad pointer can be modified by next code, so
390  // calculate the next pad here
391 
392  if( !pad->IsOnLayer( aZone->GetLayer() ) )
393  {
394  /* Test for pads that are on top or bottom only and have a hole.
395  * There are curious pads but they can be used for some components that are
396  * inside the board (in fact inside the hole. Some photo diodes and Leds are
397  * like this)
398  */
399  if( pad->GetDrillSize().x == 0 && pad->GetDrillSize().y == 0 )
400  continue;
401 
402  // Use a dummy pad to calculate a hole shape that have the same dimension as
403  // the pad hole
404  dummypad.SetSize( pad->GetDrillSize() );
405  dummypad.SetOrientation( pad->GetOrientation() );
406  dummypad.SetShape( pad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG ?
408  dummypad.SetPosition( pad->GetPosition() );
409 
410  pad = &dummypad;
411  }
412 
413  // Note: netcode <=0 means not connected item
414  if( ( pad->GetNetCode() != aZone->GetNetCode() ) || ( pad->GetNetCode() <= 0 ) )
415  {
416  int item_clearance = pad->GetClearance() + outline_half_thickness;
417  item_boundingbox = pad->GetBoundingBox();
418  item_boundingbox.Inflate( item_clearance );
419 
420  if( item_boundingbox.Intersects( zone_boundingbox ) )
421  {
422  int clearance = std::max( zone_clearance, item_clearance );
423 
424  // PAD_SHAPE_CUSTOM can have a specific keepout, to avoid to break the shape
425  if( pad->GetShape() == PAD_SHAPE_CUSTOM
426  && pad->GetCustomShapeInZoneOpt() == CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL )
427  {
428  // the pad shape in zone can be its convex hull or
429  // the shape itself
430  SHAPE_POLY_SET outline( pad->GetCustomShapeAsPolygon() );
431  outline.Inflate( KiROUND( clearance * correctionFactor ), segsPerCircle );
432  pad->CustomShapeAsPolygonToBoardPosition( &outline,
433  pad->GetPosition(), pad->GetOrientation() );
434 
435  if( pad->GetCustomShapeInZoneOpt() == CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL )
436  {
437  std::vector<wxPoint> convex_hull;
438  BuildConvexHull( convex_hull, outline );
439 
440  aFeatures.NewOutline();
441 
442  for( unsigned ii = 0; ii < convex_hull.size(); ++ii )
443  aFeatures.Append( convex_hull[ii] );
444  }
445  else
446  aFeatures.Append( outline );
447  }
448  else
449  pad->TransformShapeWithClearanceToPolygon( aFeatures,
450  clearance,
451  segsPerCircle,
452  correctionFactor );
453  }
454 
455  continue;
456  }
457 
458  // Pads are removed from zone if the setup is PAD_ZONE_CONN_NONE
459  // or if they have a custom shape and not PAD_ZONE_CONN_FULL,
460  // because a thermal relief will break
461  // the shape
462  if( aZone->GetPadConnection( pad ) == PAD_ZONE_CONN_NONE
463  || ( pad->GetShape() == PAD_SHAPE_CUSTOM && aZone->GetPadConnection( pad ) != PAD_ZONE_CONN_FULL ) )
464  {
465  int gap = zone_clearance;
466  int thermalGap = aZone->GetThermalReliefGap( pad );
467  gap = std::max( gap, thermalGap );
468  item_boundingbox = pad->GetBoundingBox();
469  item_boundingbox.Inflate( gap );
470 
471  if( item_boundingbox.Intersects( zone_boundingbox ) )
472  {
473  // PAD_SHAPE_CUSTOM has a specific keepout, to avoid to break the shape
474  // the pad shape in zone can be its convex hull or the shape itself
475  if( pad->GetShape() == PAD_SHAPE_CUSTOM
476  && pad->GetCustomShapeInZoneOpt() == CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL )
477  {
478  // the pad shape in zone can be its convex hull or
479  // the shape itself
480  SHAPE_POLY_SET outline( pad->GetCustomShapeAsPolygon() );
481  outline.Inflate( KiROUND( gap * correctionFactor ), segsPerCircle );
482  pad->CustomShapeAsPolygonToBoardPosition( &outline,
483  pad->GetPosition(), pad->GetOrientation() );
484 
485  std::vector<wxPoint> convex_hull;
486  BuildConvexHull( convex_hull, outline );
487 
488  aFeatures.NewOutline();
489 
490  for( unsigned ii = 0; ii < convex_hull.size(); ++ii )
491  aFeatures.Append( convex_hull[ii] );
492  }
493  else
494  pad->TransformShapeWithClearanceToPolygon( aFeatures,
495  gap, segsPerCircle, correctionFactor );
496  }
497  }
498  }
499  }
500 
501  /* Add holes (i.e. tracks and vias areas as polygons outlines)
502  * in cornerBufferPolysToSubstract
503  */
504  for( auto track : m_board->Tracks() )
505  {
506  if( !track->IsOnLayer( aZone->GetLayer() ) )
507  continue;
508 
509  if( track->GetNetCode() == aZone->GetNetCode() && ( aZone->GetNetCode() != 0) )
510  continue;
511 
512  int item_clearance = track->GetClearance() + outline_half_thickness;
513  item_boundingbox = track->GetBoundingBox();
514 
515  if( item_boundingbox.Intersects( zone_boundingbox ) )
516  {
517  int clearance = std::max( zone_clearance, item_clearance );
518  track->TransformShapeWithClearanceToPolygon( aFeatures,
519  clearance, segsPerCircle, correctionFactor );
520  }
521  }
522 
523  /* Add graphic items that are on copper layers. These have no net, so we just
524  * use the zone clearance (or edge clearance).
525  */
526  auto doGraphicItem = [&]( BOARD_ITEM* aItem )
527  {
528  // A item on the Edge_Cuts is always seen as on any layer:
529  if( !aItem->IsOnLayer( aZone->GetLayer() ) && !aItem->IsOnLayer( Edge_Cuts ) )
530  return;
531 
532  if( !aItem->GetBoundingBox().Intersects( zone_boundingbox ) )
533  return;
534 
535  bool ignoreLineWidth = false;
536  int zclearance = zone_clearance;
537 
538  if( aItem->IsOnLayer( Edge_Cuts ) )
539  {
540  // use only the m_ZoneClearance, not the clearance using
541  // the netclass value, because we do not have a copper item
542  zclearance = zone_to_edgecut_clearance;
543 
544  // edge cuts by definition don't have a width
545  ignoreLineWidth = true;
546  }
547 
548  switch( aItem->Type() )
549  {
550  case PCB_LINE_T:
551  static_cast<DRAWSEGMENT*>( aItem )->TransformShapeWithClearanceToPolygon(
552  aFeatures, zclearance, segsPerCircle, correctionFactor, ignoreLineWidth );
553  break;
554 
555  case PCB_TEXT_T:
556  static_cast<TEXTE_PCB*>( aItem )->TransformBoundingBoxWithClearanceToPolygon(
557  &aFeatures, zclearance );
558  break;
559 
560  case PCB_MODULE_EDGE_T:
561  static_cast<EDGE_MODULE*>( aItem )->TransformShapeWithClearanceToPolygon(
562  aFeatures, zclearance, segsPerCircle, correctionFactor, ignoreLineWidth );
563  break;
564 
565  case PCB_MODULE_TEXT_T:
566  if( static_cast<TEXTE_MODULE*>( aItem )->IsVisible() )
567  {
568  static_cast<TEXTE_MODULE*>( aItem )->TransformBoundingBoxWithClearanceToPolygon(
569  &aFeatures, zclearance );
570  }
571  break;
572 
573  default:
574  break;
575  }
576  };
577 
578  for( auto module : m_board->Modules() )
579  {
580  doGraphicItem( &module->Reference() );
581  doGraphicItem( &module->Value() );
582 
583  for( auto item : module->GraphicalItems() )
584  doGraphicItem( item );
585  }
586 
587  for( auto item : m_board->Drawings() )
588  doGraphicItem( item );
589 
590  /* Add zones outlines having an higher priority and keepout
591  */
592  for( int ii = 0; ii < m_board->GetAreaCount(); ii++ )
593  {
594  ZONE_CONTAINER* zone = m_board->GetArea( ii );
595 
596  // If the zones share no common layers
597  if( !aZone->CommonLayerExists( zone->GetLayerSet() ) )
598  continue;
599 
600  if( !zone->GetIsKeepout() && zone->GetPriority() <= aZone->GetPriority() )
601  continue;
602 
603  if( zone->GetIsKeepout() && !zone->GetDoNotAllowCopperPour() )
604  continue;
605 
606  // A highter priority zone or keepout area is found: remove this area
607  item_boundingbox = zone->GetBoundingBox();
608 
609  if( !item_boundingbox.Intersects( zone_boundingbox ) )
610  continue;
611 
612  // Add the zone outline area.
613  // However if the zone has the same net as the current zone,
614  // do not add any clearance.
615  // the zone will be connected to the current zone, but filled areas
616  // will use different parameters (clearance, thermal shapes )
617  bool same_net = aZone->GetNetCode() == zone->GetNetCode();
618  bool use_net_clearance = true;
619  int min_clearance = zone_clearance;
620 
621  // Do not forget to make room to draw the thick outlines
622  // of the hole created by the area of the zone to remove
623  int holeclearance = zone->GetClearance() + outline_half_thickness;
624 
625  // The final clearance is obviously the max value of each zone clearance
626  min_clearance = std::max( min_clearance, holeclearance );
627 
628  if( zone->GetIsKeepout() || same_net )
629  {
630  // Just take in account the fact the outline has a thickness, so
631  // the actual area to substract is inflated to take in account this fact
632  min_clearance = outline_half_thickness;
633  use_net_clearance = false;
634  }
635 
637  aFeatures, min_clearance, use_net_clearance );
638  }
639 
640  /* Remove thermal symbols
641  */
642  for( auto module : m_board->Modules() )
643  {
644  for( auto pad : module->Pads() )
645  {
646  // Rejects non-standard pads with tht-only thermal reliefs
647  if( aZone->GetPadConnection( pad ) == PAD_ZONE_CONN_THT_THERMAL
648  && pad->GetAttribute() != PAD_ATTRIB_STANDARD )
649  continue;
650 
651  if( aZone->GetPadConnection( pad ) != PAD_ZONE_CONN_THERMAL
652  && aZone->GetPadConnection( pad ) != PAD_ZONE_CONN_THT_THERMAL )
653  continue;
654 
655  if( !pad->IsOnLayer( aZone->GetLayer() ) )
656  continue;
657 
658  if( pad->GetNetCode() != aZone->GetNetCode() )
659  continue;
660 
661  if( pad->GetNetCode() <= 0 )
662  continue;
663 
664  item_boundingbox = pad->GetBoundingBox();
665  int thermalGap = aZone->GetThermalReliefGap( pad );
666  item_boundingbox.Inflate( thermalGap, thermalGap );
667 
668  if( item_boundingbox.Intersects( zone_boundingbox ) )
669  {
671  *pad, thermalGap,
672  aZone->GetThermalReliefCopperBridge( pad ),
673  aZone->GetMinThickness(),
674  segsPerCircle,
675  correctionFactor, s_thermalRot );
676  }
677  }
678  }
679 }
680 
711  const SHAPE_POLY_SET& aSmoothedOutline,
712  SHAPE_POLY_SET& aRawPolys,
713  SHAPE_POLY_SET& aFinalPolys ) const
714 {
715  int outline_half_thickness = aZone->GetMinThickness() / 2;
716 
717  std::unique_ptr<SHAPE_FILE_IO> dumper( new SHAPE_FILE_IO(
718  s_DumpZonesWhenFilling ? "zones_dump.txt" : "", SHAPE_FILE_IO::IOM_APPEND ) );
719 
720  // Set the number of segments in arc approximations
721  int segsPerCircle = std::max( aZone->GetArcSegmentCount(), ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF );
722 
723  /* calculates the coeff to compensate radius reduction of holes clearance
724  */
725  double correctionFactor = GetCircletoPolyCorrectionFactor( segsPerCircle );
726 
728  dumper->BeginGroup( "clipper-zone" );
729 
730  SHAPE_POLY_SET solidAreas = aSmoothedOutline;
731 
732  solidAreas.Inflate( -outline_half_thickness, segsPerCircle );
733  solidAreas.Simplify( SHAPE_POLY_SET::PM_FAST );
734 
735  SHAPE_POLY_SET holes;
736 
738  dumper->Write( &solidAreas, "solid-areas" );
739 
740  buildZoneFeatureHoleList( aZone, holes );
741 
743  dumper->Write( &holes, "feature-holes" );
744 
746 
748  dumper->Write( &holes, "feature-holes-postsimplify" );
749 
750  // Generate the filled areas (currently, without thermal shapes, which will
751  // be created later).
752  // Use SHAPE_POLY_SET::PM_STRICTLY_SIMPLE to generate strictly simple polygons
753  // needed by Gerber files and Fracture()
755 
756  // Now remove the non filled areas due to the hatch pattern
757  if( aZone->GetFillMode() == ZFM_HATCH_PATTERN )
758  addHatchFillTypeOnZone( aZone, solidAreas );
759 
761  dumper->Write( &solidAreas, "solid-areas-minus-holes" );
762 
763  if( !aZone->IsOnCopperLayer() )
764  {
765  SHAPE_POLY_SET areas_fractured = solidAreas;
766  areas_fractured.Fracture( SHAPE_POLY_SET::PM_FAST );
767 
769  dumper->Write( &areas_fractured, "areas_fractured" );
770 
771  aFinalPolys = areas_fractured;
772  aRawPolys = aFinalPolys;
773 
775  dumper->EndGroup();
776 
777  return;
778  }
779 
780  // Test thermal stubs connections and add polygons to remove unconnected stubs.
781  // (this is a refinement for thermal relief shapes)
782  // Note: we are using not fractured solid area polygons, to avoid a side effect of extra segments
783  // created by Fracture(): if a tested point used in buildUnconnectedThermalStubsPolygonList
784  // is on a extra segment, the tested point is seen outside the solid area, but it is inside.
785  // This is not a bug, just the fact when a point is on a polygon outline, it is hard to say
786  // if it is inside or outside the polygon.
787  SHAPE_POLY_SET thermalHoles;
788 
789  if( aZone->GetNetCode() > 0 )
790  {
791  buildUnconnectedThermalStubsPolygonList( thermalHoles, aZone, solidAreas,
792  correctionFactor, s_thermalRot );
793 
794  }
795 
796  // remove copper areas corresponding to not connected stubs
797  if( !thermalHoles.IsEmpty() )
798  {
799  thermalHoles.Simplify( SHAPE_POLY_SET::PM_FAST );
800  // Remove unconnected stubs. Use SHAPE_POLY_SET::PM_STRICTLY_SIMPLE to
801  // generate strictly simple polygons
802  // needed by Gerber files and Fracture()
803  solidAreas.BooleanSubtract( thermalHoles, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
804 
806  dumper->Write( &thermalHoles, "thermal-holes" );
807 
808  // put these areas in m_FilledPolysList
809  SHAPE_POLY_SET th_fractured = solidAreas;
810  th_fractured.Fracture( SHAPE_POLY_SET::PM_FAST );
811 
813  dumper->Write( &th_fractured, "th_fractured" );
814 
815  aFinalPolys = th_fractured;
816  }
817  else
818  {
819  SHAPE_POLY_SET areas_fractured = solidAreas;
820  areas_fractured.Fracture( SHAPE_POLY_SET::PM_FAST );
821 
823  dumper->Write( &areas_fractured, "areas_fractured" );
824 
825  aFinalPolys = areas_fractured;
826  }
827 
828  aRawPolys = aFinalPolys;
829 
831  dumper->EndGroup();
832 }
833 
834 /* Build the filled solid areas data from real outlines (stored in m_Poly)
835  * The solid areas can be more than one on copper layers, and do not have holes
836  * ( holes are linked by overlapping segments to the main outline)
837  */
839  SHAPE_POLY_SET& aFinalPolys ) const
840 {
841  SHAPE_POLY_SET smoothedPoly;
842 
843  /* convert outlines + holes to outlines without holes (adding extra segments if necessary)
844  * m_Poly data is expected normalized, i.e. NormalizeAreaOutlines was used after building
845  * this zone
846  */
847  if ( !aZone->BuildSmoothedPoly( smoothedPoly ) )
848  return false;
849 
850  if( aZone->IsOnCopperLayer() )
851  {
852  computeRawFilledAreas( aZone, smoothedPoly, aRawPolys, aFinalPolys );
853  }
854  else
855  {
856  aFinalPolys.Inflate( -aZone->GetMinThickness() / 2, ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF );
857 
858  // Remove the non filled areas due to the hatch pattern
859  if( aZone->GetFillMode() == ZFM_HATCH_PATTERN )
860  addHatchFillTypeOnZone( aZone, smoothedPoly );
861 
862  aRawPolys = smoothedPoly;
863  aFinalPolys = smoothedPoly;
865  }
866 
867  aZone->SetNeedRefill( false );
868  return true;
869 }
870 
871 
883  const ZONE_CONTAINER* aZone,
884  const SHAPE_POLY_SET& aRawFilledArea,
885  double aArcCorrection,
886  double aRoundPadThermalRotation ) const
887 {
888  SHAPE_LINE_CHAIN spokes;
889  BOX2I itemBB;
890  VECTOR2I ptTest[4];
891  auto zoneBB = aRawFilledArea.BBox();
892 
893 
894  int zone_clearance = aZone->GetZoneClearance();
895 
896  int biggest_clearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
897  biggest_clearance = std::max( biggest_clearance, zone_clearance );
898  zoneBB.Inflate( biggest_clearance );
899 
900  // half size of the pen used to draw/plot zones outlines
901  int pen_radius = aZone->GetMinThickness() / 2;
902 
903  for( auto module : m_board->Modules() )
904  {
905  for( auto pad : module->Pads() )
906  {
907  // Rejects non-standard pads with tht-only thermal reliefs
908  if( aZone->GetPadConnection( pad ) == PAD_ZONE_CONN_THT_THERMAL
909  && pad->GetAttribute() != PAD_ATTRIB_STANDARD )
910  continue;
911 
912  if( aZone->GetPadConnection( pad ) != PAD_ZONE_CONN_THERMAL
913  && aZone->GetPadConnection( pad ) != PAD_ZONE_CONN_THT_THERMAL )
914  continue;
915 
916  if( !pad->IsOnLayer( aZone->GetLayer() ) )
917  continue;
918 
919  if( pad->GetNetCode() != aZone->GetNetCode() )
920  continue;
921 
922  // Calculate thermal bridge half width
923  int thermalBridgeWidth = aZone->GetThermalReliefCopperBridge( pad )
924  - aZone->GetMinThickness();
925  if( thermalBridgeWidth <= 0 )
926  continue;
927 
928  // we need the thermal bridge half width
929  // with a small extra size to be sure we create a stub
930  // slightly larger than the actual stub
931  thermalBridgeWidth = ( thermalBridgeWidth + 4 ) / 2;
932 
933  int thermalReliefGap = aZone->GetThermalReliefGap( pad );
934 
935  itemBB = pad->GetBoundingBox();
936  itemBB.Inflate( thermalReliefGap );
937  if( !( itemBB.Intersects( zoneBB ) ) )
938  continue;
939 
940  // Thermal bridges are like a segment from a starting point inside the pad
941  // to an ending point outside the pad
942 
943  // calculate the ending point of the thermal pad, outside the pad
944  VECTOR2I endpoint;
945  endpoint.x = ( pad->GetSize().x / 2 ) + thermalReliefGap;
946  endpoint.y = ( pad->GetSize().y / 2 ) + thermalReliefGap;
947 
948  // Calculate the starting point of the thermal stub
949  // inside the pad
950  VECTOR2I startpoint;
951  int copperThickness = aZone->GetThermalReliefCopperBridge( pad )
952  - aZone->GetMinThickness();
953 
954  if( copperThickness < 0 )
955  copperThickness = 0;
956 
957  // Leave a small extra size to the copper area inside to pad
958  copperThickness += KiROUND( IU_PER_MM * 0.04 );
959 
960  startpoint.x = std::min( pad->GetSize().x, copperThickness );
961  startpoint.y = std::min( pad->GetSize().y, copperThickness );
962 
963  startpoint.x /= 2;
964  startpoint.y /= 2;
965 
966  // This is a CIRCLE pad tweak
967  // for circle pads, the thermal stubs orientation is 45 deg
968  double fAngle = pad->GetOrientation();
969  if( pad->GetShape() == PAD_SHAPE_CIRCLE )
970  {
971  endpoint.x = KiROUND( endpoint.x * aArcCorrection );
972  endpoint.y = endpoint.x;
973  fAngle = aRoundPadThermalRotation;
974  }
975 
976  // contour line width has to be taken into calculation to avoid "thermal stub bleed"
977  endpoint.x += pen_radius;
978  endpoint.y += pen_radius;
979  // compute north, south, west and east points for zone connection.
980  ptTest[0] = VECTOR2I( 0, endpoint.y ); // lower point
981  ptTest[1] = VECTOR2I( 0, -endpoint.y ); // upper point
982  ptTest[2] = VECTOR2I( endpoint.x, 0 ); // right point
983  ptTest[3] = VECTOR2I( -endpoint.x, 0 ); // left point
984 
985  // Test all sides
986  for( int i = 0; i < 4; i++ )
987  {
988  // rotate point
989  RotatePoint( ptTest[i], fAngle );
990 
991  // translate point
992  ptTest[i] += pad->ShapePos();
993 
994  if( aRawFilledArea.Contains( ptTest[i] ) )
995  continue;
996 
997  spokes.Clear();
998 
999  // polygons are rectangles with width of copper bridge value
1000  switch( i )
1001  {
1002  case 0: // lower stub
1003  spokes.Append( -thermalBridgeWidth, endpoint.y );
1004  spokes.Append( +thermalBridgeWidth, endpoint.y );
1005  spokes.Append( +thermalBridgeWidth, startpoint.y );
1006  spokes.Append( -thermalBridgeWidth, startpoint.y );
1007  break;
1008 
1009  case 1: // upper stub
1010  spokes.Append( -thermalBridgeWidth, -endpoint.y );
1011  spokes.Append( +thermalBridgeWidth, -endpoint.y );
1012  spokes.Append( +thermalBridgeWidth, -startpoint.y );
1013  spokes.Append( -thermalBridgeWidth, -startpoint.y );
1014  break;
1015 
1016  case 2: // right stub
1017  spokes.Append( endpoint.x, -thermalBridgeWidth );
1018  spokes.Append( endpoint.x, thermalBridgeWidth );
1019  spokes.Append( +startpoint.x, thermalBridgeWidth );
1020  spokes.Append( +startpoint.x, -thermalBridgeWidth );
1021  break;
1022 
1023  case 3: // left stub
1024  spokes.Append( -endpoint.x, -thermalBridgeWidth );
1025  spokes.Append( -endpoint.x, thermalBridgeWidth );
1026  spokes.Append( -startpoint.x, thermalBridgeWidth );
1027  spokes.Append( -startpoint.x, -thermalBridgeWidth );
1028  break;
1029  }
1030 
1031  aCornerBuffer.NewOutline();
1032 
1033  // add computed polygon to list
1034  for( int ic = 0; ic < spokes.PointCount(); ic++ )
1035  {
1036  auto cpos = spokes.CPoint( ic );
1037  RotatePoint( cpos, fAngle ); // Rotate according to module orientation
1038  cpos += pad->ShapePos(); // Shift origin to position
1039  aCornerBuffer.Append( cpos );
1040  }
1041  }
1042  }
1043  }
1044 }
1045 
1046 
1048 {
1049  // Build grid:
1050 
1051  // obvously line thickness must be > zone min thickness. However, it should be
1052  // the case because the zone dialog setup ensure that. However, it can happens
1053  // if a board file was edited by hand by a python script
1054  int thickness = std::max( aZone->GetHatchFillTypeThickness(), aZone->GetMinThickness()+2 );
1055  int linethickness = thickness - aZone->GetMinThickness();
1056  int gridsize = thickness + aZone->GetHatchFillTypeGap();
1057  double orientation = aZone->GetHatchFillTypeOrientation();
1058 
1059  SHAPE_POLY_SET filledPolys = aRawPolys;
1060  // Use a area that contains the rotated bbox by orientation,
1061  // and after rotate the result by -orientation.
1062  if( orientation != 0.0 )
1063  {
1064  filledPolys.Rotate( M_PI/180.0 * orientation, VECTOR2I( 0,0 ) );
1065  }
1066 
1067  BOX2I bbox = filledPolys.BBox( 0 );
1068 
1069  // Build hole shape
1070  // the hole size is aZone->GetHatchFillTypeGap(), but because the outline thickness
1071  // is aZone->GetMinThickness(), the hole shape size must be larger
1072  SHAPE_LINE_CHAIN hole_base;
1073  int hole_size = aZone->GetHatchFillTypeGap() + aZone->GetMinThickness();
1074  VECTOR2I corner( 0, 0 );;
1075  hole_base.Append( corner );
1076  corner.x += hole_size;
1077  hole_base.Append( corner );
1078  corner.y += hole_size;
1079  hole_base.Append( corner );
1080  corner.x = 0;
1081  hole_base.Append( corner );
1082  hole_base.SetClosed( true );
1083 
1084  // Calculate minimal area of a grid hole.
1085  // All holes smaller than a threshold will be removed
1086  double minimal_hole_area = hole_base.Area() / 2;
1087 
1088  // Now convert this hole to a smoothed shape:
1089  if( aZone->GetHatchFillTypeSmoothingLevel() > 0 )
1090  {
1091  // the actual size of chamfer, or rounded corner radius is the half size
1092  // of the HatchFillTypeGap scaled by aZone->GetHatchFillTypeSmoothingValue()
1093  // aZone->GetHatchFillTypeSmoothingValue() = 1.0 is the max value for the chamfer or the
1094  // radius of corner (radius = half size of the hole)
1095  int smooth_value = KiROUND( aZone->GetHatchFillTypeGap()
1096  * aZone->GetHatchFillTypeSmoothingValue() / 2 );
1097 
1098  // Minimal optimization:
1099  // make smoothing only for reasonnable smooth values, to avoid a lot of useless segments
1100  // and if the smooth value is small, use chamfer even if fillet is requested
1101  #define SMOOTH_MIN_VAL_MM 0.02
1102  #define SMOOTH_SMALL_VAL_MM 0.04
1103  if( smooth_value > Millimeter2iu( SMOOTH_MIN_VAL_MM ) )
1104  {
1105  SHAPE_POLY_SET smooth_hole;
1106  smooth_hole.AddOutline( hole_base );
1107  int smooth_level = aZone->GetHatchFillTypeSmoothingLevel();
1108 
1109  if( smooth_value < Millimeter2iu( SMOOTH_SMALL_VAL_MM ) && smooth_level > 1 )
1110  smooth_level = 1;
1111  // Use a larger smooth_value to compensate the outline tickness
1112  // (chamfer is not visible is smooth value < outline thickess)
1113  smooth_value += aZone->GetMinThickness()/2;
1114 
1115  // smooth_value cannot be bigger than the half size oh the hole:
1116  smooth_value = std::min( smooth_value, aZone->GetHatchFillTypeGap()/2 );
1117  // the error to approximate a circle by segments when smoothing corners by a arc
1118  int error_max = std::max( Millimeter2iu( 0.01), smooth_value/20 );
1119 
1120  switch( smooth_level )
1121  {
1122  case 1:
1123  // Chamfer() uses the distance from a corner to create a end point
1124  // for the chamfer.
1125  hole_base = smooth_hole.Chamfer( smooth_value ).Outline( 0 );
1126  break;
1127 
1128  default:
1129  if( aZone->GetHatchFillTypeSmoothingLevel() > 2 )
1130  error_max /= 2; // Force better smoothing
1131  hole_base = smooth_hole.Fillet( smooth_value, error_max ).Outline( 0 );
1132  break;
1133 
1134  case 0:
1135  break;
1136  };
1137  }
1138  }
1139 
1140  // Build holes
1141  SHAPE_POLY_SET holes;
1142 
1143  for( int xx = 0; ; xx++ )
1144  {
1145  int xpos = xx * gridsize;
1146 
1147  if( xpos > bbox.GetWidth() )
1148  break;
1149 
1150  for( int yy = 0; ; yy++ )
1151  {
1152  int ypos = yy * gridsize;
1153 
1154  if( ypos > bbox.GetHeight() )
1155  break;
1156 
1157  // Generate hole
1158  SHAPE_LINE_CHAIN hole( hole_base );
1159  hole.Move( VECTOR2I( xpos, ypos ) );
1160  holes.AddOutline( hole );
1161  }
1162  }
1163 
1164  holes.Move( bbox.GetPosition() );
1165 
1166  // Clamp holes to the area of filled zones with a outline thickness
1167  // > aZone->GetMinThickness() to be sure the thermal pads can be built
1168  int outline_margin = std::max( (aZone->GetMinThickness()*10)/9, linethickness/2 );
1169  filledPolys.Inflate( -outline_margin, 16 );
1170  holes.BooleanIntersection( filledPolys, SHAPE_POLY_SET::PM_FAST );
1171 
1172  if( orientation != 0.0 )
1173  holes.Rotate( -M_PI/180.0 * orientation, VECTOR2I( 0,0 ) );
1174 
1175  // Now filter truncated holes to avoid small holes in pattern
1176  // It happens for holes near the zone outline
1177  for( int ii = 0; ii < holes.OutlineCount(); )
1178  {
1179  double area = holes.Outline( ii ).Area();
1180 
1181  if( area < minimal_hole_area ) // The current hole is too small: remove it
1182  holes.DeletePolygon( ii );
1183  else
1184  ++ii;
1185  }
1186 
1187  // create grid. Use SHAPE_POLY_SET::PM_STRICTLY_SIMPLE to
1188  // generate strictly simple polygons needed by Gerber files and Fracture()
1189  aRawPolys.BooleanSubtract( aRawPolys, holes, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
1190 }
void SetFilledPolysList(SHAPE_POLY_SET &aPolysList)
Function SetFilledPolysList sets the list of filled polygons.
Definition: class_zone.h:594
virtual void Revert()=0
Revertes the commit by restoring the modifed items state.
D_PAD * Next() const
Definition: class_pad.h:162
void AdvancePhase()
Uses the next vailable virtual zone of the dialog progress bar.
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, bool aIgnoreHoles=false) const
Returns true if a given subpolygon contains the point aP.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox
Definition: confirm.cpp:61
Class SHAPE_FILE_IO.
Definition: shape_file_io.h:38
int GetNetCode() const
Function GetNetCode.
int OutlineCount() const
Returns the number of outlines in the set
TEXTE_PCB class definition.
bool CommonLayerExists(const LSET aLayerSet) const
Function CommonLayerExist Test if this zone shares a common layer with the given layer set.
Definition: class_zone.cpp:204
int GetThermalReliefCopperBridge(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:635
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
This file is part of the common library.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
BOARD * m_board
Definition: zone_filler.h:111
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox (virtual)
Definition: class_zone.cpp:516
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
PROGRESS_REPORTER_HIDER(WX_PROGRESS_REPORTER *aReporter)
Definition: zone_filler.cpp:58
A progress reporter for use in multi-threaded environments.
void TransformOutlinesShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aMinClearanceValue, bool aUseNetClearance) const
Function TransformOutlinesShapeWithClearanceToPolygon Convert the outlines shape to a polygon with no...
int GetHatchFillTypeThickness() const
Definition: class_zone.h:208
Class BOARD to handle a board.
WX_PROGRESS_REPORTER * m_progressReporter
Definition: zone_filler.h:113
void Move(const VECTOR2I &aVector) override
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:185
#define SMOOTH_MIN_VAL_MM
void Report(const wxString &aMessage)
Display aMessage in the progress bar dialog.
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
double GetHatchFillTypeOrientation() const
Definition: class_zone.h:214
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:221
Classes to handle copper zones.
Class COMMIT.
Definition: commit.h:71
double GetHatchFillTypeSmoothingValue() const
Definition: class_zone.h:220
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:534
SHAPE_POLY_SET Fillet(int aRadius, int aErrorMax)
Function Fillet returns a filleted version of the polygon set.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
int GetThermalReliefGap(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:626
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
#define SMOOTH_SMALL_VAL_MM
void SetIsFilled(bool isFilled)
Definition: class_zone.h:188
void BuildConvexHull(std::vector< wxPoint > &aResult, const std::vector< wxPoint > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
Definition: convex_hull.cpp:87
int PointCount() const
Function PointCount()
static const bool s_DumpZonesWhenFilling
Definition: zone_filler.cpp:83
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_zone.cpp:775
Functions relatives to tracks, vias and segments used to fill zones.
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void DeletePolygon(int aIdx)
Deletes aIdx-th polygon from the set
Pads are not covered.
Definition: zones.h:52
WX_PROGRESS_REPORTER * m_reporter
Definition: zone_filler.cpp:73
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:243
bool Intersects(const BOX2< Vec > &aRect) const
Function Intersects.
Definition: box2.h:234
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
int GetArcSegmentCount() const
Definition: class_zone.h:185
void SetClosed(bool aClosed)
Function SetClosed()
void SetProgressReporter(WX_PROGRESS_REPORTER *aReporter)
Definition: zone_filler.cpp:97
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:981
void Inflate(int aFactor, int aCircleSegmentsCount)
Performs outline inflation/deflation, using round corners.
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:252
void Move(const VECTOR2I &aVector) override
COMMIT * m_commit
Definition: zone_filler.h:112
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
ZONE_FILLER(BOARD *aBoard, COMMIT *aCommit=nullptr)
Definition: zone_filler.cpp:86
ZONE_FILL_MODE GetFillMode() const
Definition: class_zone.h:170
coord_type GetWidth() const
Definition: box2.h:195
void CreateThermalReliefPadPolygon(SHAPE_POLY_SET &aCornerBuffer, const D_PAD &aPad, int aThermalGap, int aCopperThickness, int aMinThicknessValue, int aCircleToSegmentsCount, double aCorrectionFactor, double aThermalRot)
Function CreateThermalReliefPadPolygon Add holes around a pad to create a thermal relief copper thick...
bool GetDoNotAllowCopperPour() const
Definition: class_zone.h:652
void addHatchFillTypeOnZone(const ZONE_CONTAINER *aZone, SHAPE_POLY_SET &aRawPolys) const
for zones having the ZONE_FILL_MODE::ZFM_HATCH_PATTERN, create a grid pattern in filled areas of aZon...
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:292
void SetSize(const wxSize &aSize)
Definition: class_pad.h:270
a few functions useful in geometry calculations.
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, wxString *aErrorText=nullptr, wxPoint *aErrorLocation=nullptr)
Function GetBoardPolygonOutlines Extracts the board outlines and build a closed polygon from lines,...
bool Fill(const std::vector< ZONE_CONTAINER * > &aZones, bool aCheck=false)
void buildZoneFeatureHoleList(const ZONE_CONTAINER *aZone, SHAPE_POLY_SET &aFeatures) const
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset intersection For aFastMode meaning, see function booleanOp
int NewOutline()
Creates a new empty polygon in the set and returns its index
Thermal relief only for THT pads.
Definition: zones.h:55
void Fracture(POLYGON_MODE aFastMode)
Converts a set of polygons with holes to a singe outline with "slits"/"fractures" connecting the oute...
void SetRawPolysList(SHAPE_POLY_SET &aPolysList)
Function SetFilledPolysList sets the list of filled polygons.
Definition: class_zone.h:603
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:651
double Area() const
const Vec & GetPosition() const
Definition: box2.h:192
static double s_thermalRot
Definition: zone_filler.cpp:82
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index
void buildUnconnectedThermalStubsPolygonList(SHAPE_POLY_SET &aCornerBuffer, const ZONE_CONTAINER *aZone, const SHAPE_POLY_SET &aRawFilledArea, double aArcCorrection, double aRoundPadThermalRotation) const
Function buildUnconnectedThermalStubsPolygonList Creates a set of polygons corresponding to stubs cre...
void computeRawFilledAreas(const ZONE_CONTAINER *aZone, const SHAPE_POLY_SET &aSmoothedOutline, SHAPE_POLY_SET &aRawPolys, SHAPE_POLY_SET &aFinalPolys) const
Function computeRawFilledAreas Add non copper areas polygons (pads and tracks with clearance) to a fi...
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly) const
Function GetSmoothedPoly returns a pointer to the corner-smoothed version of m_Poly if it exists,...
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:300
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true)=0
Executes the changes.
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:96
SHAPE_POLY_SET Chamfer(int aDistance)
Function Chamfer returns a chamfered version of the polygon set.
Class to handle a graphic segment.
ZoneConnection GetPadConnection(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:999
#define max(a, b)
Definition: auxiliary.h:86
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
DLIST< MODULE > m_Modules
Definition: class_board.h:248
Class SHAPE_LINE_CHAIN.
size_t i
Definition: json11.cpp:597
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
bool KeepRefreshing(bool aWait=false)
Update the UI dialog.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
coord_type GetHeight() const
Definition: box2.h:196
int GetMinThickness() const
Definition: class_zone.h:199
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_pad.cpp:608
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:219
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
void SetOrientation(double aAngle)
Function SetOrientation sets the rotation angle of the pad.
Definition: class_pad.cpp:429
void Clear()
Function Clear() Removes all points from the line chain.
bool fillSingleZone(ZONE_CONTAINER *aZone, SHAPE_POLY_SET &aRawPolys, SHAPE_POLY_SET &aFinalPolys) const
Build the filled solid areas polygons from zone outlines (stored in m_Poly) The solid areas can be mo...
int GetHatchFillTypeSmoothingLevel() const
Definition: class_zone.h:217
PCB_TARGET class definition.
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:251
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset difference For aFastMode meaning, see function booleanOp
Module description (excepted pads)
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:952
int GetZoneClearance() const
Definition: class_zone.h:193
EDGE_MODULE class definition.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void SetMaxProgress(int aMaxProgress)
Fix the value thar gives the 100 precent progress bar length (inside the current virtual zone)
void Rotate(double aAngle, const VECTOR2I &aCenter)
Function Rotate rotates all vertices by a given angle.
void AdvanceProgress()
Increment the progress bar length (inside the current virtual zone)
#define ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF
Definition: pcbnew.h:42
const BOX2I BBox(int aClearance=0) const override
Function BBox()
int GetHatchFillTypeGap() const
Definition: class_zone.h:211
bool IsOnCopperLayer() const
Function IsOnCopperLayer.
Definition: class_zone.cpp:191
Use thermal relief for pads.
Definition: zones.h:53
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:253
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
#define min(a, b)
Definition: auxiliary.h:85
pads are covered by copper
Definition: zones.h:54
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
void SetNeedRefill(bool aNeedRefill)
Definition: class_zone.h:191
double GetCircletoPolyCorrectionFactor(int aSegCountforCircle)