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.

65 lines
2.2 KiB

  1. /*
  2. * file polygons_defs.h
  3. * definitions to use boost::polygon in KiCad.
  4. */
  5. #ifndef _POLYGONS_DEFS_H_
  6. #define _POLYGONS_DEFS_H_
  7. #include <boost/polygon/polygon.hpp>
  8. // Define some types used here from boost::polygon
  9. namespace bpl = boost::polygon; // bpl = boost polygon library
  10. using namespace bpl::operators; // +, -, =, ...
  11. // Definitions needed by boost::polygon
  12. typedef int coordinate_type;
  13. /**
  14. * KI_POLYGON defines a single polygon ( boost::polygon_data type.
  15. * When holes are created in a KPolygon, they are
  16. * linked to main outline by overlapping segments,
  17. * so there is always one polygon and one list of corners
  18. * coordinates are int
  19. */
  20. typedef bpl::polygon_data<int> KI_POLYGON;
  21. /**
  22. * KI_POLYGON_SET defines a set of single KI_POLYGON.
  23. * A KI_POLYGON_SET is used to store a set of polygons
  24. * when performing operations between 2 polygons
  25. * or 2 sets of polygons
  26. * The result of operations like and, xor... between 2 polygons
  27. * is always stored in a KI_POLYGON_SET, because these operations
  28. * can create many polygons
  29. */
  30. typedef std::vector<KI_POLYGON> KI_POLYGON_SET;
  31. /**
  32. * KI_POLY_POINT defines a point for boost::polygon.
  33. * KI_POLY_POINT store x and y coordinates (int)
  34. */
  35. typedef bpl::point_data<int> KI_POLY_POINT;
  36. /**
  37. * KI_POLYGON_WITH_HOLES defines a single polygon with holes
  38. * When holes are created in a KI_POLYGON_WITH_HOLES, they are
  39. * stored as separate single polygons,
  40. * KI_POLYGON_WITH_HOLES store always one polygon for the external outline
  41. * and one list of polygons (holes) which can be empty
  42. */
  43. typedef bpl::polygon_with_holes_data<int> KI_POLYGON_WITH_HOLES;
  44. /**
  45. * KI_POLYGON_WITH_HOLES_SET defines a set of KI_POLYGON_WITH_HOLES.
  46. * A KI_POLYGON_WITH_HOLES_SET is used to store a set of polygons with holes
  47. * when performing operations between 2 polygons
  48. * or 2 sets of polygons with holes
  49. * The result of operations like and, xor... between 2 polygons with holes
  50. * is always stored in a KI_POLYGON_WITH_HOLES_SET, because these operations
  51. * can create many separate polygons with holespolygons
  52. */
  53. typedef std::vector<KI_POLYGON_WITH_HOLES> KI_POLYGON_WITH_HOLES_SET;
  54. #endif // #ifndef _POLYGONS_DEFS_H_