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.

89 lines
3.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2012-2014 KiCad Developers, see CHANGELOG.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. /*
  25. * file polygons_defs.h
  26. * definitions to use boost::polygon in KiCad.
  27. */
  28. #ifndef _POLYGONS_DEFS_H_
  29. #define _POLYGONS_DEFS_H_
  30. #include <boost/polygon/polygon.hpp>
  31. // Define some types used here from boost::polygon
  32. namespace bpl = boost::polygon; // bpl = boost polygon library
  33. using namespace bpl::operators; // +, -, =, ...
  34. // Definitions needed by boost::polygon
  35. typedef int coordinate_type;
  36. /**
  37. * KI_POLYGON defines a single polygon ( boost::polygon_data type.
  38. * When holes are created in a KPolygon, they are
  39. * linked to main outline by overlapping segments,
  40. * so there is always one polygon and one list of corners
  41. * coordinates are int
  42. */
  43. typedef bpl::polygon_data<int> KI_POLYGON;
  44. /**
  45. * KI_POLYGON_SET defines a set of single KI_POLYGON.
  46. * A KI_POLYGON_SET is used to store a set of polygons
  47. * when performing operations between 2 polygons
  48. * or 2 sets of polygons
  49. * The result of operations like and, xor... between 2 polygons
  50. * is always stored in a KI_POLYGON_SET, because these operations
  51. * can create many polygons
  52. */
  53. typedef std::vector<KI_POLYGON> KI_POLYGON_SET;
  54. /**
  55. * KI_POLY_POINT defines a point for boost::polygon.
  56. * KI_POLY_POINT store x and y coordinates (int)
  57. */
  58. typedef bpl::point_data<int> KI_POLY_POINT;
  59. /**
  60. * KI_POLYGON_WITH_HOLES defines a single polygon with holes
  61. * When holes are created in a KI_POLYGON_WITH_HOLES, they are
  62. * stored as separate single polygons,
  63. * KI_POLYGON_WITH_HOLES store always one polygon for the external outline
  64. * and one list of polygons (holes) which can be empty
  65. */
  66. typedef bpl::polygon_with_holes_data<int> KI_POLYGON_WITH_HOLES;
  67. /**
  68. * KI_POLYGON_WITH_HOLES_SET defines a set of KI_POLYGON_WITH_HOLES.
  69. * A KI_POLYGON_WITH_HOLES_SET is used to store a set of polygons with holes
  70. * when performing operations between 2 polygons
  71. * or 2 sets of polygons with holes
  72. * The result of operations like and, xor... between 2 polygons with holes
  73. * is always stored in a KI_POLYGON_WITH_HOLES_SET, because these operations
  74. * can create many separate polygons with holespolygons
  75. */
  76. typedef std::vector<KI_POLYGON_WITH_HOLES> KI_POLYGON_WITH_HOLES_SET;
  77. #endif // #ifndef _POLYGONS_DEFS_H_