Commit 9d5e2713 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix a minor issue in non copper zones when creating the solid filled areas.

parent c82b8787
...@@ -261,6 +261,21 @@ public: ...@@ -261,6 +261,21 @@ public:
*/ */
int BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt>* aCornerBuffer = NULL ); int BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt>* aCornerBuffer = NULL );
/**
* Function CopyPolygonsFromKiPolygonListToFilledPolysList
* Copy polygons stored in aKiPolyList to m_FilledPolysList
* The previous m_FilledPolysList contents is replaced.
* @param aKiPolyList = a KI_POLYGON_SET containing polygons.
*/
void CopyPolygonsFromKiPolygonListToFilledPolysList( KI_POLYGON_SET& aKiPolyList );
/**
* Function CopyPolygonsFromFilledPolysListToKiPolygonList
* Copy polygons from m_FilledPolysList to aKiPolyList
* @param aKiPolyList = a KI_POLYGON_SET to fill by polygons.
*/
void CopyPolygonsFromFilledPolysListToKiPolygonList( KI_POLYGON_SET& aKiPolyList );
/** /**
* Function AddClearanceAreasPolygonsToPolysList * Function AddClearanceAreasPolygonsToPolysList
* Add non copper areas polygons (pads and tracks with clearance) * Add non copper areas polygons (pads and tracks with clearance)
......
...@@ -95,14 +95,35 @@ int ZONE_CONTAINER::BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt> ...@@ -95,14 +95,35 @@ int ZONE_CONTAINER::BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt>
else else
ConvertPolysListWithHolesToOnePolygon( m_smoothedPoly->m_CornersList, ConvertPolysListWithHolesToOnePolygon( m_smoothedPoly->m_CornersList,
m_FilledPolysList ); m_FilledPolysList );
/* For copper layers, we now must add holes in the Polygon list. /* For copper layers, we now must add holes in the Polygon list.
* holes are pads and tracks with their clearance area * holes are pads and tracks with their clearance area
* for non copper layers just recalculate the m_FilledPolysList
* with m_ZoneMinThickness taken in account
*/ */
if( ! aCornerBuffer ) if( ! aCornerBuffer )
{ {
if( IsOnCopperLayer() ) if( IsOnCopperLayer() )
AddClearanceAreasPolygonsToPolysList( aPcb ); AddClearanceAreasPolygonsToPolysList( aPcb );
else
{
// This KI_POLYGON_SET is the area(s) to fill, with m_ZoneMinThickness/2
KI_POLYGON_SET polyset_zone_solid_areas;
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 polygon is stored in polyset_zone_solid_areas
*/
CopyPolygonsFromFilledPolysListToKiPolygonList( polyset_zone_solid_areas );
polyset_zone_solid_areas -= margin;
// put solid area in m_FilledPolysList:
m_FilledPolysList.clear();
CopyPolygonsFromKiPolygonListToFilledPolysList( polyset_zone_solid_areas );
}
if ( m_FillMode ) // if fill mode uses segments, create them: if ( m_FillMode ) // if fill mode uses segments, create them:
Fill_Zone_Areas_With_Segments( ); Fill_Zone_Areas_With_Segments( );
} }
......
...@@ -79,17 +79,8 @@ extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer, ...@@ -79,17 +79,8 @@ extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor, double aCorrectionFactor,
int aThermalRot ); int aThermalRot );
// Local Functions: helper function to calculate solid areas
static void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer, static void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
KI_POLYGON_SET& aKiPolyList ); KI_POLYGON_SET& aKiPolyList );
static int CopyPolygonsFromKiPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
KI_POLYGON_SET& aKiPolyList );
static int CopyPolygonsFromFilledPolysListToKiPolygonList( ZONE_CONTAINER* aZone,
KI_POLYGON_SET& aKiPolyList );
// Local Variables: // Local Variables:
static int s_thermalRot = 450; // angle of stubs in thermal reliefs for round pads static int s_thermalRot = 450; // angle of stubs in thermal reliefs for round pads
...@@ -160,7 +151,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -160,7 +151,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
* the main polygon is stored in polyset_zone_solid_areas * the main polygon is stored in polyset_zone_solid_areas
*/ */
CopyPolygonsFromFilledPolysListToKiPolygonList( this, polyset_zone_solid_areas ); CopyPolygonsFromFilledPolysListToKiPolygonList( polyset_zone_solid_areas );
polyset_zone_solid_areas -= margin; polyset_zone_solid_areas -= margin;
if( polyset_zone_solid_areas.size() == 0 ) if( polyset_zone_solid_areas.size() == 0 )
...@@ -439,7 +430,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -439,7 +430,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
// put solid areas in m_FilledPolysList: // put solid areas in m_FilledPolysList:
m_FilledPolysList.clear(); m_FilledPolysList.clear();
CopyPolygonsFromKiPolygonListToFilledPolysList( this, polyset_zone_solid_areas ); CopyPolygonsFromKiPolygonListToFilledPolysList( polyset_zone_solid_areas );
// Remove insulated islands: // Remove insulated islands:
if( GetNet() > 0 ) if( GetNet() > 0 )
...@@ -461,7 +452,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -461,7 +452,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
// put these areas in m_FilledPolysList // put these areas in m_FilledPolysList
m_FilledPolysList.clear(); m_FilledPolysList.clear();
CopyPolygonsFromKiPolygonListToFilledPolysList( this, polyset_zone_solid_areas ); CopyPolygonsFromKiPolygonListToFilledPolysList( polyset_zone_solid_areas );
if( GetNet() > 0 ) if( GetNet() > 0 )
Test_For_Copper_Island_And_Remove_Insulated_Islands( aPcb ); Test_For_Copper_Island_And_Remove_Insulated_Islands( aPcb );
...@@ -507,11 +498,9 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer, ...@@ -507,11 +498,9 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
} }
int CopyPolygonsFromKiPolygonListToFilledPolysList( ZONE_CONTAINER* aZone, void ZONE_CONTAINER::CopyPolygonsFromKiPolygonListToFilledPolysList( KI_POLYGON_SET& aKiPolyList )
KI_POLYGON_SET& aKiPolyList )
{ {
int count = 0; m_FilledPolysList.clear();
std::vector<CPolyPt> polysList;
for( unsigned ii = 0; ii < aKiPolyList.size(); ii++ ) for( unsigned ii = 0; ii < aKiPolyList.size(); ii++ )
{ {
...@@ -524,33 +513,26 @@ int CopyPolygonsFromKiPolygonListToFilledPolysList( ZONE_CONTAINER* aZone, ...@@ -524,33 +513,26 @@ int CopyPolygonsFromKiPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
corner.x = point.x(); corner.x = point.x();
corner.y = point.y(); corner.y = point.y();
corner.end_contour = false; corner.end_contour = false;
polysList.push_back( corner ); m_FilledPolysList.push_back( corner );
count++;
} }
corner.end_contour = true; corner.end_contour = true;
polysList.pop_back(); m_FilledPolysList.pop_back();
polysList.push_back( corner ); m_FilledPolysList.push_back( corner );
} }
aZone->AddFilledPolysList( polysList );
return count;
} }
int CopyPolygonsFromFilledPolysListToKiPolygonList( ZONE_CONTAINER* aZone, void ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToKiPolygonList( KI_POLYGON_SET& aKiPolyList )
KI_POLYGON_SET& aKiPolyList )
{ {
const std::vector<CPolyPt>& polysList = aZone->GetFilledPolysList(); unsigned corners_count = m_FilledPolysList.size();
unsigned corners_count = polysList.size();
int count = 0;
unsigned ic = 0; unsigned ic = 0;
int polycount = 0; int polycount = 0;
for( unsigned ii = 0; ii < corners_count; ii++ ) for( unsigned ii = 0; ii < corners_count; ii++ )
{ {
const CPolyPt& corner = polysList[ii]; const CPolyPt& corner = m_FilledPolysList[ii];
if( corner.end_contour ) if( corner.end_contour )
polycount++; polycount++;
...@@ -566,9 +548,8 @@ int CopyPolygonsFromFilledPolysListToKiPolygonList( ZONE_CONTAINER* aZone, ...@@ -566,9 +548,8 @@ int CopyPolygonsFromFilledPolysListToKiPolygonList( ZONE_CONTAINER* aZone,
{ {
while( ic < corners_count ) while( ic < corners_count )
{ {
const CPolyPt& corner = polysList[ic++]; const CPolyPt& corner = m_FilledPolysList[ic++];
cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) ); cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) );
count++;
if( corner.end_contour ) if( corner.end_contour )
break; break;
...@@ -578,6 +559,4 @@ int CopyPolygonsFromFilledPolysListToKiPolygonList( ZONE_CONTAINER* aZone, ...@@ -578,6 +559,4 @@ int CopyPolygonsFromFilledPolysListToKiPolygonList( ZONE_CONTAINER* aZone,
aKiPolyList.push_back( poly ); aKiPolyList.push_back( poly );
} }
} }
return count;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment