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.

66 lines
2.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. /**
  24. * @file convert_drawsegment_list_to_polygon.h
  25. * @brief functions to convert a shape built with DRAWSEGMENTS to a polygon.
  26. * expecting the shape describes shape similar to a polygon
  27. */
  28. #pragma once
  29. class PCB_SHAPE;
  30. class SHAPE_POLY_SET;
  31. class wxString;
  32. class wxPoint;
  33. typedef
  34. const std::function<void( const wxString& msg, BOARD_ITEM* itemA, BOARD_ITEM* itemB,
  35. const wxPoint& pt )> OUTLINE_ERROR_HANDLER;
  36. /**
  37. * Function ConvertOutlineToPolygon
  38. * build a polygon (with holes) from a PCB_SHAPE list, which is expected to be
  39. * a outline, therefore a closed main outline with perhaps closed inner outlines.
  40. * These closed inner outlines are considered as holes in the main outline
  41. * @param aSegList the initial list of drawsegments (only lines, circles and arcs).
  42. * @param aPolygons will contain the complex polygon.
  43. * @param aErrorMax is the max error distance when polygonizing a curve (internal units)
  44. * @param aChainingEpsilon is the max distance from one endPt to the next startPt (internal units)
  45. * @param aErrorHandler = an optional error handler
  46. */
  47. bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET& aPolygons,
  48. int aErrorMax, int aChainingEpsilon,
  49. OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
  50. /**
  51. * Extracts the board outlines and build a closed polygon from lines, arcs and circle items on
  52. * edge cut layer. Any closed outline inside the main outline is a hole. All contours should be
  53. * closed, i.e. are valid vertices for a closed polygon.
  54. * @return true if success, false if a contour is not valid
  55. */
  56. extern bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
  57. int aErrorMax, int aChainingEpsilon,
  58. OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );