2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file zones_polygons_insulated_copper_islands.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
|
|
|
|
*/
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_zone.h>
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <zones.h>
|
2012-07-31 17:51:58 +00:00
|
|
|
#include <polygon_test_point_inside.h>
|
2008-11-14 22:40:31 +00:00
|
|
|
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
void ZONE_CONTAINER::TestForCopperIslandAndRemoveInsulatedIslands( BOARD* aPcb )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2015-07-14 20:23:13 +00:00
|
|
|
if( m_FilledPolysList.GetCornersCount() == 0 )
|
2008-11-14 22:40:31 +00:00
|
|
|
return;
|
|
|
|
|
2008-11-18 18:13:55 +00:00
|
|
|
// Build a list of points connected to the net:
|
2011-09-23 13:57:12 +00:00
|
|
|
// list of coordinates of pads and vias on this layer and on this net.
|
2012-02-19 04:02:19 +00:00
|
|
|
std::vector <wxPoint> listPointsCandidates;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
|
|
|
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
if( !pad->IsOnLayer( GetLayer() ) )
|
|
|
|
continue;
|
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
if( pad->GetNetCode() != GetNetCode() )
|
2008-11-14 22:40:31 +00:00
|
|
|
continue;
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
listPointsCandidates.push_back( pad->GetPosition() );
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
for( TRACK* track = aPcb->m_Track; track; track = track->Next() )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
if( !track->IsOnLayer( GetLayer() ) )
|
|
|
|
continue;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
if( track->GetNetCode() != GetNetCode() )
|
2008-11-14 22:40:31 +00:00
|
|
|
continue;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
listPointsCandidates.push_back( track->GetStart() );
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( track->Type() != PCB_VIA_T )
|
2013-01-13 00:04:00 +00:00
|
|
|
listPointsCandidates.push_back( track->GetEnd() );
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// test if a point is inside
|
2015-07-14 20:23:13 +00:00
|
|
|
unsigned indexstart = 0, indexend;
|
|
|
|
bool connected = false;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2015-07-14 20:23:13 +00:00
|
|
|
for( indexend = 0; indexend < m_FilledPolysList.GetCornersCount(); indexend++ )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2015-07-14 20:23:13 +00:00
|
|
|
if( m_FilledPolysList[indexend].end_contour ) // end of a filled sub-area found
|
2015-07-14 11:36:24 +00:00
|
|
|
{
|
2015-07-14 20:23:13 +00:00
|
|
|
EDA_RECT bbox = CalculateSubAreaBoundaryBox( indexstart, indexend );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2015-07-14 20:23:13 +00:00
|
|
|
for( unsigned ic = 0; ic < listPointsCandidates.size(); ic++ )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2015-07-14 20:23:13 +00:00
|
|
|
// test if this area is connected to a board item:
|
|
|
|
wxPoint pos = listPointsCandidates[ic];
|
|
|
|
|
|
|
|
if( !bbox.Contains( pos ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( TestPointInsidePolygon( m_FilledPolysList, indexstart, indexend,
|
|
|
|
pos.x, pos.y ) )
|
|
|
|
{
|
|
|
|
connected = true;
|
|
|
|
break;
|
|
|
|
}
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 20:23:13 +00:00
|
|
|
if( connected ) // this polygon is connected: analyse next polygon
|
|
|
|
{
|
|
|
|
indexstart = indexend + 1; // indexstart points the first point of the next polygon
|
|
|
|
connected = false;
|
|
|
|
}
|
|
|
|
else // Not connected: remove this polygon
|
|
|
|
{
|
|
|
|
m_FilledPolysList.DeleteCorners( indexstart, indexend );
|
|
|
|
indexend = indexstart; /* indexstart points the first point of the next polygon
|
|
|
|
* because the current poly is removed */
|
|
|
|
}
|
2015-07-14 11:36:24 +00:00
|
|
|
}
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-14 20:23:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
EDA_RECT ZONE_CONTAINER::CalculateSubAreaBoundaryBox( int aIndexStart, int aIndexEnd )
|
|
|
|
{
|
|
|
|
CPolyPt start_point, end_point;
|
|
|
|
EDA_RECT bbox;
|
|
|
|
|
|
|
|
start_point = m_FilledPolysList[aIndexStart];
|
|
|
|
end_point = start_point;
|
|
|
|
|
|
|
|
for( int ii = aIndexStart; ii <= aIndexEnd; ii++ )
|
|
|
|
{
|
|
|
|
CPolyPt ptst = m_FilledPolysList[ii];
|
|
|
|
|
|
|
|
if( start_point.x > ptst.x )
|
|
|
|
start_point.x = ptst.x;
|
|
|
|
|
|
|
|
if( start_point.y > ptst.y )
|
|
|
|
start_point.y = ptst.y;
|
|
|
|
|
|
|
|
if( end_point.x < ptst.x )
|
|
|
|
end_point.x = ptst.x;
|
|
|
|
|
|
|
|
if( end_point.y < ptst.y )
|
|
|
|
end_point.y = ptst.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
bbox.SetOrigin( start_point.x, start_point.y );
|
|
|
|
bbox.SetEnd( wxPoint( end_point.x, end_point.y ) );
|
|
|
|
|
|
|
|
return bbox;
|
|
|
|
}
|