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.

128 lines
5.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #ifndef CONVERT_BASIC_SHAPES_TO_POLYGON_H
  25. #define CONVERT_BASIC_SHAPES_TO_POLYGON_H
  26. /**
  27. * @file convert_basic_shapes_to_polygon.h
  28. */
  29. #include <vector>
  30. #include <fctsys.h>
  31. #include <trigo.h>
  32. #include <macros.h>
  33. #include <geometry/shape_poly_set.h>
  34. /**
  35. * Function TransformCircleToPolygon
  36. * convert a circle to a polygon, using multiple straight lines
  37. * @param aCornerBuffer = a buffer to store the polygon
  38. * @param aCenter = the center of the circle
  39. * @param aRadius = the radius of the circle
  40. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  41. * Note: the polygon is inside the circle, so if you want to have the polygon
  42. * outside the circle, you should give aRadius calculated with a correction factor
  43. */
  44. void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer,
  45. wxPoint aCenter, int aRadius,
  46. int aCircleToSegmentsCount );
  47. /**
  48. * Helper function GetRoundRectCornerCenters
  49. * Has meaning only for rounded rect
  50. * Returns the centers of the rounded corners.
  51. * @param aPosition = position of the round rect
  52. * @param aSize = size of the of the round rect.
  53. * @param aRotation = rotation of the of the round rect
  54. * @param aCenters a buffer to store the 4 coordinates.
  55. */
  56. void GetRoundRectCornerCenters( wxPoint aCenters[4], int aRadius,
  57. const wxPoint& aPosition, const wxSize& aSize, double aRotation );
  58. /**
  59. * Function TransformRoundRectToPolygon
  60. * convert a rectangle with rounded corners to a polygon
  61. * Convert arcs to multiple straight lines
  62. * @param aCornerBuffer = a buffer to store the polygon
  63. * @param aPosition = the coordinate of the center of the rectangle
  64. * @param aSize = the size of the rectangle
  65. * @param aCornerRadius = radius of rounded corners
  66. * @param aRotation = rotation in 0.1 degrees of the rectangle
  67. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  68. */
  69. void TransformRoundRectToPolygon( SHAPE_POLY_SET& aCornerBuffer,
  70. const wxPoint& aPosition, const wxSize& aSize,
  71. double aRotation, int aCornerRadius,
  72. int aCircleToSegmentsCount );
  73. /**
  74. * Function TransformRoundedEndsSegmentToPolygon
  75. * convert a segment with rounded ends to a polygon
  76. * Convert arcs to multiple straight lines
  77. * @param aCornerBuffer = a buffer to store the polygon
  78. * @param aStart = the segment start point coordinate
  79. * @param aEnd = the segment end point coordinate
  80. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  81. * @param aWidth = the segment width
  82. * Note: the polygon is inside the arc ends, so if you want to have the polygon
  83. * outside the circle, you should give aStart and aEnd calculated with a correction factor
  84. */
  85. void TransformRoundedEndsSegmentToPolygon( SHAPE_POLY_SET& aCornerBuffer,
  86. wxPoint aStart, wxPoint aEnd,
  87. int aCircleToSegmentsCount,
  88. int aWidth );
  89. /**
  90. * Function TransformArcToPolygon
  91. * Creates a polygon from an Arc
  92. * Convert arcs to multiple straight segments
  93. * @param aCornerBuffer = a buffer to store the polygon
  94. * @param aCentre = centre of the arc or circle
  95. * @param aStart = start point of the arc, or a point on the circle
  96. * @param aArcAngle = arc angle in 0.1 degrees. For a circle, aArcAngle = 3600
  97. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  98. * @param aWidth = width (thickness) of the line
  99. */
  100. void TransformArcToPolygon( SHAPE_POLY_SET& aCornerBuffer,
  101. wxPoint aCentre, wxPoint aStart, double aArcAngle,
  102. int aCircleToSegmentsCount, int aWidth );
  103. /**
  104. * Function TransformRingToPolygon
  105. * Creates a polygon from a ring
  106. * Convert arcs to multiple straight segments
  107. * @param aCornerBuffer = a buffer to store the polygon
  108. * @param aCentre = centre of the arc or circle
  109. * @param aRadius = radius of the circle
  110. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  111. * @param aWidth = width (thickness) of the ring
  112. */
  113. void TransformRingToPolygon( SHAPE_POLY_SET& aCornerBuffer,
  114. wxPoint aCentre, int aRadius,
  115. int aCircleToSegmentsCount, int aWidth );
  116. #endif // CONVERT_BASIC_SHAPES_TO_POLYGON_H