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.

99 lines
4.2 KiB

  1. /**
  2. * @file convert_basic_shapes_to_polygon.h
  3. */
  4. /*
  5. * This program source code file is part of KiCad, a free EDA CAD application.
  6. *
  7. * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
  8. * Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, you may find one here:
  22. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  23. * or you may search the http://www.gnu.org website for the version 2 license,
  24. * or you may write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  26. */
  27. #ifndef CONVERT_BASIC_SHAPES_TO_POLYGON_H
  28. #define CONVERT_BASIC_SHAPES_TO_POLYGON_H
  29. #include <vector>
  30. #include <fctsys.h>
  31. #include <trigo.h>
  32. #include <macros.h>
  33. #include <PolyLine.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( CPOLYGONS_LIST& aCornerBuffer,
  45. wxPoint aCenter, int aRadius,
  46. int aCircleToSegmentsCount );
  47. /**
  48. * Function TransformRoundedEndsSegmentToPolygon
  49. * convert a segment with rounded ends to a polygon
  50. * Convert arcs to multiple straight lines
  51. * @param aCornerBuffer = a buffer to store the polygon
  52. * @param aStart = the segment start point coordinate
  53. * @param aEnd = the segment end point coordinate
  54. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  55. * @param aWidth = the segment width
  56. * Note: the polygon is inside the arc ends, so if you want to have the polygon
  57. * outside the circle, you should give aStart and aEnd calculated with a correction factor
  58. */
  59. void TransformRoundedEndsSegmentToPolygon( CPOLYGONS_LIST& aCornerBuffer,
  60. wxPoint aStart, wxPoint aEnd,
  61. int aCircleToSegmentsCount,
  62. int aWidth );
  63. /**
  64. * Function TransformArcToPolygon
  65. * Creates a polygon from an Arc
  66. * Convert arcs to multiple straight segments
  67. * @param aCornerBuffer = a buffer to store the polygon
  68. * @param aCentre = centre of the arc or circle
  69. * @param aStart = start point of the arc, or a point on the circle
  70. * @param aArcAngle = arc angle in 0.1 degrees. For a circle, aArcAngle = 3600
  71. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  72. * @param aWidth = width (thickness) of the line
  73. */
  74. void TransformArcToPolygon( CPOLYGONS_LIST& aCornerBuffer,
  75. wxPoint aCentre, wxPoint aStart, double aArcAngle,
  76. int aCircleToSegmentsCount, int aWidth );
  77. /**
  78. * Function TransformRingToPolygon
  79. * Creates a polygon from a ring
  80. * Convert arcs to multiple straight segments
  81. * @param aCornerBuffer = a buffer to store the polygon
  82. * @param aCentre = centre of the arc or circle
  83. * @param aRadius = radius of the circle
  84. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  85. * @param aWidth = width (thickness) of the ring
  86. */
  87. void TransformRingToPolygon( CPOLYGONS_LIST& aCornerBuffer,
  88. wxPoint aCentre, int aRadius,
  89. int aCircleToSegmentsCount, int aWidth );
  90. #endif // CONVERT_BASIC_SHAPES_TO_POLYGON_H