2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file zones_convert_brd_items_to_polygons_with_Boost.cpp
|
|
|
|
*/
|
2012-06-08 09:56:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
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.
|
|
|
|
*/
|
|
|
|
|
2012-09-21 17:02:54 +00:00
|
|
|
#include <cmath>
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <polygons_defs.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>
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
2013-05-03 17:51:10 +00:00
|
|
|
extern void BuildUnconnectedThermalStubsPolygonList( CPOLYGONS_LIST& 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
|
|
|
|
2013-05-03 17:51:10 +00:00
|
|
|
extern void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& 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
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// how many segments are used to create a polygon from a circle:
|
2010-07-26 17:06:36 +00:00
|
|
|
static int s_CircleToSegmentsCount = ARC_APPROX_SEGMENTS_COUNT_LOW_DEF; /* default value. the real value will be changed to
|
|
|
|
* ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF
|
|
|
|
* if m_ArcToSegmentsCount == ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF
|
|
|
|
*/
|
|
|
|
double s_Correction; /* mult coeff used to enlarge rounded and oval pads (and vias)
|
|
|
|
* because the segment approximation for arcs and circles
|
|
|
|
* create a smaller gap than a true circle
|
|
|
|
*/
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function AddClearanceAreasPolygonsToPolysList
|
2010-07-26 17:06:36 +00:00
|
|
|
* Supports a min thickness area constraint.
|
2013-05-01 19:01:14 +00:00
|
|
|
* Add non copper areas polygons (pads and tracks with clearance)
|
2010-07-26 17:06:36 +00:00
|
|
|
* 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
|
2013-05-01 19:01:14 +00:00
|
|
|
* filled copper area polygon (without clearance areas)
|
2010-07-26 17:06:36 +00:00
|
|
|
* 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
|
2011-09-07 19:41:04 +00:00
|
|
|
* 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
|
2010-07-26 17:06:36 +00:00
|
|
|
* 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:
|
2011-09-07 19:41:04 +00:00
|
|
|
* creates a buffer of polygons corresponding to stubs to remove
|
|
|
|
* sub them to the filled areas.
|
|
|
|
* Remove new insulated copper islands
|
2010-07-26 17:06:36 +00:00
|
|
|
*/
|
|
|
|
void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
|
|
|
|
{
|
|
|
|
// Set the number of segments in arc approximations
|
|
|
|
if( m_ArcToSegmentsCount == ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF )
|
|
|
|
s_CircleToSegmentsCount = ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF;
|
|
|
|
else
|
|
|
|
s_CircleToSegmentsCount = 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 )
|
|
|
|
*/
|
2012-10-17 20:59:05 +00:00
|
|
|
s_Correction = 1.0 / cos( M_PI / s_CircleToSegmentsCount );
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2012-07-25 07:36:56 +00:00
|
|
|
// This KI_POLYGON_SET is the area(s) to fill, with m_ZoneMinThickness/2
|
|
|
|
KI_POLYGON_SET polyset_zone_solid_areas;
|
2010-07-26 17:06:36 +00:00
|
|
|
int margin = m_ZoneMinThickness / 2;
|
|
|
|
|
|
|
|
/* First, creates the main polygon (i.e. the filled area using only one outline)
|
|
|
|
* to reserve a m_ZoneMinThickness/2 margin around the outlines and holes
|
|
|
|
* this margin is the room to redraw outlines with segments having a width set to
|
|
|
|
* m_ZoneMinThickness
|
|
|
|
* so m_ZoneMinThickness is the min thickness of the filled zones areas
|
|
|
|
* the main polygon is stored in polyset_zone_solid_areas
|
|
|
|
*/
|
2010-07-31 12:26:07 +00:00
|
|
|
|
2012-08-04 16:33:04 +00:00
|
|
|
CopyPolygonsFromFilledPolysListToKiPolygonList( polyset_zone_solid_areas );
|
2010-07-26 17:06:36 +00:00
|
|
|
polyset_zone_solid_areas -= margin;
|
|
|
|
|
|
|
|
if( polyset_zone_solid_areas.size() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Calculates the clearance value that meet DRC requirements
|
|
|
|
* from m_ZoneClearance and clearance from the corresponding netclass
|
|
|
|
* We have a "local" clearance in zones because most of time
|
|
|
|
* clearance between a zone and others items is bigger than the netclass clearance
|
|
|
|
* this is more true for small clearance values
|
|
|
|
* Note also the "local" clearance is used for clearance between non copper items
|
|
|
|
* or items like texts on copper layers
|
|
|
|
*/
|
2012-08-03 15:43:15 +00:00
|
|
|
int zone_clearance = std::max( m_ZoneClearance, GetClearance() );
|
2010-07-26 17:06:36 +00:00
|
|
|
zone_clearance += margin;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
// static to avoid unnecessary memory allocation when filling many zones.
|
2013-05-03 17:51:10 +00:00
|
|
|
static CPOLYGONS_LIST cornerBufferPolysToSubstract;
|
2013-05-14 18:47:01 +00:00
|
|
|
cornerBufferPolysToSubstract.RemoveAllContours();
|
2010-07-26 17:06:36 +00:00
|
|
|
|
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() );
|
2014-01-26 14:20:58 +00:00
|
|
|
dummypad.SetShape( pad->GetDrillShape() == PAD_DRILL_OBLONG ?
|
|
|
|
PAD_OVAL : PAD_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
|
|
|
{
|
|
|
|
item_clearance = pad->GetClearance() + margin;
|
|
|
|
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 );
|
2010-07-26 17:06:36 +00:00
|
|
|
pad->TransformShapeWithClearanceToPolygon( cornerBufferPolysToSubstract,
|
|
|
|
clearance,
|
|
|
|
s_CircleToSegmentsCount,
|
|
|
|
s_Correction );
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
if( ( GetPadConnection( pad ) == PAD_NOT_IN_ZONE )
|
2014-05-29 11:48:14 +00:00
|
|
|
|| ( pad->GetShape() == PAD_TRAPEZOID ) )
|
2010-07-26 17:06:36 +00:00
|
|
|
|
|
|
|
// PAD_TRAPEZOID shapes are not in zones because they are used in microwave apps
|
|
|
|
// and i think it is good that shapes are not changed by thermal pads or others
|
|
|
|
{
|
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();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
if( item_boundingbox.Intersects( zone_boundingbox ) )
|
|
|
|
{
|
|
|
|
pad->TransformShapeWithClearanceToPolygon( cornerBufferPolysToSubstract,
|
|
|
|
gap,
|
|
|
|
s_CircleToSegmentsCount,
|
|
|
|
s_Correction );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
item_clearance = track->GetClearance() + margin;
|
|
|
|
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 );
|
2010-07-26 17:06:36 +00:00
|
|
|
track->TransformShapeWithClearanceToPolygon( cornerBufferPolysToSubstract,
|
|
|
|
clearance,
|
|
|
|
s_CircleToSegmentsCount,
|
|
|
|
s_Correction );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add module edge items that are on copper layers
|
|
|
|
* Pcbnew allows these items to be on copper layers in microwave applictions
|
|
|
|
* This is a bad thing, but must be handle here, until a better way is found
|
|
|
|
*/
|
|
|
|
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
|
|
|
{
|
|
|
|
if( !item->IsOnLayer( GetLayer() ) )
|
|
|
|
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(
|
2011-01-09 21:12:22 +00:00
|
|
|
cornerBufferPolysToSubstract, zone_clearance,
|
2010-07-26 17:06:36 +00:00
|
|
|
s_CircleToSegmentsCount, s_Correction );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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(
|
|
|
|
cornerBufferPolysToSubstract,
|
2013-05-01 19:01:14 +00:00
|
|
|
zone_clearance, s_CircleToSegmentsCount, s_Correction );
|
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(
|
|
|
|
cornerBufferPolysToSubstract, 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;
|
|
|
|
|
2012-07-14 16:27:25 +00:00
|
|
|
// A highter priority zone or keepout area is found: remove its 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,
|
|
|
|
// do not add clearance.
|
|
|
|
// 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-02-25 10:47:27 +00:00
|
|
|
bool addclearance = GetNetCode() != zone->GetNetCode();
|
2012-07-14 16:27:25 +00:00
|
|
|
int clearance = zone_clearance;
|
2012-07-13 18:55:29 +00:00
|
|
|
|
|
|
|
if( zone->GetIsKeepout() )
|
2012-07-14 16:27:25 +00:00
|
|
|
{
|
|
|
|
addclearance = true;
|
|
|
|
clearance = m_ZoneMinThickness / 2;
|
|
|
|
}
|
2012-07-13 18:55:29 +00:00
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
zone->TransformOutlinesShapeWithClearanceToPolygon(
|
2012-01-29 19:29:19 +00:00
|
|
|
cornerBufferPolysToSubstract,
|
2013-05-01 19:01:14 +00:00
|
|
|
clearance, addclearance );
|
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
|
|
|
|
if( GetPadConnection( pad ) == THT_THERMAL
|
|
|
|
&& pad->GetAttribute() != PAD_STANDARD )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( GetPadConnection( pad ) != THERMAL_PAD
|
|
|
|
&& GetPadConnection( pad ) != 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 ) )
|
|
|
|
{
|
|
|
|
CreateThermalReliefPadPolygon( cornerBufferPolysToSubstract,
|
2012-03-08 20:44:03 +00:00
|
|
|
*pad, thermalGap,
|
|
|
|
GetThermalReliefCopperBridge( pad ),
|
2012-02-24 23:23:46 +00:00
|
|
|
m_ZoneMinThickness,
|
|
|
|
s_CircleToSegmentsCount,
|
|
|
|
s_Correction, s_thermalRot );
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// cornerBufferPolysToSubstract contains polygons to substract.
|
2011-05-06 07:17:28 +00:00
|
|
|
// polyset_zone_solid_areas contains the main filled area
|
2010-07-26 17:06:36 +00:00
|
|
|
// Calculate now actual solid areas
|
2013-05-09 19:08:12 +00:00
|
|
|
if( cornerBufferPolysToSubstract.GetCornersCount() > 0 )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2012-07-25 07:36:56 +00:00
|
|
|
KI_POLYGON_SET polyset_holes;
|
2013-05-08 18:20:58 +00:00
|
|
|
cornerBufferPolysToSubstract.ExportTo( polyset_holes );
|
2010-07-26 17:06:36 +00:00
|
|
|
// Remove holes from initial area.:
|
|
|
|
polyset_zone_solid_areas -= polyset_holes;
|
|
|
|
}
|
|
|
|
|
2011-05-06 07:17:28 +00:00
|
|
|
// put solid areas in m_FilledPolysList:
|
2013-05-14 18:47:01 +00:00
|
|
|
m_FilledPolysList.RemoveAllContours();
|
2012-08-04 16:33:04 +00:00
|
|
|
CopyPolygonsFromKiPolygonListToFilledPolysList( polyset_zone_solid_areas );
|
2011-05-06 07:17:28 +00:00
|
|
|
|
2010-07-26 17:06:36 +00:00
|
|
|
// Remove insulated islands:
|
2014-02-25 10:47:27 +00:00
|
|
|
if( GetNetCode() > 0 )
|
2013-03-20 14:50:12 +00:00
|
|
|
TestForCopperIslandAndRemoveInsulatedIslands( aPcb );
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
// Now we remove all unused thermal stubs.
|
2013-05-14 18:47:01 +00:00
|
|
|
cornerBufferPolysToSubstract.RemoveAllContours();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
// Test thermal stubs connections and add polygons to remove unconnected stubs.
|
2013-01-27 13:54:43 +00:00
|
|
|
// (this is a refinement for thermal relief shapes)
|
2014-02-25 10:47:27 +00:00
|
|
|
if( GetNetCode() > 0 )
|
2012-12-18 17:50:00 +00:00
|
|
|
BuildUnconnectedThermalStubsPolygonList( cornerBufferPolysToSubstract, aPcb, this,
|
|
|
|
s_Correction, s_thermalRot );
|
2010-07-26 17:06:36 +00:00
|
|
|
|
2013-01-27 13:54:43 +00:00
|
|
|
// remove copper areas corresponding to not connected stubs
|
2013-05-09 19:08:12 +00:00
|
|
|
if( cornerBufferPolysToSubstract.GetCornersCount() )
|
2012-02-24 23:23:46 +00:00
|
|
|
{
|
2012-07-25 07:36:56 +00:00
|
|
|
KI_POLYGON_SET polyset_holes;
|
2013-05-08 18:20:58 +00:00
|
|
|
cornerBufferPolysToSubstract.ExportTo( polyset_holes );
|
2013-01-27 13:54:43 +00:00
|
|
|
|
|
|
|
// Remove unconnected stubs
|
2012-02-24 23:23:46 +00:00
|
|
|
polyset_zone_solid_areas -= polyset_holes;
|
2010-12-01 07:51:21 +00:00
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
// put these areas in m_FilledPolysList
|
2013-05-14 18:47:01 +00:00
|
|
|
m_FilledPolysList.RemoveAllContours();
|
2012-08-04 16:33:04 +00:00
|
|
|
CopyPolygonsFromKiPolygonListToFilledPolysList( polyset_zone_solid_areas );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-02-25 10:47:27 +00:00
|
|
|
if( GetNetCode() > 0 )
|
2013-03-20 14:50:12 +00:00
|
|
|
TestForCopperIslandAndRemoveInsulatedIslands( aPcb );
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|
|
|
|
|
2013-05-14 18:47:01 +00:00
|
|
|
cornerBufferPolysToSubstract.RemoveAllContours();
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-04 16:33:04 +00:00
|
|
|
void ZONE_CONTAINER::CopyPolygonsFromKiPolygonListToFilledPolysList( KI_POLYGON_SET& aKiPolyList )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2013-05-14 18:47:01 +00:00
|
|
|
m_FilledPolysList.RemoveAllContours();
|
2013-05-08 18:20:58 +00:00
|
|
|
m_FilledPolysList.ImportFrom( aKiPolyList );
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-04 16:33:04 +00:00
|
|
|
void ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToKiPolygonList( KI_POLYGON_SET& aKiPolyList )
|
2010-07-26 17:06:36 +00:00
|
|
|
{
|
2013-05-08 18:20:58 +00:00
|
|
|
m_FilledPolysList.ExportTo( aKiPolyList );
|
2010-07-26 17:06:36 +00:00
|
|
|
}
|