2012-06-08 09:56:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-04-06 18:15:49 +00:00
|
|
|
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-06-08 09:56:42 +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
|
|
|
|
*/
|
2010-07-26 17:06:36 +00:00
|
|
|
|
|
|
|
/* Functions to convert some board items to polygons
|
|
|
|
* (pads, tracks ..)
|
|
|
|
* This is used to calculate filled areas in copper zones.
|
|
|
|
* Filled areas are areas remainder of the full zone area after removed all polygons
|
|
|
|
* calculated from these items shapes and the clearance area
|
|
|
|
*
|
|
|
|
* Important note:
|
2011-09-07 19:41:04 +00:00
|
|
|
* Because filled areas must have a minimum thickness to match with Design rule, they are
|
|
|
|
* draw in 2 step:
|
2010-07-26 17:06:36 +00:00
|
|
|
* 1 - filled polygons are drawn
|
2011-09-07 19:41:04 +00:00
|
|
|
* 2 - polygon outlines are drawn with a "minimum thickness width" ( or with a minimum
|
|
|
|
* thickness pen )
|
2010-07-26 17:06:36 +00:00
|
|
|
* So outlines of filled polygons are calculated with the constraint they match with clearance,
|
|
|
|
* taking in account outlines have thickness
|
|
|
|
* This ensures:
|
|
|
|
* - areas meet the minimum thickness requirement.
|
|
|
|
* - shapes are smoothed.
|
|
|
|
*/
|
|
|
|
|
2015-12-15 20:21:25 +00:00
|
|
|
// Polygon calculations can use fast mode or force strickly simple polygons after calculations
|
|
|
|
// Forcing strickly simple polygons is time consuming, and we have not see issues in fast mode
|
|
|
|
// so we use fast mode
|
|
|
|
#define POLY_CALC_MODE SHAPE_POLY_SET::PM_FAST
|
|
|
|
|
2012-09-21 17:02:54 +00:00
|
|
|
#include <cmath>
|
2015-06-12 15:13:18 +00:00
|
|
|
#include <sstream>
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_edge_mod.h>
|
|
|
|
#include <class_drawsegment.h>
|
|
|
|
#include <class_pcb_text.h>
|
|
|
|
#include <class_zone.h>
|
2015-06-12 15:13:18 +00:00
|
|
|
#include <project.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <zones.h>
|
2013-05-01 19:01:14 +00:00
|
|
|
#include <convert_basic_shapes_to_polygon.h>
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2015-06-12 15:13:18 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
|
|
|
#include <geometry/shape_file_io.h>
|
|
|
|
|
|
|
|
#include <boost/foreach.hpp>
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2016-05-10 21:37:51 +00:00
|
|
|
/* DEBUG OPTION:
|
|
|
|
* To emit zone data to a file when filling zones for the debugging purposes,
|
|
|
|
* set this 'true' and build.
|
|
|
|
*/
|
|
|
|
static const bool g_DumpZonesWhenFilling = false;
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
extern void BuildUnconnectedThermalStubsPolygonList( SHAPE_POLY_SET& aCornerBuffer,
|
2010-11-18 13:38:08 +00:00
|
|
|
BOARD* aPcb, ZONE_CONTAINER* aZone,
|
2013-05-01 17:32:36 +00:00
|
|
|
double aArcCorrection,
|
2013-05-05 07:17:48 +00:00
|
|
|
double aRoundPadThermalRotation);
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb,
|
|
|
|
ZONE_CONTAINER* aZone_container );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
extern void CreateThermalReliefPadPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
2010-07-26 17:06:36 +00:00
|
|
|
D_PAD& aPad,
|
|
|
|
int aThermalGap,
|
|
|
|
int aCopperThickness,
|
|
|
|
int aMinThicknessValue,
|
|
|
|
int aCircleToSegmentsCount,
|
|
|
|
double aCorrectionFactor,
|
2013-05-05 07:17:48 +00:00
|
|
|
double aThermalRot );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
// Local Variables:
|
2013-05-05 07:17:48 +00:00
|
|
|
static double s_thermalRot = 450; // angle of stubs in thermal reliefs for round pads
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
void ZONE_CONTAINER::buildFeatureHoleList( BOARD* aPcb, SHAPE_POLY_SET& aFeatures )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2015-06-12 15:13:18 +00:00
|
|
|
int segsPerCircle;
|
|
|
|
double correctionFactor;
|
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
// Set the number of segments in arc approximations
|
|
|
|
if( m_ArcToSegmentsCount == ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF )
|
2015-06-12 15:13:18 +00:00
|
|
|
segsPerCircle = ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF;
|
2010-07-26 17:06:36 +00:00
|
|
|
else
|
2015-06-12 15:13:18 +00:00
|
|
|
segsPerCircle = ARC_APPROX_SEGMENTS_COUNT_LOW_DEF;
|
2010-07-26 17:06:36 +00:00
|
|
|
|
|
|
|
/* calculates the coeff to compensate radius reduction of holes clearance
|
|
|
|
* due to the segment approx.
|
|
|
|
* For a circle the min radius is radius * cos( 2PI / s_CircleToSegmentsCount / 2)
|
|
|
|
* s_Correction is 1 /cos( PI/s_CircleToSegmentsCount )
|
|
|
|
*/
|
2015-06-12 15:13:18 +00:00
|
|
|
correctionFactor = 1.0 / cos( M_PI / (double) segsPerCircle );
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2015-06-12 15:13:18 +00:00
|
|
|
aFeatures.RemoveAllContours();
|
2014-11-30 17:07:02 +00:00
|
|
|
|
2015-05-23 17:12:40 +00:00
|
|
|
int outline_half_thickness = m_ZoneMinThickness / 2;
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2012-08-03 15:43:15 +00:00
|
|
|
int zone_clearance = std::max( m_ZoneClearance, GetClearance() );
|
2015-05-23 17:12:40 +00:00
|
|
|
zone_clearance += outline_half_thickness;
|
2010-07-26 17:06:36 +00:00
|
|
|
|
|
|
|
/* store holes (i.e. tracks and pads areas as polygons outlines)
|
|
|
|
* in a polygon list
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* items ouside the zone bounding box are skipped
|
|
|
|
* the bounding box is the zone bounding box + the biggest clearance found in Netclass list
|
|
|
|
*/
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT item_boundingbox;
|
|
|
|
EDA_RECT zone_boundingbox = GetBoundingBox();
|
2014-05-13 09:22:51 +00:00
|
|
|
int biggest_clearance = aPcb->GetDesignSettings().GetBiggestClearanceValue();
|
2012-08-03 15:43:15 +00:00
|
|
|
biggest_clearance = std::max( biggest_clearance, zone_clearance );
|
2010-11-18 13:38:08 +00:00
|
|
|
zone_boundingbox.Inflate( biggest_clearance );
|
2010-07-26 17:06:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First : Add pads. Note: pads having the same net as zone are left in zone.
|
|
|
|
* Thermal shapes will be created later if necessary
|
|
|
|
*/
|
|
|
|
int item_clearance;
|
|
|
|
|
2010-10-28 13:02:07 +00:00
|
|
|
/* Use a dummy pad to calculate hole clerance when a pad is not on all copper layers
|
|
|
|
* and this pad has a hole
|
|
|
|
* This dummy pad has the size and shape of the hole
|
|
|
|
* Therefore, this dummy pad is a circle or an oval.
|
|
|
|
* A pad must have a parent because some functions expect a non null parent
|
|
|
|
* to find the parent board, and some other data
|
|
|
|
*/
|
|
|
|
MODULE dummymodule( aPcb ); // Creates a dummy parent
|
|
|
|
D_PAD dummypad( &dummymodule );
|
2014-05-29 11:48:14 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
|
|
|
|
{
|
2014-05-29 11:48:14 +00:00
|
|
|
D_PAD* nextpad;
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = module->Pads(); pad != NULL; pad = nextpad )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
nextpad = pad->Next(); // pad pointer can be modified by next code, so
|
|
|
|
// calculate the next pad here
|
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
if( !pad->IsOnLayer( GetLayer() ) )
|
|
|
|
{
|
2010-12-01 07:51:21 +00:00
|
|
|
/* Test for pads that are on top or bottom only and have a hole.
|
2011-09-07 19:41:04 +00:00
|
|
|
* There are curious pads but they can be used for some components that are
|
|
|
|
* inside the board (in fact inside the hole. Some photo diodes and Leds are
|
|
|
|
* like this)
|
2010-07-26 17:06:36 +00:00
|
|
|
*/
|
2012-02-19 04:02:19 +00:00
|
|
|
if( pad->GetDrillSize().x == 0 && pad->GetDrillSize().y == 0 )
|
2010-07-26 17:06:36 +00:00
|
|
|
continue;
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
// Use a dummy pad to calculate a hole shape that have the same dimension as
|
|
|
|
// the pad hole
|
2012-02-19 04:02:19 +00:00
|
|
|
dummypad.SetSize( pad->GetDrillSize() );
|
|
|
|
dummypad.SetOrientation( pad->GetOrientation() );
|
2015-08-23 19:40:33 +00:00
|
|
|
dummypad.SetShape( pad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG ?
|
|
|
|
PAD_SHAPE_OVAL : PAD_SHAPE_CIRCLE );
|
2012-02-19 04:02:19 +00:00
|
|
|
dummypad.SetPosition( pad->GetPosition() );
|
|
|
|
|
2010-10-28 13:02:07 +00:00
|
|
|
pad = &dummypad;
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|
|
|
|
|
2014-05-29 11:48:14 +00:00
|
|
|
// Note: netcode <=0 means not connected item
|
|
|
|
if( ( pad->GetNetCode() != GetNetCode() ) || ( pad->GetNetCode() <= 0 ) )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2015-05-23 17:12:40 +00:00
|
|
|
item_clearance = pad->GetClearance() + outline_half_thickness;
|
2010-07-26 17:06:36 +00:00
|
|
|
item_boundingbox = pad->GetBoundingBox();
|
2012-08-31 18:43:09 +00:00
|
|
|
item_boundingbox.Inflate( item_clearance );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
if( item_boundingbox.Intersects( zone_boundingbox ) )
|
|
|
|
{
|
2012-08-03 15:43:15 +00:00
|
|
|
int clearance = std::max( zone_clearance, item_clearance );
|
2015-06-12 15:13:18 +00:00
|
|
|
pad->TransformShapeWithClearanceToPolygon( aFeatures,
|
2010-07-26 17:06:36 +00:00
|
|
|
clearance,
|
2015-06-12 15:13:18 +00:00
|
|
|
segsPerCircle,
|
|
|
|
correctionFactor );
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
// Pads are removed from zone if the setup is PAD_ZONE_CONN_NONE
|
2015-08-18 14:19:17 +00:00
|
|
|
if( GetPadConnection( pad ) == PAD_ZONE_CONN_NONE )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2014-05-29 11:48:14 +00:00
|
|
|
int gap = zone_clearance;
|
|
|
|
int thermalGap = GetThermalReliefGap( pad );
|
|
|
|
gap = std::max( gap, thermalGap );
|
2010-07-26 17:06:36 +00:00
|
|
|
item_boundingbox = pad->GetBoundingBox();
|
2016-04-06 18:15:49 +00:00
|
|
|
item_boundingbox.Inflate( gap );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
if( item_boundingbox.Intersects( zone_boundingbox ) )
|
|
|
|
{
|
2015-06-12 15:13:18 +00:00
|
|
|
pad->TransformShapeWithClearanceToPolygon( aFeatures,
|
2010-07-26 17:06:36 +00:00
|
|
|
gap,
|
2015-06-12 15:13:18 +00:00
|
|
|
segsPerCircle,
|
|
|
|
correctionFactor );
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add holes (i.e. tracks and vias areas as polygons outlines)
|
|
|
|
* in cornerBufferPolysToSubstract
|
|
|
|
*/
|
|
|
|
for( TRACK* track = aPcb->m_Track; track; track = track->Next() )
|
|
|
|
{
|
|
|
|
if( !track->IsOnLayer( GetLayer() ) )
|
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-02-25 10:47:27 +00:00
|
|
|
if( track->GetNetCode() == GetNetCode() && (GetNetCode() != 0) )
|
2010-07-26 17:06:36 +00:00
|
|
|
continue;
|
|
|
|
|
2015-05-23 17:12:40 +00:00
|
|
|
item_clearance = track->GetClearance() + outline_half_thickness;
|
2010-07-26 17:06:36 +00:00
|
|
|
item_boundingbox = track->GetBoundingBox();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
if( item_boundingbox.Intersects( zone_boundingbox ) )
|
|
|
|
{
|
2012-08-03 15:43:15 +00:00
|
|
|
int clearance = std::max( zone_clearance, item_clearance );
|
2015-06-12 15:13:18 +00:00
|
|
|
track->TransformShapeWithClearanceToPolygon( aFeatures,
|
2010-07-26 17:06:36 +00:00
|
|
|
clearance,
|
2015-06-12 15:13:18 +00:00
|
|
|
segsPerCircle,
|
|
|
|
correctionFactor );
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add module edge items that are on copper layers
|
|
|
|
* Pcbnew allows these items to be on copper layers in microwave applictions
|
2014-07-09 13:02:56 +00:00
|
|
|
* This is a bad thing, but must be handled here, until a better way is found
|
2010-07-26 17:06:36 +00:00
|
|
|
*/
|
|
|
|
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2014-07-09 14:25:50 +00:00
|
|
|
if( !item->IsOnLayer( GetLayer() ) && !item->IsOnLayer( Edge_Cuts ) )
|
2010-07-26 17:06:36 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( item->Type() != PCB_MODULE_EDGE_T )
|
2010-07-26 17:06:36 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
item_boundingbox = item->GetBoundingBox();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
if( item_boundingbox.Intersects( zone_boundingbox ) )
|
|
|
|
{
|
|
|
|
( (EDGE_MODULE*) item )->TransformShapeWithClearanceToPolygon(
|
2015-06-12 15:13:18 +00:00
|
|
|
aFeatures, zone_clearance,
|
|
|
|
segsPerCircle, correctionFactor );
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add graphic items (copper texts) and board edges
|
2012-04-16 12:56:01 +00:00
|
|
|
for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( item->GetLayer() != GetLayer() && item->GetLayer() != Edge_Cuts )
|
2010-07-26 17:06:36 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2010-07-26 17:06:36 +00:00
|
|
|
( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
|
2015-06-12 15:13:18 +00:00
|
|
|
aFeatures,
|
|
|
|
zone_clearance, segsPerCircle, correctionFactor );
|
2010-07-26 17:06:36 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2013-05-01 19:01:14 +00:00
|
|
|
( (TEXTE_PCB*) item )->TransformBoundingBoxWithClearanceToPolygon(
|
2015-06-12 15:13:18 +00:00
|
|
|
aFeatures, zone_clearance );
|
2010-07-26 17:06:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-14 16:27:25 +00:00
|
|
|
// Add zones outlines having an higher priority and keepout
|
2012-01-29 19:29:19 +00:00
|
|
|
for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone = GetBoard()->GetArea( ii );
|
|
|
|
if( zone->GetLayer() != GetLayer() )
|
|
|
|
continue;
|
|
|
|
|
2012-07-14 16:27:25 +00:00
|
|
|
if( !zone->GetIsKeepout() && zone->GetPriority() <= GetPriority() )
|
2012-07-13 18:55:29 +00:00
|
|
|
continue;
|
|
|
|
|
2012-07-14 16:27:25 +00:00
|
|
|
if( zone->GetIsKeepout() && ! zone->GetDoNotAllowCopperPour() )
|
2012-01-29 19:29:19 +00:00
|
|
|
continue;
|
|
|
|
|
2014-12-19 19:09:53 +00:00
|
|
|
// A highter priority zone or keepout area is found: remove this area
|
2012-01-29 19:29:19 +00:00
|
|
|
item_boundingbox = zone->GetBoundingBox();
|
|
|
|
if( !item_boundingbox.Intersects( zone_boundingbox ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Add the zone outline area.
|
|
|
|
// However if the zone has the same net as the current zone,
|
2015-05-23 17:12:40 +00:00
|
|
|
// do not add any clearance.
|
2012-01-29 19:29:19 +00:00
|
|
|
// the zone will be connected to the current zone, but filled areas
|
2012-07-13 18:55:29 +00:00
|
|
|
// will use different parameters (clearance, thermal shapes )
|
2014-12-19 19:09:53 +00:00
|
|
|
bool same_net = GetNetCode() == zone->GetNetCode();
|
|
|
|
bool use_net_clearance = true;
|
2015-05-23 17:12:40 +00:00
|
|
|
int min_clearance = zone_clearance;
|
|
|
|
|
|
|
|
// Do not forget to make room to draw the thick outlines
|
|
|
|
// of the hole created by the area of the zone to remove
|
|
|
|
int holeclearance = zone->GetClearance() + outline_half_thickness;
|
|
|
|
|
|
|
|
// The final clearance is obviously the max value of each zone clearance
|
|
|
|
min_clearance = std::max( min_clearance, holeclearance );
|
2012-07-13 18:55:29 +00:00
|
|
|
|
2014-12-19 19:09:53 +00:00
|
|
|
if( zone->GetIsKeepout() || same_net )
|
2012-07-14 16:27:25 +00:00
|
|
|
{
|
2014-12-19 19:09:53 +00:00
|
|
|
// Just take in account the fact the outline has a thickness, so
|
|
|
|
// the actual area to substract is inflated to take in account this fact
|
2015-05-23 17:12:40 +00:00
|
|
|
min_clearance = outline_half_thickness;
|
2014-12-19 19:09:53 +00:00
|
|
|
use_net_clearance = false;
|
2012-07-14 16:27:25 +00:00
|
|
|
}
|
2012-07-13 18:55:29 +00:00
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
zone->TransformOutlinesShapeWithClearanceToPolygon(
|
2015-06-12 15:13:18 +00:00
|
|
|
aFeatures,
|
2014-12-19 19:09:53 +00:00
|
|
|
min_clearance, use_net_clearance );
|
2012-01-29 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove thermal symbols
|
2012-02-24 23:23:46 +00:00
|
|
|
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2012-07-09 07:10:07 +00:00
|
|
|
// Rejects non-standard pads with tht-only thermal reliefs
|
2015-08-18 14:19:17 +00:00
|
|
|
if( GetPadConnection( pad ) == PAD_ZONE_CONN_THT_THERMAL
|
2015-08-23 19:40:33 +00:00
|
|
|
&& pad->GetAttribute() != PAD_ATTRIB_STANDARD )
|
2012-07-09 07:10:07 +00:00
|
|
|
continue;
|
|
|
|
|
2015-08-18 14:19:17 +00:00
|
|
|
if( GetPadConnection( pad ) != PAD_ZONE_CONN_THERMAL
|
|
|
|
&& GetPadConnection( pad ) != PAD_ZONE_CONN_THT_THERMAL )
|
2012-02-24 23:23:46 +00:00
|
|
|
continue;
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
if( !pad->IsOnLayer( GetLayer() ) )
|
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-02-25 10:47:27 +00:00
|
|
|
if( pad->GetNetCode() != GetNetCode() )
|
2012-02-24 23:23:46 +00:00
|
|
|
continue;
|
|
|
|
item_boundingbox = pad->GetBoundingBox();
|
2012-03-08 20:44:03 +00:00
|
|
|
int thermalGap = GetThermalReliefGap( pad );
|
|
|
|
item_boundingbox.Inflate( thermalGap, thermalGap );
|
2012-02-24 23:23:46 +00:00
|
|
|
|
|
|
|
if( item_boundingbox.Intersects( zone_boundingbox ) )
|
|
|
|
{
|
2015-06-12 15:13:18 +00:00
|
|
|
CreateThermalReliefPadPolygon( aFeatures,
|
2012-03-08 20:44:03 +00:00
|
|
|
*pad, thermalGap,
|
|
|
|
GetThermalReliefCopperBridge( pad ),
|
2012-02-24 23:23:46 +00:00
|
|
|
m_ZoneMinThickness,
|
2015-06-12 15:13:18 +00:00
|
|
|
segsPerCircle,
|
|
|
|
correctionFactor, s_thermalRot );
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-12 15:13:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function AddClearanceAreasPolygonsToPolysList
|
|
|
|
* Supports a min thickness area constraint.
|
|
|
|
* Add non copper areas polygons (pads and tracks with clearance)
|
|
|
|
* to the filled copper area found
|
|
|
|
* in BuildFilledPolysListData after calculating filled areas in a zone
|
|
|
|
* Non filled copper areas are pads and track and their clearance areas
|
|
|
|
* The filled copper area must be computed just before.
|
|
|
|
* BuildFilledPolysListData() call this function just after creating the
|
|
|
|
* filled copper area polygon (without clearance areas)
|
|
|
|
* to do that this function:
|
|
|
|
* 1 - Creates the main outline (zone outline) using a correction to shrink the resulting area
|
|
|
|
* with m_ZoneMinThickness/2 value.
|
|
|
|
* The result is areas with a margin of m_ZoneMinThickness/2
|
|
|
|
* When drawing outline with segments having a thickness of m_ZoneMinThickness, the
|
|
|
|
* outlines will match exactly the initial outlines
|
|
|
|
* 3 - Add all non filled areas (pads, tracks) in group B with a clearance of m_Clearance +
|
|
|
|
* m_ZoneMinThickness/2
|
|
|
|
* in a buffer
|
|
|
|
* - If Thermal shapes are wanted, add non filled area, in order to create these thermal shapes
|
|
|
|
* 4 - calculates the polygon A - B
|
|
|
|
* 5 - put resulting list of polygons (filled areas) in m_FilledPolysList
|
|
|
|
* This zone contains pads with the same net.
|
|
|
|
* 6 - Remove insulated copper islands
|
|
|
|
* 7 - If Thermal shapes are wanted, remove unconnected stubs in thermal shapes:
|
|
|
|
* creates a buffer of polygons corresponding to stubs to remove
|
|
|
|
* sub them to the filled areas.
|
|
|
|
* Remove new insulated copper islands
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList_NG( BOARD* aPcb )
|
|
|
|
{
|
|
|
|
int segsPerCircle;
|
|
|
|
double correctionFactor;
|
|
|
|
int outline_half_thickness = m_ZoneMinThickness / 2;
|
|
|
|
|
2015-08-02 17:39:24 +00:00
|
|
|
|
2016-05-22 17:39:20 +00:00
|
|
|
std::unique_ptr<SHAPE_FILE_IO> dumper( new SHAPE_FILE_IO(
|
2015-08-03 18:29:44 +00:00
|
|
|
g_DumpZonesWhenFilling ? "zones_dump.txt" : "", SHAPE_FILE_IO::IOM_APPEND ) );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
|
|
|
// Set the number of segments in arc approximations
|
|
|
|
if( m_ArcToSegmentsCount == ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF )
|
|
|
|
segsPerCircle = ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF;
|
|
|
|
else
|
|
|
|
segsPerCircle = ARC_APPROX_SEGMENTS_COUNT_LOW_DEF;
|
|
|
|
|
|
|
|
/* calculates the coeff to compensate radius reduction of holes clearance
|
|
|
|
* due to the segment approx.
|
|
|
|
* For a circle the min radius is radius * cos( 2PI / s_CircleToSegmentsCount / 2)
|
|
|
|
* s_Correction is 1 /cos( PI/s_CircleToSegmentsCount )
|
|
|
|
*/
|
|
|
|
correctionFactor = 1.0 / cos( M_PI / (double) segsPerCircle );
|
|
|
|
|
|
|
|
CPOLYGONS_LIST tmp;
|
|
|
|
|
|
|
|
if(g_DumpZonesWhenFilling)
|
|
|
|
dumper->BeginGroup("clipper-zone");
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET solidAreas = ConvertPolyListToPolySet( m_smoothedPoly->m_CornersList );
|
|
|
|
|
2015-07-27 19:46:47 +00:00
|
|
|
solidAreas.Inflate( -outline_half_thickness, segsPerCircle );
|
2015-12-15 20:21:25 +00:00
|
|
|
solidAreas.Simplify( POLY_CALC_MODE );
|
2015-07-27 19:45:57 +00:00
|
|
|
|
|
|
|
SHAPE_POLY_SET holes;
|
2015-06-12 15:13:18 +00:00
|
|
|
|
|
|
|
if(g_DumpZonesWhenFilling)
|
2015-07-04 16:38:08 +00:00
|
|
|
dumper->Write( &solidAreas, "solid-areas" );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
|
|
|
tmp.RemoveAllContours();
|
2015-07-27 19:45:57 +00:00
|
|
|
buildFeatureHoleList( aPcb, holes );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
|
|
|
if(g_DumpZonesWhenFilling)
|
2015-07-04 16:38:08 +00:00
|
|
|
dumper->Write( &holes, "feature-holes" );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2015-12-15 20:21:25 +00:00
|
|
|
holes.Simplify( POLY_CALC_MODE );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
|
|
|
if (g_DumpZonesWhenFilling)
|
2015-07-04 16:38:08 +00:00
|
|
|
dumper->Write( &holes, "feature-holes-postsimplify" );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2015-12-15 20:21:25 +00:00
|
|
|
solidAreas.BooleanSubtract( holes, POLY_CALC_MODE );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
|
|
|
if (g_DumpZonesWhenFilling)
|
2015-07-04 16:38:08 +00:00
|
|
|
dumper->Write( &solidAreas, "solid-areas-minus-holes" );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2016-04-18 18:15:44 +00:00
|
|
|
SHAPE_POLY_SET areas_fractured = solidAreas;
|
|
|
|
areas_fractured.Fracture( POLY_CALC_MODE );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
|
|
|
if (g_DumpZonesWhenFilling)
|
2016-04-18 18:15:44 +00:00
|
|
|
dumper->Write( &areas_fractured, "areas_fractured" );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2016-04-18 18:15:44 +00:00
|
|
|
m_FilledPolysList = areas_fractured;
|
2015-06-12 15:13:18 +00:00
|
|
|
|
|
|
|
// Remove insulated islands:
|
|
|
|
if( GetNetCode() > 0 )
|
|
|
|
TestForCopperIslandAndRemoveInsulatedIslands( aPcb );
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET thermalHoles;
|
|
|
|
|
2015-06-12 15:13:18 +00:00
|
|
|
// Test thermal stubs connections and add polygons to remove unconnected stubs.
|
|
|
|
// (this is a refinement for thermal relief shapes)
|
|
|
|
if( GetNetCode() > 0 )
|
2015-07-27 19:45:57 +00:00
|
|
|
BuildUnconnectedThermalStubsPolygonList( thermalHoles, aPcb, this,
|
2015-06-12 15:13:18 +00:00
|
|
|
correctionFactor, s_thermalRot );
|
|
|
|
|
|
|
|
// remove copper areas corresponding to not connected stubs
|
2015-07-27 19:45:57 +00:00
|
|
|
if( !thermalHoles.IsEmpty() )
|
2015-06-12 15:13:18 +00:00
|
|
|
{
|
2015-12-15 20:21:25 +00:00
|
|
|
thermalHoles.Simplify( POLY_CALC_MODE );
|
2015-06-12 15:13:18 +00:00
|
|
|
// Remove unconnected stubs
|
2015-12-15 20:21:25 +00:00
|
|
|
solidAreas.BooleanSubtract( thermalHoles, POLY_CALC_MODE );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
if( g_DumpZonesWhenFilling )
|
|
|
|
dumper->Write( &thermalHoles, "thermal-holes" );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
|
|
|
// put these areas in m_FilledPolysList
|
2016-04-18 18:15:44 +00:00
|
|
|
SHAPE_POLY_SET th_fractured = solidAreas;
|
|
|
|
th_fractured.Fracture( POLY_CALC_MODE );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
if( g_DumpZonesWhenFilling )
|
2016-04-18 18:15:44 +00:00
|
|
|
dumper->Write ( &th_fractured, "th_fractured" );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2016-04-18 18:15:44 +00:00
|
|
|
m_FilledPolysList = th_fractured;
|
2015-06-12 15:13:18 +00:00
|
|
|
|
|
|
|
if( GetNetCode() > 0 )
|
|
|
|
TestForCopperIslandAndRemoveInsulatedIslands( aPcb );
|
|
|
|
}
|
|
|
|
|
|
|
|
if(g_DumpZonesWhenFilling)
|
|
|
|
dumper->EndGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
|
|
|
|
{
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|