2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file zones_polygons_insulated_copper_islands.cpp
|
|
|
|
*/
|
2008-11-14 22:40:31 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
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>
|
2008-11-14 22:40:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Test_For_Copper_Island_And_Remove__Insulated_Islands
|
|
|
|
* Remove insulated copper islands found in m_FilledPolysList.
|
|
|
|
* @param aPcb = the board to analyse
|
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
void ZONE_CONTAINER::Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD * aPcb )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
if( m_FilledPolysList.size() == 0 )
|
|
|
|
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.
|
|
|
|
std::vector <wxPoint> ListPointsCandidates;
|
|
|
|
|
|
|
|
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2011-09-23 13:57:12 +00:00
|
|
|
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
if( !pad->IsOnLayer( GetLayer() ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( pad->GetNet() != GetNet() )
|
|
|
|
continue;
|
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
ListPointsCandidates.push_back( pad->m_Pos );
|
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
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
if( track->GetNet() != GetNet() )
|
|
|
|
continue;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2008-11-18 18:13:55 +00:00
|
|
|
ListPointsCandidates.push_back( track->m_Start );
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( track->Type() != PCB_VIA_T )
|
2008-11-18 18:13:55 +00:00
|
|
|
ListPointsCandidates.push_back( track->m_End );
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// test if a point is inside
|
|
|
|
unsigned indexstart = 0, indexend;
|
|
|
|
bool connected = false;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
|
|
|
for( indexend = 0; indexend < m_FilledPolysList.size(); indexend++ )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2011-09-23 13:57:12 +00:00
|
|
|
if( m_FilledPolysList[indexend].end_contour ) // end of a filled sub-area found
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2011-09-23 13:57:12 +00:00
|
|
|
EDA_RECT bbox = CalculateSubAreaBoundaryBox( indexstart, indexend );
|
|
|
|
|
|
|
|
for( unsigned ic = 0; ic < ListPointsCandidates.size(); ic++ )
|
|
|
|
{
|
|
|
|
// test if this area is connected to a board item:
|
2008-11-18 18:13:55 +00:00
|
|
|
wxPoint pos = ListPointsCandidates[ic];
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
if( !bbox.Contains( pos ) )
|
2008-11-14 22:40:31 +00:00
|
|
|
continue;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
|
|
|
if( TestPointInsidePolygon( m_FilledPolysList, indexstart, indexend,
|
|
|
|
pos.x, pos.y ) )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
|
|
|
connected = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
if( connected ) // this polygon is connected: analyse next polygon
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2011-09-23 13:57:12 +00:00
|
|
|
indexstart = indexend + 1; // indexstart points the first point of the next polygon
|
2008-11-14 22:40:31 +00:00
|
|
|
connected = false;
|
|
|
|
}
|
2011-09-23 13:57:12 +00:00
|
|
|
else // Not connected: remove this polygon
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2011-09-23 13:57:12 +00:00
|
|
|
m_FilledPolysList.erase( m_FilledPolysList.begin() + indexstart,
|
|
|
|
m_FilledPolysList.begin() + indexend + 1 );
|
|
|
|
|
|
|
|
indexend = indexstart; /* indexstart points the first point of the next polygon
|
|
|
|
* because the current poly is removed */
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function CalculateSubAreaBoundaryBox
|
2008-11-18 18:13:55 +00:00
|
|
|
* Calculates the bounding box of a a filled area ( list of CPolyPt )
|
2011-09-23 13:57:12 +00:00
|
|
|
* use m_FilledPolysList as list of CPolyPt (that are the corners of one or more polygons or
|
|
|
|
* filled areas )
|
2011-03-29 19:33:07 +00:00
|
|
|
* @return an EDA_RECT as bounding box
|
2008-11-18 18:13:55 +00:00
|
|
|
* @param aIndexStart = index of the first corner of a polygon (filled area) in m_FilledPolysList
|
|
|
|
* @param aIndexEnd = index of the last corner of a polygon in m_FilledPolysList
|
2008-11-14 22:40:31 +00:00
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
EDA_RECT ZONE_CONTAINER::CalculateSubAreaBoundaryBox( int aIndexStart, int aIndexEnd )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2008-11-18 18:13:55 +00:00
|
|
|
CPolyPt start_point, end_point;
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT bbox;
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2008-11-18 18:13:55 +00:00
|
|
|
start_point = m_FilledPolysList[aIndexStart];
|
2008-11-14 22:40:31 +00:00
|
|
|
end_point = start_point;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
for( int ii = aIndexStart; ii <= aIndexEnd; ii++ )
|
|
|
|
{
|
2008-11-18 18:13:55 +00:00
|
|
|
CPolyPt ptst = m_FilledPolysList[ii];
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
if( start_point.x > ptst.x )
|
|
|
|
start_point.x = ptst.x;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
if( start_point.y > ptst.y )
|
|
|
|
start_point.y = ptst.y;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
if( end_point.x < ptst.x )
|
|
|
|
end_point.x = ptst.x;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
if( end_point.y < ptst.y )
|
|
|
|
end_point.y = ptst.y;
|
|
|
|
}
|
|
|
|
|
2008-11-18 18:13:55 +00:00
|
|
|
bbox.SetOrigin( start_point.x, start_point.y );
|
|
|
|
bbox.SetEnd( wxPoint( end_point.x, end_point.y ) );
|
|
|
|
|
|
|
|
return bbox;
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|