2014-10-23 17:53:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-04-06 13:30:52 +00:00
|
|
|
* Copyright (C) 2009-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2018-03-08 12:48:29 +00:00
|
|
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-23 17:53:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
/***
|
|
|
|
* @file board_items_to_polygon_shape_transform.cpp
|
|
|
|
* @brief function to convert shapes of items ( pads, tracks... ) to polygons
|
|
|
|
*/
|
2009-11-14 19:47:52 +00:00
|
|
|
|
2014-11-29 12:58:34 +00:00
|
|
|
/* Function to convert pad and track shapes to polygons
|
|
|
|
* Used to fill zones areas and in 3D viewer
|
2009-11-14 19:47:52 +00:00
|
|
|
*/
|
|
|
|
#include <vector>
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2018-07-07 11:04:01 +00:00
|
|
|
#include <bezier_curves.h>
|
2018-02-16 14:25:38 +00:00
|
|
|
#include <base_units.h> // for IU_PER_MM
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <draw_graphic_text.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <trigo.h>
|
2014-05-17 19:29:15 +00:00
|
|
|
#include <class_board.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_pad.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_drawsegment.h>
|
|
|
|
#include <class_pcb_text.h>
|
2012-01-29 19:29:19 +00:00
|
|
|
#include <class_zone.h>
|
2013-05-01 19:01:14 +00:00
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_edge_mod.h>
|
2012-08-23 19:15:58 +00:00
|
|
|
#include <convert_basic_shapes_to_polygon.h>
|
2018-03-08 12:48:29 +00:00
|
|
|
#include <geometry/geometry_utils.h>
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2018-04-06 13:30:52 +00:00
|
|
|
// A helper struct for the callback function
|
2014-02-28 10:51:47 +00:00
|
|
|
// These variables are parameters used in addTextSegmToPoly.
|
|
|
|
// But addTextSegmToPoly is a call-back function,
|
|
|
|
// so we cannot send them as arguments.
|
2018-04-06 13:30:52 +00:00
|
|
|
struct TSEGM_2_POLY_PRMS {
|
|
|
|
int m_textWidth;
|
|
|
|
int m_textCircle2SegmentCount;
|
|
|
|
SHAPE_POLY_SET* m_cornerBuffer;
|
|
|
|
};
|
|
|
|
TSEGM_2_POLY_PRMS prms;
|
2014-02-28 10:51:47 +00:00
|
|
|
|
2018-03-08 12:48:29 +00:00
|
|
|
// The max error is the distance between the middle of a segment, and the circle
|
|
|
|
// for circle/arc to segment approximation.
|
|
|
|
// Warning: too small values can create very long calculation time in zone filling
|
2018-03-09 12:36:54 +00:00
|
|
|
// 0.05 to 0.01 mm is a reasonable value
|
|
|
|
double s_error_max = Millimeter2iu( 0.02 );
|
2018-03-08 12:48:29 +00:00
|
|
|
|
2014-02-28 10:51:47 +00:00
|
|
|
// This is a call back function, used by DrawGraphicText to draw the 3D text shape:
|
2018-04-06 13:30:52 +00:00
|
|
|
static void addTextSegmToPoly( int x0, int y0, int xf, int yf, void* aData )
|
2014-02-28 10:51:47 +00:00
|
|
|
{
|
2018-04-06 13:30:52 +00:00
|
|
|
TSEGM_2_POLY_PRMS* prm = static_cast<TSEGM_2_POLY_PRMS*>( aData );
|
|
|
|
TransformRoundedEndsSegmentToPolygon( *prm->m_cornerBuffer,
|
2014-02-28 10:51:47 +00:00
|
|
|
wxPoint( x0, y0), wxPoint( xf, yf ),
|
2018-04-06 13:30:52 +00:00
|
|
|
prm->m_textCircle2SegmentCount, prm->m_textWidth );
|
2014-02-28 10:51:47 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines )
|
2014-05-17 19:29:15 +00:00
|
|
|
{
|
|
|
|
// Number of segments to convert a circle to a polygon
|
2019-01-04 01:34:59 +00:00
|
|
|
const int segcountforcircle = ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF;
|
2018-03-08 12:48:29 +00:00
|
|
|
double correctionFactor = GetCircletoPolyCorrectionFactor( segcountforcircle );
|
2014-05-17 19:29:15 +00:00
|
|
|
|
|
|
|
// convert tracks and vias:
|
|
|
|
for( TRACK* track = m_Track; track != NULL; track = track->Next() )
|
|
|
|
{
|
|
|
|
if( !track->IsOnLayer( aLayer ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
track->TransformShapeWithClearanceToPolygon( aOutlines,
|
|
|
|
0, segcountforcircle, correctionFactor );
|
|
|
|
}
|
|
|
|
|
|
|
|
// convert pads
|
|
|
|
for( MODULE* module = m_Modules; module != NULL; module = module->Next() )
|
|
|
|
{
|
|
|
|
module->TransformPadsShapesWithClearanceToPolygon( aLayer,
|
|
|
|
aOutlines, 0, segcountforcircle, correctionFactor );
|
|
|
|
|
|
|
|
// Micro-wave modules may have items on copper layers
|
|
|
|
module->TransformGraphicShapesWithClearanceToPolygonSet( aLayer,
|
|
|
|
aOutlines, 0, segcountforcircle, correctionFactor );
|
|
|
|
}
|
|
|
|
|
|
|
|
// convert copper zones
|
|
|
|
for( int ii = 0; ii < GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone = GetArea( ii );
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID zonelayer = zone->GetLayer();
|
2014-05-17 19:29:15 +00:00
|
|
|
|
|
|
|
if( zonelayer == aLayer )
|
|
|
|
zone->TransformSolidAreasShapesToPolygonSet(
|
|
|
|
aOutlines, segcountforcircle, correctionFactor );
|
|
|
|
}
|
|
|
|
|
|
|
|
// convert graphic items on copper layers (texts)
|
|
|
|
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( !item->IsOnLayer( aLayer ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2019-04-05 16:10:59 +00:00
|
|
|
case PCB_LINE_T:
|
2014-05-17 19:29:15 +00:00
|
|
|
( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
|
|
|
|
aOutlines, 0, segcountforcircle, correctionFactor );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
|
|
|
|
aOutlines, 0, segcountforcircle, correctionFactor );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void MODULE::TransformPadsShapesWithClearanceToPolygon( PCB_LAYER_ID aLayer,
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET& aCornerBuffer,
|
2013-05-01 19:01:14 +00:00
|
|
|
int aInflateValue,
|
|
|
|
int aCircleToSegmentsCount,
|
2015-03-23 08:28:12 +00:00
|
|
|
double aCorrectionFactor,
|
2016-07-19 17:35:25 +00:00
|
|
|
bool aSkipNPTHPadsWihNoCopper ) const
|
2013-05-01 19:01:14 +00:00
|
|
|
{
|
2017-04-25 09:06:24 +00:00
|
|
|
D_PAD* pad = PadsList();
|
2013-05-01 19:01:14 +00:00
|
|
|
|
|
|
|
wxSize margin;
|
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
2018-02-19 00:00:29 +00:00
|
|
|
if( aLayer != UNDEFINED_LAYER && !pad->IsOnLayer(aLayer) )
|
2013-05-01 19:01:14 +00:00
|
|
|
continue;
|
|
|
|
|
2015-03-23 08:28:12 +00:00
|
|
|
// NPTH pads are not drawn on layers if the shape size and pos is the same
|
|
|
|
// as their hole:
|
2015-08-23 19:40:33 +00:00
|
|
|
if( aSkipNPTHPadsWihNoCopper && pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
|
2015-03-23 08:28:12 +00:00
|
|
|
{
|
|
|
|
if( pad->GetDrillSize() == pad->GetSize() && pad->GetOffset() == wxPoint( 0, 0 ) )
|
|
|
|
{
|
|
|
|
switch( pad->GetShape() )
|
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_CIRCLE:
|
|
|
|
if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
|
2015-03-23 08:28:12 +00:00
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_OVAL:
|
|
|
|
if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
|
2015-03-23 08:28:12 +00:00
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-01 19:01:14 +00:00
|
|
|
|
|
|
|
switch( aLayer )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
case F_Mask:
|
|
|
|
case B_Mask:
|
2013-05-01 19:01:14 +00:00
|
|
|
margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
|
|
|
|
break;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
case F_Paste:
|
|
|
|
case B_Paste:
|
2013-05-01 19:01:14 +00:00
|
|
|
margin = pad->GetSolderPasteMargin();
|
|
|
|
margin.x += aInflateValue;
|
|
|
|
margin.y += aInflateValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
margin.x = margin.y = aInflateValue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pad->BuildPadShapePolygon( aCornerBuffer, margin,
|
|
|
|
aCircleToSegmentsCount, aCorrectionFactor );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* generate shapes of graphic items (outlines) on layer aLayer as polygons,
|
|
|
|
* and adds these polygons to aCornerBuffer
|
|
|
|
* aCornerBuffer = the buffer to store polygons
|
|
|
|
* aInflateValue = a value to inflate shapes
|
|
|
|
* aCircleToSegmentsCount = number of segments to approximate a circle
|
|
|
|
* aCorrectionFactor = the correction to apply to the circle radius
|
|
|
|
* to generate the polygon.
|
|
|
|
* if aCorrectionFactor = 1.0, the polygon is inside the circle
|
|
|
|
* the radius of circle approximated by segments is
|
|
|
|
* initial radius * aCorrectionFactor
|
|
|
|
*/
|
|
|
|
void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID aLayer,
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET& aCornerBuffer,
|
2015-08-11 11:56:02 +00:00
|
|
|
int aInflateValue,
|
|
|
|
int aCircleToSegmentsCount,
|
|
|
|
double aCorrectionFactor,
|
2018-02-19 00:00:29 +00:00
|
|
|
int aCircleToSegmentsCountForTexts,
|
|
|
|
bool aIncludeText ) const
|
2013-05-01 19:01:14 +00:00
|
|
|
{
|
2014-02-28 10:51:47 +00:00
|
|
|
std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
|
2013-05-01 19:01:14 +00:00
|
|
|
EDGE_MODULE* outline;
|
2014-02-28 10:51:47 +00:00
|
|
|
|
2017-04-25 09:06:24 +00:00
|
|
|
for( EDA_ITEM* item = GraphicalItemsList(); item != NULL; item = item->Next() )
|
2013-05-01 19:01:14 +00:00
|
|
|
{
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_MODULE_TEXT_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
{
|
|
|
|
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
|
2015-03-11 13:59:43 +00:00
|
|
|
|
2018-02-19 00:00:29 +00:00
|
|
|
if( ( aLayer != UNDEFINED_LAYER && text->GetLayer() == aLayer )
|
|
|
|
&& text->IsVisible() )
|
2014-09-10 15:18:42 +00:00
|
|
|
texts.push_back( text );
|
2015-03-11 13:59:43 +00:00
|
|
|
|
2014-09-10 15:18:42 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-05-01 19:01:14 +00:00
|
|
|
|
|
|
|
case PCB_MODULE_EDGE_T:
|
|
|
|
outline = (EDGE_MODULE*) item;
|
|
|
|
|
2018-02-19 00:00:29 +00:00
|
|
|
if( aLayer != UNDEFINED_LAYER && outline->GetLayer() != aLayer )
|
2013-05-01 19:01:14 +00:00
|
|
|
break;
|
2016-06-07 12:42:42 +00:00
|
|
|
|
|
|
|
outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, 0,
|
|
|
|
aCircleToSegmentsCount, aCorrectionFactor );
|
|
|
|
break;
|
2013-05-01 19:01:14 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-02-28 10:51:47 +00:00
|
|
|
|
2018-02-19 00:00:29 +00:00
|
|
|
if( !aIncludeText )
|
|
|
|
return;
|
|
|
|
|
2014-02-28 10:51:47 +00:00
|
|
|
// Convert texts sur modules
|
|
|
|
if( Reference().GetLayer() == aLayer && Reference().IsVisible() )
|
|
|
|
texts.push_back( &Reference() );
|
|
|
|
|
|
|
|
if( Value().GetLayer() == aLayer && Value().IsVisible() )
|
|
|
|
texts.push_back( &Value() );
|
|
|
|
|
2018-04-06 13:30:52 +00:00
|
|
|
prms.m_cornerBuffer = &aCornerBuffer;
|
2015-08-11 11:56:02 +00:00
|
|
|
|
|
|
|
// To allow optimization of circles approximated by segments,
|
|
|
|
// aCircleToSegmentsCountForTexts, when not 0, is used.
|
|
|
|
// if 0 (default value) the aCircleToSegmentsCount is used
|
2018-04-06 13:30:52 +00:00
|
|
|
prms.m_textCircle2SegmentCount = aCircleToSegmentsCountForTexts ?
|
2015-08-11 11:56:02 +00:00
|
|
|
aCircleToSegmentsCountForTexts : aCircleToSegmentsCount;
|
2014-02-28 10:51:47 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < texts.size(); ii++ )
|
|
|
|
{
|
|
|
|
TEXTE_MODULE *textmod = texts[ii];
|
2018-04-06 13:30:52 +00:00
|
|
|
prms.m_textWidth = textmod->GetThickness() + ( 2 * aInflateValue );
|
2017-01-23 20:30:11 +00:00
|
|
|
wxSize size = textmod->GetTextSize();
|
2014-02-28 17:46:18 +00:00
|
|
|
|
|
|
|
if( textmod->IsMirrored() )
|
2015-06-26 13:41:56 +00:00
|
|
|
size.x = -size.x;
|
2014-02-28 17:46:18 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK,
|
2014-09-13 18:15:45 +00:00
|
|
|
textmod->GetShownText(), textmod->GetDrawRotation(), size,
|
2014-02-28 10:51:47 +00:00
|
|
|
textmod->GetHorizJustify(), textmod->GetVertJustify(),
|
|
|
|
textmod->GetThickness(), textmod->IsItalic(),
|
2018-04-06 13:30:52 +00:00
|
|
|
true, addTextSegmToPoly, &prms );
|
2014-02-28 10:51:47 +00:00
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Same as function TransformGraphicShapesWithClearanceToPolygonSet but
|
|
|
|
// this only render text
|
|
|
|
void MODULE::TransformGraphicTextWithClearanceToPolygonSet(
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID aLayer,
|
2016-07-19 17:35:25 +00:00
|
|
|
SHAPE_POLY_SET& aCornerBuffer,
|
|
|
|
int aInflateValue,
|
|
|
|
int aCircleToSegmentsCount,
|
|
|
|
double aCorrectionFactor,
|
|
|
|
int aCircleToSegmentsCountForTexts ) const
|
|
|
|
{
|
|
|
|
std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
|
|
|
|
|
2017-04-25 09:06:24 +00:00
|
|
|
for( EDA_ITEM* item = GraphicalItemsList(); item != NULL; item = item->Next() )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_MODULE_TEXT_T:
|
|
|
|
{
|
|
|
|
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
|
|
|
|
|
|
|
|
if( text->GetLayer() == aLayer && text->IsVisible() )
|
|
|
|
texts.push_back( text );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PCB_MODULE_EDGE_T:
|
|
|
|
// This function does not render this
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert texts sur modules
|
|
|
|
if( Reference().GetLayer() == aLayer && Reference().IsVisible() )
|
|
|
|
texts.push_back( &Reference() );
|
|
|
|
|
|
|
|
if( Value().GetLayer() == aLayer && Value().IsVisible() )
|
|
|
|
texts.push_back( &Value() );
|
|
|
|
|
2018-04-06 13:30:52 +00:00
|
|
|
prms.m_cornerBuffer = &aCornerBuffer;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// To allow optimization of circles approximated by segments,
|
|
|
|
// aCircleToSegmentsCountForTexts, when not 0, is used.
|
|
|
|
// if 0 (default value) the aCircleToSegmentsCount is used
|
2018-04-06 13:30:52 +00:00
|
|
|
prms.m_textCircle2SegmentCount = aCircleToSegmentsCountForTexts ?
|
2016-07-19 17:35:25 +00:00
|
|
|
aCircleToSegmentsCountForTexts : aCircleToSegmentsCount;
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < texts.size(); ii++ )
|
|
|
|
{
|
|
|
|
TEXTE_MODULE *textmod = texts[ii];
|
2018-04-06 13:30:52 +00:00
|
|
|
prms.m_textWidth = textmod->GetThickness() + ( 2 * aInflateValue );
|
2017-01-23 20:30:11 +00:00
|
|
|
wxSize size = textmod->GetTextSize();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
if( textmod->IsMirrored() )
|
|
|
|
size.x = -size.x;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK,
|
2016-07-19 17:35:25 +00:00
|
|
|
textmod->GetShownText(), textmod->GetDrawRotation(), size,
|
|
|
|
textmod->GetHorizJustify(), textmod->GetVertJustify(),
|
|
|
|
textmod->GetThickness(), textmod->IsItalic(),
|
2018-04-06 13:30:52 +00:00
|
|
|
true, addTextSegmToPoly, &prms );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Function TransformSolidAreasShapesToPolygonSet
|
|
|
|
* Convert solid areas full shapes to polygon set
|
|
|
|
* (the full shape is the polygon area with a thick outline)
|
|
|
|
* Used in 3D view
|
|
|
|
* Arcs (ends of segments) are approximated by segments
|
|
|
|
* aCornerBuffer = a buffer to store the polygons
|
|
|
|
* aCircleToSegmentsCount = the number of segments to approximate a circle
|
|
|
|
* aCorrectionFactor = the correction to apply to arcs radius to roughly
|
|
|
|
* keep arc radius when approximated by segments
|
|
|
|
*/
|
|
|
|
void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET& aCornerBuffer,
|
2013-05-01 19:01:14 +00:00
|
|
|
int aCircleToSegmentsCount,
|
2016-07-19 17:35:25 +00:00
|
|
|
double aCorrectionFactor ) const
|
2013-05-01 19:01:14 +00:00
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
if( GetFilledPolysList().IsEmpty() )
|
2013-05-01 19:01:14 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// add filled areas polygons
|
2013-05-08 18:20:58 +00:00
|
|
|
aCornerBuffer.Append( m_FilledPolysList );
|
2013-05-01 19:01:14 +00:00
|
|
|
|
2015-04-09 18:53:36 +00:00
|
|
|
// add filled areas outlines, which are drawn with thick lines
|
2015-07-27 19:45:57 +00:00
|
|
|
for( int i = 0; i < m_FilledPolysList.OutlineCount(); i++ )
|
2013-05-01 19:01:14 +00:00
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
const SHAPE_LINE_CHAIN& path = m_FilledPolysList.COutline( i );
|
2013-05-01 19:01:14 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
for( int j = 0; j < path.PointCount(); j++ )
|
2015-07-14 20:23:13 +00:00
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
const VECTOR2I& a = path.CPoint( j );
|
|
|
|
const VECTOR2I& b = path.CPoint( j + 1 );
|
2015-07-14 20:23:13 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
TransformRoundedEndsSegmentToPolygon( aCornerBuffer, wxPoint( a.x, a.y ), wxPoint( b.x, b.y ),
|
|
|
|
aCircleToSegmentsCount,
|
|
|
|
GetMinThickness() );
|
|
|
|
}
|
2013-05-01 19:01:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
2013-05-01 19:01:14 +00:00
|
|
|
* Function TransformBoundingBoxWithClearanceToPolygon
|
2014-08-13 15:47:02 +00:00
|
|
|
* Convert the text bounding box to a rectangular polygon
|
2009-11-16 08:13:40 +00:00
|
|
|
* Used in filling zones calculations
|
|
|
|
* Circles and arcs are approximated by segments
|
|
|
|
* @param aCornerBuffer = a buffer to store the polygon
|
2014-08-13 15:47:02 +00:00
|
|
|
* @param aClearanceValue = the clearance around the text bounding box
|
2009-11-16 08:13:40 +00:00
|
|
|
*/
|
2018-08-23 22:41:57 +00:00
|
|
|
void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(
|
|
|
|
SHAPE_POLY_SET* aCornerBuffer,
|
2015-07-27 19:45:57 +00:00
|
|
|
int aClearanceValue ) const
|
2009-11-16 08:13:40 +00:00
|
|
|
{
|
2018-04-05 21:40:02 +00:00
|
|
|
// Oh dear. When in UTF-8 mode, wxString puts string iterators in a linked list, and
|
|
|
|
// that linked list is not thread-safe.
|
|
|
|
std::lock_guard<std::mutex> guard( m_mutex );
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( GetText().Length() == 0 )
|
2009-11-16 08:13:40 +00:00
|
|
|
return;
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
wxPoint corners[4]; // Buffer of polygon corners
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT rect = GetTextBox( -1 );
|
2009-11-28 09:24:37 +00:00
|
|
|
rect.Inflate( aClearanceValue );
|
2009-11-16 08:13:40 +00:00
|
|
|
corners[0].x = rect.GetOrigin().x;
|
|
|
|
corners[0].y = rect.GetOrigin().y;
|
|
|
|
corners[1].y = corners[0].y;
|
|
|
|
corners[1].x = rect.GetRight();
|
|
|
|
corners[2].x = corners[1].x;
|
|
|
|
corners[2].y = rect.GetBottom();
|
|
|
|
corners[3].y = corners[2].y;
|
|
|
|
corners[3].x = corners[0].x;
|
|
|
|
|
2018-08-23 22:41:57 +00:00
|
|
|
aCornerBuffer->NewOutline();
|
2015-07-27 19:45:57 +00:00
|
|
|
|
2009-11-16 08:13:40 +00:00
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
|
|
|
{
|
|
|
|
// Rotate polygon
|
2017-01-23 20:30:11 +00:00
|
|
|
RotatePoint( &corners[ii].x, &corners[ii].y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
|
2018-08-23 22:41:57 +00:00
|
|
|
aCornerBuffer->Append( corners[ii].x, corners[ii].y );
|
2009-11-16 08:13:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-29 19:29:19 +00:00
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
/* Function TransformShapeWithClearanceToPolygonSet
|
|
|
|
* Convert the text shape to a set of polygons (one by segment)
|
|
|
|
* Used in filling zones calculations and 3D view
|
|
|
|
* Circles and arcs are approximated by segments
|
2015-07-27 19:45:57 +00:00
|
|
|
* aCornerBuffer = SHAPE_POLY_SET to store the polygon corners
|
2013-05-01 19:01:14 +00:00
|
|
|
* aClearanceValue = the clearance around the text
|
|
|
|
* aCircleToSegmentsCount = the number of segments to approximate a circle
|
|
|
|
* aCorrectionFactor = the correction to apply to circles radius to keep
|
|
|
|
* clearance when the circle is approximated by segment bigger or equal
|
|
|
|
* to the real clearance value (usually near from 1.0)
|
|
|
|
*/
|
2012-01-29 19:29:19 +00:00
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET& aCornerBuffer,
|
2013-05-01 19:01:14 +00:00
|
|
|
int aClearanceValue,
|
|
|
|
int aCircleToSegmentsCount,
|
|
|
|
double aCorrectionFactor ) const
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
wxSize size = GetTextSize();
|
2012-01-29 19:29:19 +00:00
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
if( IsMirrored() )
|
2015-06-26 13:41:56 +00:00
|
|
|
size.x = -size.x;
|
2012-01-29 19:29:19 +00:00
|
|
|
|
2018-04-06 13:30:52 +00:00
|
|
|
prms.m_cornerBuffer = &aCornerBuffer;
|
|
|
|
prms.m_textWidth = GetThickness() + ( 2 * aClearanceValue );
|
|
|
|
prms.m_textCircle2SegmentCount = aCircleToSegmentsCount;
|
2017-02-20 17:48:27 +00:00
|
|
|
COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by DrawGraphicText
|
2012-01-29 19:29:19 +00:00
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
if( IsMultilineAllowed() )
|
2012-01-29 19:29:19 +00:00
|
|
|
{
|
2015-01-15 20:01:53 +00:00
|
|
|
wxArrayString strings_list;
|
|
|
|
wxStringSplit( GetShownText(), strings_list, '\n' );
|
2013-12-27 07:24:36 +00:00
|
|
|
std::vector<wxPoint> positions;
|
2015-01-15 20:01:53 +00:00
|
|
|
positions.reserve( strings_list.Count() );
|
|
|
|
GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
|
2012-01-29 19:29:19 +00:00
|
|
|
|
2015-01-15 20:01:53 +00:00
|
|
|
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
2012-01-29 19:29:19 +00:00
|
|
|
{
|
2015-01-15 20:01:53 +00:00
|
|
|
wxString txt = strings_list.Item( ii );
|
2013-12-27 07:24:36 +00:00
|
|
|
DrawGraphicText( NULL, NULL, positions[ii], color,
|
2017-01-23 20:30:11 +00:00
|
|
|
txt, GetTextAngle(), size,
|
2013-05-01 19:01:14 +00:00
|
|
|
GetHorizJustify(), GetVertJustify(),
|
|
|
|
GetThickness(), IsItalic(),
|
2018-04-06 13:30:52 +00:00
|
|
|
true, addTextSegmToPoly, &prms );
|
2012-01-29 19:29:19 +00:00
|
|
|
}
|
2013-05-01 19:01:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
DrawGraphicText( NULL, NULL, GetTextPos(), color,
|
|
|
|
GetShownText(), GetTextAngle(), size,
|
2013-05-01 19:01:14 +00:00
|
|
|
GetHorizJustify(), GetVertJustify(),
|
|
|
|
GetThickness(), IsItalic(),
|
2018-04-06 13:30:52 +00:00
|
|
|
true, addTextSegmToPoly, &prms );
|
2012-01-29 19:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function TransformShapeWithClearanceToPolygon
|
2009-11-16 08:13:40 +00:00
|
|
|
* Convert the track shape to a closed polygon
|
|
|
|
* Used in filling zones calculations
|
|
|
|
* Circles and arcs are approximated by segments
|
|
|
|
* @param aCornerBuffer = a buffer to store the polygon
|
|
|
|
* @param aClearanceValue = the clearance around the pad
|
|
|
|
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
|
|
|
|
* @param aCorrectionFactor = the correction to apply to circles radius to keep
|
|
|
|
* clearance when the circle is approxiamted by segment bigger or equal
|
|
|
|
* to the real clearance value (usually near from 1.0)
|
2018-11-14 23:34:32 +00:00
|
|
|
* @param ignoreLineWidth = used for edge cut items where the line width is only
|
|
|
|
* for visualization
|
2009-11-16 08:13:40 +00:00
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
2015-11-02 09:24:32 +00:00
|
|
|
int aClearanceValue,
|
|
|
|
int aCircleToSegmentsCount,
|
2018-11-14 23:34:32 +00:00
|
|
|
double aCorrectionFactor,
|
|
|
|
bool ignoreLineWidth ) const
|
2009-11-16 08:13:40 +00:00
|
|
|
{
|
2015-04-09 18:53:36 +00:00
|
|
|
// The full width of the lines to create:
|
2018-11-14 23:34:32 +00:00
|
|
|
int linewidth = ignoreLineWidth ? 0 : m_Width;
|
|
|
|
|
|
|
|
linewidth += 2 * aClearanceValue;
|
2015-04-09 18:53:36 +00:00
|
|
|
|
2018-03-09 14:56:00 +00:00
|
|
|
// Creating a reliable clearance shape for circles and arcs is not so easy, due to
|
|
|
|
// the error created by segment approximation.
|
|
|
|
// for a cicle this is not so hard: create a polygon from a circle slightly bigger:
|
|
|
|
// thickness = linewidth + s_error_max, and radius = initial radius + s_error_max/2
|
|
|
|
// giving a shape with a suitable internal radius and external radius
|
|
|
|
// For an arc this is more tricky: TODO
|
2018-02-16 14:25:38 +00:00
|
|
|
if( m_Shape == S_CIRCLE || m_Shape == S_ARC )
|
|
|
|
{
|
2018-03-08 12:48:29 +00:00
|
|
|
int segCount = GetArcToSegmentCount( GetRadius(), s_error_max, 360.0 );
|
2018-03-07 13:16:26 +00:00
|
|
|
|
|
|
|
if( segCount > aCircleToSegmentsCount )
|
|
|
|
aCircleToSegmentsCount = segCount;
|
2018-02-16 14:25:38 +00:00
|
|
|
}
|
|
|
|
|
2009-11-16 08:13:40 +00:00
|
|
|
switch( m_Shape )
|
|
|
|
{
|
|
|
|
case S_CIRCLE:
|
2018-03-09 14:56:00 +00:00
|
|
|
TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius() + (s_error_max/2),
|
|
|
|
aCircleToSegmentsCount, linewidth + s_error_max ) ;
|
2009-11-16 08:13:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2013-05-01 19:01:14 +00:00
|
|
|
TransformArcToPolygon( aCornerBuffer, GetCenter(),
|
|
|
|
GetArcStart(), m_Angle,
|
2015-04-09 18:53:36 +00:00
|
|
|
aCircleToSegmentsCount, linewidth );
|
2009-11-16 08:13:40 +00:00
|
|
|
break;
|
|
|
|
|
2015-04-09 18:53:36 +00:00
|
|
|
case S_SEGMENT:
|
2018-01-21 10:32:37 +00:00
|
|
|
TransformOvalClearanceToPolygon( aCornerBuffer, m_Start, m_End, linewidth,
|
|
|
|
aCircleToSegmentsCount, aCorrectionFactor );
|
2015-04-09 18:53:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_POLYGON:
|
2018-01-24 13:22:43 +00:00
|
|
|
if( IsPolyShapeValid() )
|
2015-04-09 18:53:36 +00:00
|
|
|
{
|
2018-01-24 13:22:43 +00:00
|
|
|
// The polygon is expected to be a simple polygon
|
|
|
|
// not self intersecting, no hole.
|
|
|
|
MODULE* module = GetParentModule(); // NULL for items not in footprints
|
|
|
|
double orientation = module ? module->GetOrientation() : 0.0;
|
|
|
|
wxPoint offset;
|
2017-12-21 14:06:29 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
if( module )
|
|
|
|
offset = module->GetPosition();
|
2015-04-09 18:53:36 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
// Build the polygon with the actual position and orientation:
|
|
|
|
std::vector< wxPoint> poly;
|
|
|
|
poly = BuildPolyPointsList();
|
2015-04-09 18:53:36 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
for( unsigned ii = 0; ii < poly.size(); ii++ )
|
|
|
|
{
|
|
|
|
RotatePoint( &poly[ii], orientation );
|
|
|
|
poly[ii] += offset;
|
|
|
|
}
|
2015-11-02 09:24:32 +00:00
|
|
|
|
2018-12-05 11:13:52 +00:00
|
|
|
// If the polygon is not filled, treat it as a closed set of lines
|
|
|
|
if( !IsPolygonFilled() )
|
2018-12-02 04:41:17 +00:00
|
|
|
{
|
|
|
|
for( size_t ii = 1; ii < poly.size(); ii++ )
|
|
|
|
{
|
|
|
|
TransformOvalClearanceToPolygon( aCornerBuffer, poly[ii - 1], poly[ii],
|
|
|
|
linewidth, aCircleToSegmentsCount, aCorrectionFactor );
|
|
|
|
}
|
|
|
|
|
2018-12-05 11:13:52 +00:00
|
|
|
TransformOvalClearanceToPolygon( aCornerBuffer, poly.back(), poly.front(),
|
2018-12-02 04:41:17 +00:00
|
|
|
linewidth, aCircleToSegmentsCount, aCorrectionFactor );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
// Generate polygons for the outline + clearance
|
|
|
|
// This code is compatible with a polygon with holes linked to external outline
|
|
|
|
// by overlapping segments.
|
2015-11-02 09:24:32 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
// Insert the initial polygon:
|
|
|
|
aCornerBuffer.NewOutline();
|
2015-04-09 18:53:36 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < poly.size(); ii++ )
|
2018-01-24 13:22:43 +00:00
|
|
|
aCornerBuffer.Append( poly[ii].x, poly[ii].y );
|
|
|
|
|
|
|
|
if( linewidth ) // Add thick outlines
|
2015-04-09 18:53:36 +00:00
|
|
|
{
|
2018-01-24 13:22:43 +00:00
|
|
|
wxPoint corner1( poly[poly.size()-1] );
|
2015-04-09 18:53:36 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
for( unsigned ii = 0; ii < poly.size(); ii++ )
|
2015-04-09 18:53:36 +00:00
|
|
|
{
|
2018-01-24 13:22:43 +00:00
|
|
|
wxPoint corner2( poly[ii] );
|
2015-04-09 18:53:36 +00:00
|
|
|
|
2018-01-24 13:22:43 +00:00
|
|
|
if( corner2 != corner1 )
|
|
|
|
{
|
|
|
|
TransformRoundedEndsSegmentToPolygon( aCornerBuffer,
|
|
|
|
corner1, corner2, aCircleToSegmentsCount, linewidth );
|
|
|
|
}
|
|
|
|
|
|
|
|
corner1 = corner2;
|
|
|
|
}
|
2015-04-09 18:53:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-07-07 11:04:01 +00:00
|
|
|
case S_CURVE: // Bezier curve
|
|
|
|
{
|
|
|
|
std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
|
|
|
|
BEZIER_POLY converter( ctrlPoints );
|
|
|
|
std::vector< wxPoint> poly;
|
|
|
|
converter.GetPoly( poly, m_Width );
|
|
|
|
|
|
|
|
for( unsigned ii = 1; ii < poly.size(); ii++ )
|
|
|
|
{
|
|
|
|
TransformRoundedEndsSegmentToPolygon( aCornerBuffer,
|
|
|
|
poly[ii-1], poly[ii], aCircleToSegmentsCount, linewidth );
|
|
|
|
}
|
|
|
|
}
|
2015-04-09 18:53:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-11-16 08:13:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function TransformShapeWithClearanceToPolygon
|
2009-11-14 19:47:52 +00:00
|
|
|
* Convert the track shape to a closed polygon
|
|
|
|
* Used in filling zones calculations
|
|
|
|
* Circles (vias) and arcs (ends of tracks) are approximated by segments
|
|
|
|
* @param aCornerBuffer = a buffer to store the polygon
|
|
|
|
* @param aClearanceValue = the clearance around the pad
|
|
|
|
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
|
|
|
|
* @param aCorrectionFactor = the correction to apply to circles radius to keep
|
2013-05-01 19:01:14 +00:00
|
|
|
* clearance when the circle is approximated by segment bigger or equal
|
2009-11-14 19:47:52 +00:00
|
|
|
* to the real clearance value (usually near from 1.0)
|
2018-11-14 23:34:32 +00:00
|
|
|
* @param ignoreLineWidth = used for edge cut items where the line width is only
|
|
|
|
* for visualization
|
2009-11-14 19:47:52 +00:00
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
void TRACK::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
2018-01-21 10:32:37 +00:00
|
|
|
int aClearanceValue,
|
|
|
|
int aCircleToSegmentsCount,
|
2018-11-14 23:34:32 +00:00
|
|
|
double aCorrectionFactor,
|
|
|
|
bool ignoreLineWidth ) const
|
2009-11-14 19:47:52 +00:00
|
|
|
{
|
2018-11-14 23:34:32 +00:00
|
|
|
wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for tracks." );
|
|
|
|
|
2009-11-14 19:47:52 +00:00
|
|
|
switch( Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_VIA_T:
|
2012-08-23 19:15:58 +00:00
|
|
|
{
|
|
|
|
int radius = (m_Width / 2) + aClearanceValue;
|
|
|
|
radius = KiROUND( radius * aCorrectionFactor );
|
|
|
|
TransformCircleToPolygon( aCornerBuffer, m_Start, radius, aCircleToSegmentsCount );
|
|
|
|
}
|
2009-11-14 19:47:52 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-01-21 10:32:37 +00:00
|
|
|
TransformOvalClearanceToPolygon( aCornerBuffer, m_Start, m_End,
|
|
|
|
m_Width + ( 2 * aClearanceValue),
|
|
|
|
aCircleToSegmentsCount,
|
|
|
|
aCorrectionFactor );
|
2009-11-14 19:47:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
/* Function TransformShapeWithClearanceToPolygon
|
2009-11-14 19:47:52 +00:00
|
|
|
* Convert the pad shape to a closed polygon
|
2013-05-01 19:01:14 +00:00
|
|
|
* Used in filling zones calculations and 3D view generation
|
2009-11-14 19:47:52 +00:00
|
|
|
* Circles and arcs are approximated by segments
|
2015-07-27 19:45:57 +00:00
|
|
|
* aCornerBuffer = a SHAPE_POLY_SET to store the polygon corners
|
2013-05-01 19:01:14 +00:00
|
|
|
* aClearanceValue = the clearance around the pad
|
|
|
|
* aCircleToSegmentsCount = the number of segments to approximate a circle
|
|
|
|
* aCorrectionFactor = the correction to apply to circles radius to keep
|
|
|
|
* clearance when the circle is approximated by segment bigger or equal
|
2009-11-14 19:47:52 +00:00
|
|
|
* to the real clearance value (usually near from 1.0)
|
2018-11-14 23:34:32 +00:00
|
|
|
* @param ignoreLineWidth = used for edge cut items where the line width is only
|
|
|
|
* for visualization
|
2009-11-14 19:47:52 +00:00
|
|
|
*/
|
2016-04-06 18:15:49 +00:00
|
|
|
void D_PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
2013-05-03 17:51:10 +00:00
|
|
|
int aClearanceValue,
|
|
|
|
int aCircleToSegmentsCount,
|
2018-11-14 23:34:32 +00:00
|
|
|
double aCorrectionFactor,
|
|
|
|
bool ignoreLineWidth ) const
|
2009-11-14 19:47:52 +00:00
|
|
|
{
|
2018-11-14 23:34:32 +00:00
|
|
|
wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for pads." );
|
|
|
|
|
2014-11-29 12:58:34 +00:00
|
|
|
double angle = m_Orient;
|
2011-11-24 17:32:51 +00:00
|
|
|
int dx = (m_Size.x / 2) + aClearanceValue;
|
|
|
|
int dy = (m_Size.y / 2) + aClearanceValue;
|
2009-11-14 19:47:52 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
wxPoint padShapePos = ShapePos(); /* Note: for pad having a shape offset,
|
2011-09-07 19:41:04 +00:00
|
|
|
* the pad position is NOT the shape position */
|
2009-11-14 19:47:52 +00:00
|
|
|
|
2014-01-26 14:20:58 +00:00
|
|
|
switch( GetShape() )
|
2009-11-14 19:47:52 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_CIRCLE:
|
2013-05-04 11:57:09 +00:00
|
|
|
dx = KiROUND( dx * aCorrectionFactor );
|
2016-04-06 18:15:49 +00:00
|
|
|
TransformCircleToPolygon( aCornerBuffer, padShapePos, dx,
|
2012-08-23 19:15:58 +00:00
|
|
|
aCircleToSegmentsCount );
|
2009-11-14 19:47:52 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_OVAL:
|
2012-08-23 19:15:58 +00:00
|
|
|
// An oval pad has the same shape as a segment with rounded ends
|
|
|
|
{
|
|
|
|
int width;
|
|
|
|
wxPoint shape_offset;
|
|
|
|
if( dy > dx ) // Oval pad X/Y ratio for choosing translation axis
|
2009-11-14 19:47:52 +00:00
|
|
|
{
|
2012-08-23 19:15:58 +00:00
|
|
|
shape_offset.y = dy - dx;
|
|
|
|
width = dx * 2;
|
2009-11-14 19:47:52 +00:00
|
|
|
}
|
|
|
|
else //if( dy <= dx )
|
|
|
|
{
|
2012-08-23 19:15:58 +00:00
|
|
|
shape_offset.x = dy - dx;
|
|
|
|
width = dy * 2;
|
|
|
|
}
|
2009-11-14 19:47:52 +00:00
|
|
|
|
2012-08-23 19:15:58 +00:00
|
|
|
RotatePoint( &shape_offset, angle );
|
2016-04-06 18:15:49 +00:00
|
|
|
wxPoint start = padShapePos - shape_offset;
|
|
|
|
wxPoint end = padShapePos + shape_offset;
|
2018-01-20 18:34:50 +00:00
|
|
|
TransformOvalClearanceToPolygon( aCornerBuffer, start, end, width,
|
|
|
|
aCircleToSegmentsCount, aCorrectionFactor );
|
2009-11-14 19:47:52 +00:00
|
|
|
}
|
2012-08-23 19:15:58 +00:00
|
|
|
break;
|
2009-11-14 19:47:52 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_TRAPEZOID:
|
|
|
|
case PAD_SHAPE_RECT:
|
2014-11-29 12:58:34 +00:00
|
|
|
{
|
|
|
|
wxPoint corners[4];
|
|
|
|
BuildPadPolygon( corners, wxSize( 0, 0 ), angle );
|
2009-11-14 19:47:52 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET outline;
|
|
|
|
outline.NewOutline();
|
2009-11-14 19:47:52 +00:00
|
|
|
|
2014-11-29 12:58:34 +00:00
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
2014-12-01 14:54:33 +00:00
|
|
|
{
|
2016-04-06 18:15:49 +00:00
|
|
|
corners[ii] += padShapePos;
|
2015-07-27 19:45:57 +00:00
|
|
|
outline.Append( corners[ii].x, corners[ii].y );
|
2014-12-01 14:54:33 +00:00
|
|
|
}
|
2014-11-29 12:58:34 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
int rounding_radius = int( aClearanceValue * aCorrectionFactor );
|
|
|
|
outline.Inflate( rounding_radius, aCircleToSegmentsCount );
|
|
|
|
|
|
|
|
aCornerBuffer.Append( outline );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-08-29 07:13:07 +00:00
|
|
|
case PAD_SHAPE_CHAMFERED_RECT:
|
2016-04-06 18:15:49 +00:00
|
|
|
case PAD_SHAPE_ROUNDRECT:
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET outline;
|
|
|
|
int clearance = int( aClearanceValue * aCorrectionFactor );
|
2018-08-29 07:13:07 +00:00
|
|
|
int rounding_radius = GetRoundRectCornerRadius() + clearance;
|
2016-04-06 18:15:49 +00:00
|
|
|
wxSize shapesize( m_Size );
|
|
|
|
shapesize.x += clearance*2;
|
|
|
|
shapesize.y += clearance*2;
|
2018-08-29 07:13:07 +00:00
|
|
|
bool doChamfer = GetShape() == PAD_SHAPE_CHAMFERED_RECT;
|
2015-07-14 20:23:13 +00:00
|
|
|
|
2018-08-29 07:13:07 +00:00
|
|
|
TransformRoundChamferedRectToPolygon( outline, padShapePos, shapesize, angle,
|
|
|
|
rounding_radius,
|
|
|
|
doChamfer ? GetChamferRectRatio() : 0.0,
|
|
|
|
doChamfer ? GetChamferPositions() : 0,
|
|
|
|
aCircleToSegmentsCount );
|
2015-07-27 19:45:57 +00:00
|
|
|
|
|
|
|
aCornerBuffer.Append( outline );
|
2014-11-29 12:58:34 +00:00
|
|
|
}
|
2009-11-14 19:47:52 +00:00
|
|
|
break;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
case PAD_SHAPE_CUSTOM:
|
|
|
|
{
|
|
|
|
int clearance = KiROUND( aClearanceValue * aCorrectionFactor );
|
|
|
|
|
|
|
|
SHAPE_POLY_SET outline; // Will contain the corners in board coordinates
|
|
|
|
outline.Append( m_customShapeAsPolygon );
|
2017-09-20 08:28:52 +00:00
|
|
|
CustomShapeAsPolygonToBoardPosition( &outline, GetPosition(), GetOrientation() );
|
2017-01-13 17:51:22 +00:00
|
|
|
outline.Inflate( clearance, aCircleToSegmentsCount );
|
|
|
|
aCornerBuffer.Append( outline );
|
|
|
|
}
|
|
|
|
break;
|
2009-11-14 19:47:52 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
/*
|
|
|
|
* Function BuildPadShapePolygon
|
|
|
|
* Build the Corner list of the polygonal shape,
|
|
|
|
* depending on shape, extra size (clearance ...) pad and orientation
|
|
|
|
* Note: for Round and oval pads this function is equivalent to
|
|
|
|
* TransformShapeWithClearanceToPolygon, but not for other shapes
|
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
void D_PAD::BuildPadShapePolygon( SHAPE_POLY_SET& aCornerBuffer,
|
2013-05-01 19:01:14 +00:00
|
|
|
wxSize aInflateValue, int aSegmentsPerCircle,
|
|
|
|
double aCorrectionFactor ) const
|
|
|
|
{
|
|
|
|
wxPoint corners[4];
|
2016-04-06 18:15:49 +00:00
|
|
|
wxPoint padShapePos = ShapePos(); /* Note: for pad having a shape offset,
|
|
|
|
* the pad position is NOT the shape position */
|
2014-01-26 14:20:58 +00:00
|
|
|
switch( GetShape() )
|
2013-05-01 19:01:14 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_CIRCLE:
|
|
|
|
case PAD_SHAPE_OVAL:
|
2016-04-06 18:15:49 +00:00
|
|
|
case PAD_SHAPE_ROUNDRECT:
|
2018-08-29 07:13:07 +00:00
|
|
|
case PAD_SHAPE_CHAMFERED_RECT:
|
2018-04-29 17:51:18 +00:00
|
|
|
{
|
|
|
|
// We are using TransformShapeWithClearanceToPolygon to build the shape.
|
|
|
|
// Currently, this method uses only the same inflate value for X and Y dirs.
|
|
|
|
// so because here this is not the case, we use a inflated dummy pad to build
|
|
|
|
// the polygonal shape
|
|
|
|
// TODO: remove this dummy pad when TransformShapeWithClearanceToPolygon will use
|
|
|
|
// a wxSize to inflate the pad size
|
|
|
|
D_PAD dummy( *this );
|
|
|
|
dummy.SetSize( GetSize() + aInflateValue + aInflateValue );
|
|
|
|
dummy.TransformShapeWithClearanceToPolygon( aCornerBuffer, 0,
|
|
|
|
aSegmentsPerCircle, aCorrectionFactor );
|
|
|
|
}
|
2013-05-01 19:01:14 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_TRAPEZOID:
|
|
|
|
case PAD_SHAPE_RECT:
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.NewOutline();
|
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
BuildPadPolygon( corners, aInflateValue, m_Orient );
|
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
|
|
|
{
|
2016-04-06 18:15:49 +00:00
|
|
|
corners[ii] += padShapePos; // Shift origin to position
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.Append( corners[ii].x, corners[ii].y );
|
2013-05-01 19:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2018-07-30 10:52:03 +00:00
|
|
|
|
|
|
|
case PAD_SHAPE_CUSTOM:
|
|
|
|
// for a custom shape, that is in fact a polygon (with holes), we can use only a inflate value.
|
|
|
|
// so use ( aInflateValue.x + aInflateValue.y ) / 2 as polygon inflate value.
|
|
|
|
// (different values for aInflateValue.x and aInflateValue.y has no sense for a custom pad)
|
|
|
|
TransformShapeWithClearanceToPolygon( aCornerBuffer,
|
|
|
|
( aInflateValue.x + aInflateValue.y ) / 2,
|
|
|
|
aSegmentsPerCircle, aCorrectionFactor );
|
|
|
|
break;
|
2013-05-01 19:01:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function BuildPadDrillShapePolygon
|
|
|
|
* Build the Corner list of the polygonal drill shape,
|
|
|
|
* depending on shape pad hole and orientation
|
|
|
|
* return false if the pad has no hole, true otherwise
|
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
bool D_PAD::BuildPadDrillShapePolygon( SHAPE_POLY_SET& aCornerBuffer,
|
2013-05-01 19:01:14 +00:00
|
|
|
int aInflateValue, int aSegmentsPerCircle ) const
|
|
|
|
{
|
|
|
|
wxSize drillsize = GetDrillSize();
|
|
|
|
|
2014-05-17 19:29:15 +00:00
|
|
|
if( !drillsize.x || !drillsize.y )
|
2013-05-01 19:01:14 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if( drillsize.x == drillsize.y ) // usual round hole
|
|
|
|
{
|
|
|
|
TransformCircleToPolygon( aCornerBuffer, GetPosition(),
|
2014-05-17 19:29:15 +00:00
|
|
|
(drillsize.x / 2) + aInflateValue, aSegmentsPerCircle );
|
2013-05-01 19:01:14 +00:00
|
|
|
}
|
|
|
|
else // Oblong hole
|
|
|
|
{
|
2014-05-17 19:29:15 +00:00
|
|
|
wxPoint start, end;
|
2013-05-01 19:01:14 +00:00
|
|
|
int width;
|
|
|
|
|
2014-05-17 19:29:15 +00:00
|
|
|
GetOblongDrillGeometry( start, end, width );
|
2013-05-01 19:01:14 +00:00
|
|
|
|
2014-05-17 19:29:15 +00:00
|
|
|
width += aInflateValue * 2;
|
2013-05-01 19:01:14 +00:00
|
|
|
|
2014-05-17 19:29:15 +00:00
|
|
|
TransformRoundedEndsSegmentToPolygon( aCornerBuffer,
|
|
|
|
GetPosition() + start, GetPosition() + end, aSegmentsPerCircle, width );
|
2013-05-01 19:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function CreateThermalReliefPadPolygon
|
2009-11-16 08:13:40 +00:00
|
|
|
* Add holes around a pad to create a thermal relief
|
|
|
|
* copper thickness is min (dx/2, aCopperWitdh) or min (dy/2, aCopperWitdh)
|
|
|
|
* @param aCornerBuffer = a buffer to store the polygon
|
|
|
|
* @param aPad = the current pad used to create the thermal shape
|
|
|
|
* @param aThermalGap = gap in thermal shape
|
2010-12-29 17:47:32 +00:00
|
|
|
* @param aCopperThickness = stubs thickness in thermal shape
|
2009-11-16 08:13:40 +00:00
|
|
|
* @param aMinThicknessValue = min copper thickness allowed
|
|
|
|
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
|
|
|
|
* @param aCorrectionFactor = the correction to apply to circles radius to keep
|
|
|
|
* @param aThermalRot = for rond pads the rotation of thermal stubs (450 usually for 45 deg.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* thermal reliefs are created as 4 polygons.
|
|
|
|
* each corner of a polygon if calculated for a pad at position 0, 0, orient 0,
|
|
|
|
* and then moved and rotated acroding to the pad position and orientation
|
|
|
|
*/
|
|
|
|
|
2012-01-10 20:12:46 +00:00
|
|
|
/*
|
2009-11-16 08:13:40 +00:00
|
|
|
* Note 1: polygons are drawm using outlines witk a thickness = aMinThicknessValue
|
2012-01-10 20:12:46 +00:00
|
|
|
* so shapes must take in account this outline thickness
|
2009-11-16 08:13:40 +00:00
|
|
|
*
|
|
|
|
* Note 2:
|
|
|
|
* Trapezoidal pads are not considered here because they are very special case
|
2011-09-07 19:41:04 +00:00
|
|
|
* and are used in microwave applications and they *DO NOT* have a thermal relief that
|
|
|
|
* change the shape by creating stubs and destroy their properties.
|
2009-11-16 08:13:40 +00:00
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
void CreateThermalReliefPadPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
2017-12-04 18:06:47 +00:00
|
|
|
const D_PAD& aPad,
|
2013-05-03 17:51:10 +00:00
|
|
|
int aThermalGap,
|
|
|
|
int aCopperThickness,
|
|
|
|
int aMinThicknessValue,
|
|
|
|
int aCircleToSegmentsCount,
|
|
|
|
double aCorrectionFactor,
|
2013-05-05 07:17:48 +00:00
|
|
|
double aThermalRot )
|
2009-11-16 08:13:40 +00:00
|
|
|
{
|
|
|
|
wxPoint corner, corner_end;
|
2016-04-06 18:15:49 +00:00
|
|
|
wxPoint padShapePos = aPad.ShapePos(); // Note: for pad having a shape offset,
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
// the pad position is NOT the shape position
|
2009-11-16 08:13:40 +00:00
|
|
|
wxSize copper_thickness;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2013-05-05 07:17:48 +00:00
|
|
|
double delta = 3600.0 / aCircleToSegmentsCount; // rot angle in 0.1 degree
|
2009-11-16 08:13:40 +00:00
|
|
|
|
|
|
|
/* Keep in account the polygon outline thickness
|
|
|
|
* aThermalGap must be increased by aMinThicknessValue/2 because drawing external outline
|
|
|
|
* with a thickness of aMinThicknessValue will reduce gap by aMinThicknessValue/2
|
|
|
|
*/
|
|
|
|
aThermalGap += aMinThicknessValue / 2;
|
|
|
|
|
|
|
|
/* Keep in account the polygon outline thickness
|
|
|
|
* copper_thickness must be decreased by aMinThicknessValue because drawing outlines
|
|
|
|
* with a thickness of aMinThicknessValue will increase real thickness by aMinThicknessValue
|
|
|
|
*/
|
2016-05-29 15:02:34 +00:00
|
|
|
int dx = aPad.GetSize().x / 2;
|
|
|
|
int dy = aPad.GetSize().y / 2;
|
|
|
|
|
2019-03-06 15:34:21 +00:00
|
|
|
copper_thickness.x = std::min( aPad.GetSize().x, aCopperThickness ) - aMinThicknessValue;
|
|
|
|
copper_thickness.y = std::min( aPad.GetSize().y, aCopperThickness ) - aMinThicknessValue;
|
|
|
|
|
|
|
|
if( copper_thickness.x < 0 )
|
|
|
|
copper_thickness.x = 0;
|
|
|
|
|
|
|
|
if( copper_thickness.y < 0 )
|
|
|
|
copper_thickness.y = 0;
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
switch( aPad.GetShape() )
|
2009-11-16 08:13:40 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_CIRCLE: // Add 4 similar holes
|
2012-02-19 04:02:19 +00:00
|
|
|
{
|
|
|
|
/* we create 4 copper holes and put them in position 1, 2, 3 and 4
|
|
|
|
* here is the area of the rectangular pad + its thermal gap
|
|
|
|
* the 4 copper holes remove the copper in order to create the thermal gap
|
|
|
|
* 4 ------ 1
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* 3 ------ 2
|
|
|
|
* holes 2, 3, 4 are the same as hole 1, rotated 90, 180, 270 deg
|
|
|
|
*/
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Build the hole pattern, for the hole in the X >0, Y > 0 plane:
|
|
|
|
// The pattern roughtly is a 90 deg arc pie
|
|
|
|
std::vector <wxPoint> corners_buffer;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Radius of outer arcs of the shape corrected for arc approximation by lines
|
2013-05-04 11:57:09 +00:00
|
|
|
int outer_radius = KiROUND( (dx + aThermalGap) * aCorrectionFactor );
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Crosspoint of thermal spoke sides, the first point of polygon buffer
|
|
|
|
corners_buffer.push_back( wxPoint( copper_thickness.x / 2, copper_thickness.y / 2 ) );
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Add an intermediate point on spoke sides, to allow a > 90 deg angle between side
|
|
|
|
// and first seg of arc approx
|
|
|
|
corner.x = copper_thickness.x / 2;
|
|
|
|
int y = outer_radius - (aThermalGap / 4);
|
2013-05-04 11:57:09 +00:00
|
|
|
corner.y = KiROUND( sqrt( ( (double) y * y - (double) corner.x * corner.x ) ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
if( aThermalRot != 0 )
|
|
|
|
corners_buffer.push_back( corner );
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// calculate the starting point of the outter arc
|
|
|
|
corner.x = copper_thickness.x / 2;
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2013-05-04 11:57:09 +00:00
|
|
|
corner.y = KiROUND( sqrt( ( (double) outer_radius * outer_radius ) -
|
|
|
|
( (double) corner.x * corner.x ) ) );
|
2013-05-01 17:32:36 +00:00
|
|
|
RotatePoint( &corner, 90 ); // 9 degrees is the spoke fillet size
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// calculate the ending point of the outter arc
|
|
|
|
corner_end.x = corner.y;
|
|
|
|
corner_end.y = corner.x;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// calculate intermediate points (y coordinate from corner.y to corner_end.y
|
|
|
|
while( (corner.y > corner_end.y) && (corner.x < corner_end.x) )
|
2009-11-16 08:13:40 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
corners_buffer.push_back( corner );
|
|
|
|
RotatePoint( &corner, delta );
|
2009-11-16 08:13:40 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
corners_buffer.push_back( corner_end );
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
/* add an intermediate point, to avoid angles < 90 deg between last arc approx line
|
|
|
|
* and radius line
|
|
|
|
*/
|
|
|
|
corner.x = corners_buffer[1].y;
|
|
|
|
corner.y = corners_buffer[1].x;
|
|
|
|
corners_buffer.push_back( corner );
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Now, add the 4 holes ( each is the pattern, rotated by 0, 90, 180 and 270 deg
|
|
|
|
// aThermalRot = 450 (45.0 degrees orientation) work fine.
|
2013-05-05 07:17:48 +00:00
|
|
|
double angle_pad = aPad.GetOrientation(); // Pad orientation
|
|
|
|
double th_angle = aThermalRot;
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
for( unsigned ihole = 0; ihole < 4; ihole++ )
|
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.NewOutline();
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
for( unsigned ii = 0; ii < corners_buffer.size(); ii++ )
|
|
|
|
{
|
|
|
|
corner = corners_buffer[ii];
|
|
|
|
RotatePoint( &corner, th_angle + angle_pad ); // Rotate by segment angle and pad orientation
|
2016-04-06 18:15:49 +00:00
|
|
|
corner += padShapePos;
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.Append( corner.x, corner.y );
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
th_angle += 900; // Note: th_angle in in 0.1 deg.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_OVAL:
|
2009-11-16 08:13:40 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
// Oval pad support along the lines of round and rectangular pads
|
|
|
|
std::vector <wxPoint> corners_buffer; // Polygon buffer as vector
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2016-05-29 15:02:34 +00:00
|
|
|
dx = (aPad.GetSize().x / 2) + aThermalGap; // Cutout radius x
|
|
|
|
dy = (aPad.GetSize().y / 2) + aThermalGap; // Cutout radius y
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
wxPoint shape_offset;
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// We want to calculate an oval shape with dx > dy.
|
|
|
|
// if this is not the case, exchange dx and dy, and rotate the shape 90 deg.
|
|
|
|
int supp_angle = 0;
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( dx < dy )
|
|
|
|
{
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( dx, dy );
|
2012-02-19 04:02:19 +00:00
|
|
|
supp_angle = 900;
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( copper_thickness.x, copper_thickness.y );
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
int deltasize = dx - dy; // = distance between shape position and the 2 demi-circle ends centre
|
|
|
|
// here we have dx > dy
|
|
|
|
// Radius of outer arcs of the shape:
|
|
|
|
int outer_radius = dy; // The radius of the outer arc is radius end + aThermalGap
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Some coordinate fiddling, depending on the shape offset direction
|
|
|
|
shape_offset = wxPoint( deltasize, 0 );
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Crosspoint of thermal spoke sides, the first point of polygon buffer
|
2012-02-23 14:59:57 +00:00
|
|
|
corner.x = copper_thickness.x / 2;
|
|
|
|
corner.y = copper_thickness.y / 2;
|
|
|
|
corners_buffer.push_back( corner );
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Arc start point calculation, the intersecting point of cutout arc and thermal spoke edge
|
2012-02-23 14:59:57 +00:00
|
|
|
// If copper thickness is more than shape offset, we need to calculate arc intercept point.
|
|
|
|
if( copper_thickness.x > deltasize )
|
2012-02-19 04:02:19 +00:00
|
|
|
{
|
|
|
|
corner.x = copper_thickness.x / 2;
|
2013-05-04 11:57:09 +00:00
|
|
|
corner.y = KiROUND( sqrt( ( (double) outer_radius * outer_radius ) -
|
|
|
|
( (double) ( corner.x - delta ) * ( corner.x - deltasize ) ) ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
corner.x -= deltasize;
|
|
|
|
|
|
|
|
/* creates an intermediate point, to have a > 90 deg angle
|
|
|
|
* between the side and the first segment of arc approximation
|
|
|
|
*/
|
|
|
|
wxPoint intpoint = corner;
|
|
|
|
intpoint.y -= aThermalGap / 4;
|
|
|
|
corners_buffer.push_back( intpoint + shape_offset );
|
2013-05-02 18:06:58 +00:00
|
|
|
RotatePoint( &corner, 90 ); // 9 degrees of thermal fillet
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
corner.x = copper_thickness.x / 2;
|
|
|
|
corner.y = outer_radius;
|
|
|
|
corners_buffer.push_back( corner );
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Add an intermediate point on spoke sides, to allow a > 90 deg angle between side
|
|
|
|
// and first seg of arc approx
|
|
|
|
wxPoint last_corner;
|
|
|
|
last_corner.y = copper_thickness.y / 2;
|
|
|
|
int px = outer_radius - (aThermalGap / 4);
|
|
|
|
last_corner.x =
|
2013-05-04 11:57:09 +00:00
|
|
|
KiROUND( sqrt( ( ( (double) px * px ) - (double) last_corner.y * last_corner.y ) ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
// Arc stop point calculation, the intersecting point of cutout arc and thermal spoke edge
|
|
|
|
corner_end.y = copper_thickness.y / 2;
|
|
|
|
corner_end.x =
|
2013-05-04 11:57:09 +00:00
|
|
|
KiROUND( sqrt( ( (double) outer_radius *
|
|
|
|
outer_radius ) - ( (double) corner_end.y * corner_end.y ) ) );
|
2013-05-02 18:06:58 +00:00
|
|
|
RotatePoint( &corner_end, -90 ); // 9 degrees of thermal fillet
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
// calculate intermediate arc points till limit is reached
|
|
|
|
while( (corner.y > corner_end.y) && (corner.x < corner_end.x) )
|
2009-11-16 08:13:40 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
corners_buffer.push_back( corner + shape_offset );
|
|
|
|
RotatePoint( &corner, delta );
|
2009-11-16 08:13:40 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
//corners_buffer.push_back(corner + shape_offset); // TODO: about one mil geometry error forms somewhere.
|
|
|
|
corners_buffer.push_back( corner_end + shape_offset );
|
|
|
|
corners_buffer.push_back( last_corner + shape_offset ); // Enabling the line above shows intersection point.
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
/* Create 2 holes, rotated by pad rotation.
|
|
|
|
*/
|
2013-05-05 07:17:48 +00:00
|
|
|
double angle = aPad.GetOrientation() + supp_angle;
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
for( int irect = 0; irect < 2; irect++ )
|
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.NewOutline();
|
2012-02-19 04:02:19 +00:00
|
|
|
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
|
|
|
|
{
|
|
|
|
wxPoint cpos = corners_buffer[ic];
|
|
|
|
RotatePoint( &cpos, angle );
|
2016-04-06 18:15:49 +00:00
|
|
|
cpos += padShapePos;
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.Append( cpos.x, cpos.y );
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2013-05-02 18:06:58 +00:00
|
|
|
angle = AddAngles( angle, 1800 ); // this is calculate hole 3
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create holes, that are the mirrored from the previous holes
|
2009-11-16 08:13:40 +00:00
|
|
|
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
wxPoint swap = corners_buffer[ic];
|
|
|
|
swap.x = -swap.x;
|
|
|
|
corners_buffer[ic] = swap;
|
2009-11-16 08:13:40 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Now add corner 4 and 2 (2 is the corner 4 rotated by 180 deg
|
|
|
|
angle = aPad.GetOrientation() + supp_angle;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
for( int irect = 0; irect < 2; irect++ )
|
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.NewOutline();
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
|
|
|
|
{
|
|
|
|
wxPoint cpos = corners_buffer[ic];
|
|
|
|
RotatePoint( &cpos, angle );
|
2016-04-06 18:15:49 +00:00
|
|
|
cpos += padShapePos;
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.Append( cpos.x, cpos.y );
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2013-05-02 18:06:58 +00:00
|
|
|
angle = AddAngles( angle, 1800 );
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
2009-11-16 08:13:40 +00:00
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
break;
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2018-08-29 07:13:07 +00:00
|
|
|
case PAD_SHAPE_CHAMFERED_RECT:
|
|
|
|
case PAD_SHAPE_ROUNDRECT: // thermal shape is the same for rectangular shapes.
|
2016-04-06 18:15:49 +00:00
|
|
|
case PAD_SHAPE_RECT:
|
2009-11-16 08:13:40 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
/* we create 4 copper holes and put them in position 1, 2, 3 and 4
|
|
|
|
* here is the area of the rectangular pad + its thermal gap
|
|
|
|
* the 4 copper holes remove the copper in order to create the thermal gap
|
2019-03-06 15:34:21 +00:00
|
|
|
* 1 ------ 4
|
2012-02-19 04:02:19 +00:00
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | |
|
2019-03-06 15:34:21 +00:00
|
|
|
* 2 ------ 3
|
2012-02-19 04:02:19 +00:00
|
|
|
* hole 3 is the same as hole 1, rotated 180 deg
|
|
|
|
* hole 4 is the same as hole 2, rotated 180 deg and is the same as hole 1, mirrored
|
|
|
|
*/
|
|
|
|
|
|
|
|
// First, create a rectangular hole for position 1 :
|
|
|
|
// 2 ------- 3
|
|
|
|
// | |
|
|
|
|
// | |
|
|
|
|
// | |
|
|
|
|
// 1 -------4
|
|
|
|
|
|
|
|
// Modified rectangles with one corner rounded. TODO: merging with oval thermals
|
|
|
|
// and possibly round too.
|
|
|
|
|
|
|
|
std::vector <wxPoint> corners_buffer; // Polygon buffer as vector
|
|
|
|
|
2016-05-29 15:02:34 +00:00
|
|
|
dx = (aPad.GetSize().x / 2) + aThermalGap; // Cutout radius x
|
|
|
|
dy = (aPad.GetSize().y / 2) + aThermalGap; // Cutout radius y
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2019-03-06 15:34:21 +00:00
|
|
|
// calculation is optimized for pad shape with dy >= dx (vertical rectangle).
|
|
|
|
// if it is not the case, just rotate this shape 90 degrees:
|
|
|
|
double angle = aPad.GetOrientation();
|
|
|
|
wxPoint corner_origin_pos( -aPad.GetSize().x / 2, -aPad.GetSize().y / 2 );
|
|
|
|
|
|
|
|
if( dy < dx )
|
|
|
|
{
|
|
|
|
std::swap( dx, dy );
|
|
|
|
std::swap( copper_thickness.x, copper_thickness.y );
|
|
|
|
std::swap( corner_origin_pos.x, corner_origin_pos.y );
|
|
|
|
angle += 900.0;
|
|
|
|
}
|
|
|
|
// Now calculate the hole pattern in position 1 ( top left pad corner )
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// The first point of polygon buffer is left lower corner, second the crosspoint of
|
|
|
|
// thermal spoke sides, the third is upper right corner and the rest are rounding
|
2019-03-06 15:34:21 +00:00
|
|
|
// vertices going anticlockwise. Note the inverted Y-axis in corners_buffer y coordinates.
|
|
|
|
wxPoint arc_end_point( -dx, -(aThermalGap / 4 + copper_thickness.y / 2) );
|
|
|
|
corners_buffer.push_back( arc_end_point ); // Adds small miters to zone
|
2012-02-19 04:02:19 +00:00
|
|
|
corners_buffer.push_back( wxPoint( -(dx - aThermalGap / 4), -copper_thickness.y / 2 ) ); // fill and spoke corner
|
|
|
|
corners_buffer.push_back( wxPoint( -copper_thickness.x / 2, -copper_thickness.y / 2 ) );
|
|
|
|
corners_buffer.push_back( wxPoint( -copper_thickness.x / 2, -(dy - aThermalGap / 4) ) );
|
2019-03-06 15:34:21 +00:00
|
|
|
// The first point to build the rounded corner:
|
|
|
|
wxPoint arc_start_point( -(aThermalGap / 4 + copper_thickness.x / 2) , -dy );
|
|
|
|
corners_buffer.push_back( arc_start_point );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2013-05-04 11:57:09 +00:00
|
|
|
int rounding_radius = KiROUND( aThermalGap * aCorrectionFactor ); // Corner rounding radius
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2019-03-06 15:34:21 +00:00
|
|
|
// Calculate arc angle parameters.
|
|
|
|
// the start angle id near 900 decidegrees, the final angle is near 1800.0 decidegrees.
|
|
|
|
double arc_increment = 3600.0 / aCircleToSegmentsCount;
|
|
|
|
|
|
|
|
// the arc_angle_start is 900.0 or slighly more, depending on the actual arc starting point
|
|
|
|
double arc_angle_start = atan2( -arc_start_point.y -corner_origin_pos.y, arc_start_point.x - corner_origin_pos.x ) * 1800/M_PI;
|
|
|
|
if( arc_angle_start < 900.0 )
|
|
|
|
arc_angle_start = 900.0;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2019-03-06 15:34:21 +00:00
|
|
|
bool first_point = true;
|
|
|
|
for( double curr_angle = arc_angle_start; ; curr_angle += arc_increment )
|
|
|
|
{
|
|
|
|
wxPoint corner_position = wxPoint( rounding_radius, 0 );
|
|
|
|
RotatePoint( &corner_position, curr_angle ); // Rounding vector rotation
|
|
|
|
corner_position += corner_origin_pos; // Rounding vector + Pad corner offset
|
|
|
|
|
|
|
|
// The arc angle is <= 90 degrees, therefore the arc is finished if the x coordinate
|
|
|
|
// decrease or the y coordinate is smaller than the y end point
|
|
|
|
if( !first_point &&
|
|
|
|
( corner_position.x >= corners_buffer.back().x || corner_position.y > arc_end_point.y ) )
|
|
|
|
break;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2019-03-06 15:34:21 +00:00
|
|
|
first_point = false;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2019-03-06 15:34:21 +00:00
|
|
|
// Note: for hole in position 1, arc x coordinate is always < x starting point
|
|
|
|
// and arc y coordinate is always <= y ending point
|
|
|
|
if( corner_position != corners_buffer.back() // avoid duplicate corners.
|
|
|
|
&& corner_position.x <= arc_start_point.x ) // skip current point at the right of the starting point
|
|
|
|
corners_buffer.push_back( corner_position );
|
2009-11-16 08:13:40 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
for( int irect = 0; irect < 2; irect++ )
|
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.NewOutline();
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
|
|
|
|
{
|
|
|
|
wxPoint cpos = corners_buffer[ic];
|
|
|
|
RotatePoint( &cpos, angle ); // Rotate according to module orientation
|
2016-04-06 18:15:49 +00:00
|
|
|
cpos += padShapePos; // Shift origin to position
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.Append( cpos.x, cpos.y );
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-05-02 18:06:58 +00:00
|
|
|
angle = AddAngles( angle, 1800 ); // this is calculate hole 3
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Create holes, that are the mirrored from the previous holes
|
2009-11-16 08:13:40 +00:00
|
|
|
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
wxPoint swap = corners_buffer[ic];
|
|
|
|
swap.x = -swap.x;
|
|
|
|
corners_buffer[ic] = swap;
|
2009-11-16 08:13:40 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Now add corner 4 and 2 (2 is the corner 4 rotated by 180 deg
|
|
|
|
for( int irect = 0; irect < 2; irect++ )
|
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.NewOutline();
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
|
|
|
|
{
|
|
|
|
wxPoint cpos = corners_buffer[ic];
|
|
|
|
RotatePoint( &cpos, angle );
|
2016-04-06 18:15:49 +00:00
|
|
|
cpos += padShapePos;
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.Append( cpos.x, cpos.y );
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-05-02 18:06:58 +00:00
|
|
|
angle = AddAngles( angle, 1800 );
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
2014-11-29 12:58:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_TRAPEZOID:
|
2014-11-29 12:58:34 +00:00
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET antipad; // The full antipad area
|
|
|
|
|
2014-11-29 12:58:34 +00:00
|
|
|
// We need a length to build the stubs of the thermal reliefs
|
|
|
|
// the value is not very important. The pad bounding box gives a reasonable value
|
|
|
|
EDA_RECT bbox = aPad.GetBoundingBox();
|
|
|
|
int stub_len = std::max( bbox.GetWidth(), bbox.GetHeight() );
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
aPad.TransformShapeWithClearanceToPolygon( antipad, aThermalGap,
|
2014-11-29 12:58:34 +00:00
|
|
|
aCircleToSegmentsCount, aCorrectionFactor );
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET stub; // A basic stub ( a rectangle)
|
|
|
|
SHAPE_POLY_SET stubs; // the full stubs shape
|
2014-11-29 12:58:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
// We now substract the stubs (connections to the copper zone)
|
2015-07-27 19:45:57 +00:00
|
|
|
//ClipperLib::Clipper clip_engine;
|
2014-11-29 12:58:34 +00:00
|
|
|
// Prepare a clipping transform
|
2015-07-27 19:45:57 +00:00
|
|
|
//clip_engine.AddPath( antipad, ClipperLib::ptSubject, true );
|
2014-11-29 12:58:34 +00:00
|
|
|
|
|
|
|
// Create stubs and add them to clipper engine
|
|
|
|
wxPoint stubBuffer[4];
|
|
|
|
stubBuffer[0].x = stub_len;
|
|
|
|
stubBuffer[0].y = copper_thickness.y/2;
|
|
|
|
stubBuffer[1] = stubBuffer[0];
|
|
|
|
stubBuffer[1].y = -copper_thickness.y/2;
|
|
|
|
stubBuffer[2] = stubBuffer[1];
|
|
|
|
stubBuffer[2].x = -stub_len;
|
|
|
|
stubBuffer[3] = stubBuffer[2];
|
|
|
|
stubBuffer[3].y = copper_thickness.y/2;
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
stub.NewOutline();
|
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
for( unsigned ii = 0; ii < arrayDim( stubBuffer ); ii++ )
|
2014-11-29 12:58:34 +00:00
|
|
|
{
|
|
|
|
wxPoint cpos = stubBuffer[ii];
|
|
|
|
RotatePoint( &cpos, aPad.GetOrientation() );
|
2016-04-06 18:15:49 +00:00
|
|
|
cpos += padShapePos;
|
2015-07-27 19:45:57 +00:00
|
|
|
stub.Append( cpos.x, cpos.y );
|
2014-11-29 12:58:34 +00:00
|
|
|
}
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
stubs.Append( stub );
|
2014-11-29 12:58:34 +00:00
|
|
|
|
|
|
|
stubBuffer[0].y = stub_len;
|
|
|
|
stubBuffer[0].x = copper_thickness.x/2;
|
|
|
|
stubBuffer[1] = stubBuffer[0];
|
|
|
|
stubBuffer[1].x = -copper_thickness.x/2;
|
|
|
|
stubBuffer[2] = stubBuffer[1];
|
|
|
|
stubBuffer[2].y = -stub_len;
|
|
|
|
stubBuffer[3] = stubBuffer[2];
|
|
|
|
stubBuffer[3].x = copper_thickness.x/2;
|
2015-07-27 19:45:57 +00:00
|
|
|
|
|
|
|
stub.RemoveAllContours();
|
|
|
|
stub.NewOutline();
|
2014-11-29 12:58:34 +00:00
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
for( unsigned ii = 0; ii < arrayDim( stubBuffer ); ii++ )
|
2014-11-29 12:58:34 +00:00
|
|
|
{
|
|
|
|
wxPoint cpos = stubBuffer[ii];
|
|
|
|
RotatePoint( &cpos, aPad.GetOrientation() );
|
2016-04-06 18:15:49 +00:00
|
|
|
cpos += padShapePos;
|
2015-07-27 19:45:57 +00:00
|
|
|
stub.Append( cpos.x, cpos.y );
|
2014-11-29 12:58:34 +00:00
|
|
|
}
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
stubs.Append( stub );
|
2015-12-15 20:21:25 +00:00
|
|
|
stubs.Simplify( SHAPE_POLY_SET::PM_FAST );
|
2014-11-29 12:58:34 +00:00
|
|
|
|
2015-12-15 20:21:25 +00:00
|
|
|
antipad.BooleanSubtract( stubs, SHAPE_POLY_SET::PM_FAST );
|
2015-07-27 19:45:57 +00:00
|
|
|
aCornerBuffer.Append( antipad );
|
2014-11-29 12:58:34 +00:00
|
|
|
|
2009-11-16 08:13:40 +00:00
|
|
|
break;
|
2014-11-30 17:07:02 +00:00
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
2009-11-16 08:13:40 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-29 18:51:01 +00:00
|
|
|
|
|
|
|
void ZONE_CONTAINER::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
|
|
|
int aClearanceValue,
|
|
|
|
int aCircleToSegmentsCount,
|
2018-11-14 23:34:32 +00:00
|
|
|
double aCorrectionFactor,
|
|
|
|
bool ignoreLineWidth ) const
|
2017-11-29 18:51:01 +00:00
|
|
|
{
|
2018-11-14 23:34:32 +00:00
|
|
|
wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for zones." );
|
|
|
|
|
2017-11-29 18:51:01 +00:00
|
|
|
aCornerBuffer = m_FilledPolysList;
|
|
|
|
aCornerBuffer.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
|
|
|
}
|