From 15369915cc1e6aa61329fb632dcffca46226c7a2 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 23 Oct 2020 08:48:52 +0200 Subject: [PATCH] Minor code cleanup: move "extern" declarations to convert_drawsegment_list_to_polygon.h --- pcbnew/class_board.cpp | 13 +--- pcbnew/class_module.cpp | 9 +-- .../convert_drawsegment_list_to_polygon.cpp | 1 + pcbnew/convert_drawsegment_list_to_polygon.h | 69 +++++++++++++++++++ pcbnew/dialogs/dialog_export_step.cpp | 5 +- 5 files changed, 74 insertions(+), 23 deletions(-) create mode 100644 pcbnew/convert_drawsegment_list_to_polygon.h diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 3dc603cf27..0036787da9 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -48,6 +48,7 @@ #include #include #include +#include /* This is an odd place for this, but CvPcb won't link if it is * in class_board_item.cpp like I first tried it. @@ -1838,18 +1839,6 @@ bool BOARD::NormalizeAreaPolygon( PICKED_ITEMS_LIST * aNewZonesList, ZONE_CONTAI } -/* Extracts the board outlines and build a closed polygon - * from lines, arcs and circle items on edge cut layer - * Any closed outline inside the main outline is a hole - * All contours should be closed, i.e. are valid vertices for a closed polygon - * return true if success, false if a contour is not valid - */ -extern bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, - unsigned int aTolerance, wxString* aErrorText, - std::vector* aDiscontinuities = nullptr, - std::vector* aIntersections = nullptr ); - - bool BOARD::GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, wxString* aErrorText, std::vector* aDiscontinuities, std::vector* aIntersections ) diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index a8d58cff35..4fe38ed25f 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -36,6 +36,8 @@ #include #include #include +#include + MODULE::MODULE( BOARD* parent ) : BOARD_ITEM_CONTAINER( (BOARD_ITEM*) parent, PCB_MODULE_T ), @@ -1666,13 +1668,6 @@ double MODULE::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const } -// see convert_drawsegment_list_to_polygon.cpp: -extern bool ConvertOutlineToPolygon( std::vector& aSegList, SHAPE_POLY_SET& aPolygons, - unsigned int aTolerance, wxString* aErrorText, - std::vector* aDiscontinuities = nullptr, - std::vector* aIntersections = nullptr ); - - std::shared_ptr MODULE::GetEffectiveShape( PCB_LAYER_ID aLayer ) const { std::shared_ptr shape ( new SHAPE_NULL ); diff --git a/pcbnew/convert_drawsegment_list_to_polygon.cpp b/pcbnew/convert_drawsegment_list_to_polygon.cpp index a6110e557a..22a72ec55c 100644 --- a/pcbnew/convert_drawsegment_list_to_polygon.cpp +++ b/pcbnew/convert_drawsegment_list_to_polygon.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include diff --git a/pcbnew/convert_drawsegment_list_to_polygon.h b/pcbnew/convert_drawsegment_list_to_polygon.h new file mode 100644 index 0000000000..2c47d1bb85 --- /dev/null +++ b/pcbnew/convert_drawsegment_list_to_polygon.h @@ -0,0 +1,69 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * @file convert_drawsegment_list_to_polygon.h + * @brief functions to convert a shape built with DRAWSEGMENTS to a polygon. + * expecting the shape describes shape similar to a polygon + */ + +#pragma once + +class PCB_SHAPE; +class SHAPE_POLY_SET; +class wxString; +class wxPoint; + +/** + * Function ConvertOutlineToPolygon + * build a polygon (with holes) from a PCB_SHAPE list, which is expected to be + * a outline, therefore a closed main outline with perhaps closed inner outlines. + * These closed inner outlines are considered as holes in the main outline + * @param aSegList the initial list of drawsegments (only lines, circles and arcs). + * @param aPolygons will contain the complex polygon. + * @param aTolerance is the max distance between points that is still accepted as connected + * (internal units) + * @param aErrorText is a wxString to return error message. + * @param aDiscontinuities = an optional array of wxPoint giving the locations of + * discontinuities in the outline + * @param aIntersections = an optional array of wxPoint giving the locations of self- + * intersections in the outline + */ +bool ConvertOutlineToPolygon( std::vector& aSegList, SHAPE_POLY_SET& aPolygons, + unsigned int aTolerance, wxString* aErrorText, + std::vector* aDiscontinuities = nullptr, + std::vector* aIntersections = nullptr ); + + +/** + * Extracts the board outlines and build a closed polygon + * from lines, arcs and circle items on edge cut layer + * Any closed outline inside the main outline is a hole + * All contours should be closed, i.e. are valid vertices for a closed polygon + * return true if success, false if a contour is not valid + */ +extern bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, + unsigned int aTolerance, wxString* aErrorText, + std::vector* aDiscontinuities = nullptr, + std::vector* aIntersections = nullptr ); + diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index 4f49a1ba69..d1ff58de3e 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -36,6 +36,7 @@ #include // LAST_PATH_TYPE #include #include +#include class DIALOG_EXPORT_STEP: public DIALOG_EXPORT_STEP_BASE @@ -234,10 +235,6 @@ void DIALOG_EXPORT_STEP::onUpdateYPos( wxUpdateUIEvent& aEvent ) aEvent.Enable( m_rbUserDefinedOrigin->GetValue() ); } -extern bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, - unsigned int aTolerance, wxString* aErrorText, - std::vector* aDiscontinuities = nullptr, - std::vector* aIntersections = nullptr ); void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent ) {