Minor code cleanup: move "extern" declarations to convert_drawsegment_list_to_polygon.h

This commit is contained in:
jean-pierre charras 2020-10-23 08:48:52 +02:00
parent d8ffea881e
commit 15369915cc
5 changed files with 74 additions and 23 deletions

View File

@ -48,6 +48,7 @@
#include <ratsnest/ratsnest_data.h>
#include <ratsnest/ratsnest_viewitem.h>
#include <tool/selection_conditions.h>
#include <convert_drawsegment_list_to_polygon.h>
/* 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<wxPoint>* aDiscontinuities = nullptr,
std::vector<wxPoint>* aIntersections = nullptr );
bool BOARD::GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, wxString* aErrorText,
std::vector<wxPoint>* aDiscontinuities,
std::vector<wxPoint>* aIntersections )

View File

@ -36,6 +36,8 @@
#include <view/view.h>
#include <geometry/shape_null.h>
#include <i18n_utility.h>
#include <convert_drawsegment_list_to_polygon.h>
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<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET& aPolygons,
unsigned int aTolerance, wxString* aErrorText,
std::vector<wxPoint>* aDiscontinuities = nullptr,
std::vector<wxPoint>* aIntersections = nullptr );
std::shared_ptr<SHAPE> MODULE::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
{
std::shared_ptr<SHAPE> shape ( new SHAPE_NULL );

View File

@ -39,6 +39,7 @@
#include <convert_basic_shapes_to_polygon.h>
#include <geometry/shape_poly_set.h>
#include <geometry/geometry_utils.h>
#include <convert_drawsegment_list_to_polygon.h>
#include <wx/log.h>

View File

@ -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<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET& aPolygons,
unsigned int aTolerance, wxString* aErrorText,
std::vector<wxPoint>* aDiscontinuities = nullptr,
std::vector<wxPoint>* 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<wxPoint>* aDiscontinuities = nullptr,
std::vector<wxPoint>* aIntersections = nullptr );

View File

@ -36,6 +36,7 @@
#include <project/project_file.h> // LAST_PATH_TYPE
#include <widgets/text_ctrl_eval.h>
#include <wx_html_report_panel.h>
#include <convert_drawsegment_list_to_polygon.h>
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<wxPoint>* aDiscontinuities = nullptr,
std::vector<wxPoint>* aIntersections = nullptr );
void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
{