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.

134 lines
5.4 KiB

  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-2017 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
  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. #ifndef __ZONE_FILLER_H
  26. #define __ZONE_FILLER_H
  27. #include <vector>
  28. #include <class_zone.h>
  29. class WX_PROGRESS_REPORTER;
  30. class BOARD;
  31. class COMMIT;
  32. class SHAPE_POLY_SET;
  33. class SHAPE_LINE_CHAIN;
  34. struct THERMAL_SPOKE
  35. {
  36. SHAPE_LINE_CHAIN m_Outline;
  37. VECTOR2I m_TestPtA;
  38. VECTOR2I m_TestPtB;
  39. THERMAL_SPOKE()
  40. {
  41. m_TestPtA = { 0, 0 };
  42. m_TestPtB = { 0, 0 };
  43. }
  44. };
  45. class ZONE_FILLER
  46. {
  47. public:
  48. ZONE_FILLER( BOARD* aBoard, COMMIT* aCommit = nullptr );
  49. ~ZONE_FILLER();
  50. void SetProgressReporter( WX_PROGRESS_REPORTER* aReporter );
  51. bool Fill( const std::vector<ZONE_CONTAINER*>& aZones, bool aCheck = false );
  52. private:
  53. void addKnockout( D_PAD* aPad, int aGap, SHAPE_POLY_SET& aHoles );
  54. void addKnockout( BOARD_ITEM* aItem, int aGap, bool aIgnoreLineWidth, SHAPE_POLY_SET& aHoles );
  55. void knockoutThermals( const ZONE_CONTAINER* aZone, SHAPE_POLY_SET& aFill );
  56. void knockoutCopperItems( const ZONE_CONTAINER* aZone, SHAPE_POLY_SET& aFill );
  57. /**
  58. * Function computeRawFilledArea
  59. * Add non copper areas polygons (pads and tracks with clearance)
  60. * to a filled copper area
  61. * used in BuildFilledSolidAreasPolygons when calculating filled areas in a zone
  62. * Non copper areas are pads and track and their clearance area
  63. * The filled copper area must be computed before
  64. * BuildFilledSolidAreasPolygons() call this function just after creating the
  65. * filled copper area polygon (without clearance areas
  66. * @param aPcb: the current board
  67. */
  68. void computeRawFilledArea( const ZONE_CONTAINER* aZone, const SHAPE_POLY_SET& aSmoothedOutline,
  69. SHAPE_POLY_SET& aRawPolys, SHAPE_POLY_SET& aFinalPolys );
  70. /**
  71. * Function buildThermalSpokes
  72. * Constructs a list of all thermal spokes for the given zone.
  73. */
  74. void buildThermalSpokes( const ZONE_CONTAINER* aZone, std::deque<THERMAL_SPOKE>& aSpokes );
  75. /**
  76. * Build the filled solid areas polygons from zone outlines (stored in m_Poly)
  77. * The solid areas can be more than one on copper layers, and do not have holes
  78. * ( holes are linked by overlapping segments to the main outline)
  79. * in order to have drawable (and plottable) filled polygons.
  80. * @return true if OK, false if the solid polygons cannot be built
  81. * @param aZone is the zone to fill
  82. * @param aRawPolys: A reference to a SHAPE_POLY_SET buffer to store
  83. * filled solid areas polygons (with holes)
  84. * @param aFinalPolys: A reference to a SHAPE_POLY_SET buffer to store polygons with no holes
  85. * (holes are linked to main outline by overlapping segments, and these polygons are shrinked
  86. * by aZone->GetMinThickness() / 2 to be drawn with a outline thickness = aZone->GetMinThickness()
  87. * aFinalPolys are polygons that will be drawn on screen and plotted
  88. */
  89. bool fillSingleZone( ZONE_CONTAINER* aZone, SHAPE_POLY_SET& aRawPolys,
  90. SHAPE_POLY_SET& aFinalPolys );
  91. /**
  92. * for zones having the ZONE_FILL_MODE::ZFM_HATCH_PATTERN, create a grid pattern
  93. * in filled areas of aZone, giving to the filled polygons a fill style like a grid
  94. * @param aZone is the zone to modify
  95. * @param aRawPolys: A reference to a SHAPE_POLY_SET buffer containing the initial
  96. * filled areas, and after adding the grid pattern, the modified filled areas with holes
  97. */
  98. void addHatchFillTypeOnZone( const ZONE_CONTAINER* aZone, SHAPE_POLY_SET& aRawPolys );
  99. BOARD* m_board;
  100. SHAPE_POLY_SET m_boardOutline; // The board outlines, if exists
  101. bool m_brdOutlinesValid; // true if m_boardOutline can be calculated
  102. // false if not (not closed outlines for instance)
  103. COMMIT* m_commit;
  104. WX_PROGRESS_REPORTER* m_progressReporter;
  105. // m_high_def can be used to define a high definition arc to polygon approximation
  106. int m_high_def;
  107. // m_low_def can be used to define a low definition arc to polygon approximation
  108. // Used when converting some pad shapes that can accept lower resolution, vias and track ends.
  109. // Rect pads use m_low_def to reduce the number of segments. For these shapes a low def
  110. // gives a good shape, because the arc is small (90 degrees) and a small part of the shape.
  111. int m_low_def;
  112. };
  113. #endif