Commit 2455a6cc authored by Marco Mattila's avatar Marco Mattila

Do some ZONE_CONTAINED encapsulation.

parent 57acee0d
......@@ -258,7 +258,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
if( curr_zone->m_FillMode == 0 )
{
// solid polygons only are used to fill areas
if( curr_zone->m_FilledPolysList.size() > 3 )
if( curr_zone->GetFilledPolysList().size() > 3 )
{
Draw3D_SolidPolygonsInZones( curr_zone );
}
......@@ -286,14 +286,16 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
{
ZONE_CONTAINER* zone = pcb->GetArea( ii );
if( zone->m_FilledPolysList.size() == 0 )
std::vector<CPolyPt> polysList = zone->GetFilledPolysList();
if( polysList.size() == 0 )
continue;
if( zone->m_ZoneMinThickness <= 1 )
continue;
int imax = zone->m_FilledPolysList.size() - 1;
CPolyPt* firstcorner = &zone->m_FilledPolysList[0];
int imax = polysList.size() - 1;
CPolyPt* firstcorner = &polysList[0];
CPolyPt* begincorner = firstcorner;
SEGZONE dummysegment( pcb );
dummysegment.SetLayer( zone->GetLayer() );
......@@ -301,7 +303,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
for( int ic = 1; ic <= imax; ic++ )
{
CPolyPt* endcorner = &zone->m_FilledPolysList[ic];
CPolyPt* endcorner = &polysList[ic];
if( begincorner->utility == 0 )
{
......@@ -330,7 +332,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
ic++;
if( ic < imax - 1 )
begincorner = firstcorner = &zone->m_FilledPolysList[ic];
begincorner = firstcorner = &polysList[ic];
}
else
{
......@@ -440,7 +442,8 @@ void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone )
// Draw solid areas contained in this zone
int StartContour = 1;
for( unsigned ii = 0; ii < aZone->m_FilledPolysList.size(); ii++ )
std::vector<CPolyPt> polysList = aZone->GetFilledPolysList();
for( unsigned ii = 0; ii < polysList.size(); ii++ )
{
if( StartContour == 1 )
{
......@@ -449,11 +452,11 @@ void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone )
StartContour = 0;
}
v_data[0] = aZone->m_FilledPolysList[ii].x * g_Parm_3D_Visu.m_BoardScale;
v_data[1] = -aZone->m_FilledPolysList[ii].y * g_Parm_3D_Visu.m_BoardScale;
gluTessVertex( tess, v_data, &aZone->m_FilledPolysList[ii] );
v_data[0] = polysList[ii].x * g_Parm_3D_Visu.m_BoardScale;
v_data[1] = -polysList[ii].y * g_Parm_3D_Visu.m_BoardScale;
gluTessVertex( tess, v_data, &polysList[ii] );
if( aZone->m_FilledPolysList[ii].end_contour == 1 )
if( polysList[ii].end_contour == 1 )
{
gluTessEndContour( tess );
gluTessEndPolygon( tess );
......
......@@ -457,6 +457,34 @@ public:
*/
bool IsSame( const ZONE_CONTAINER &aZoneToCompare );
/**
* Function ClearFilledPolysList
* clears the list of filled polygons.
*/
void ClearFilledPolysList()
{
m_FilledPolysList.clear();
}
/**
* Function GetFilledPolysList
* returns a reference to the list of filled polygons.
* @return Reference to the list of filled polygons.
*/
const std::vector<CPolyPt>& GetFilledPolysList() const
{
return m_FilledPolysList;
}
/**
* Function AddFilledPolysList
* sets the list of filled polygons.
*/
void AddFilledPolysList( std::vector<CPolyPt>& aPolysList )
{
m_FilledPolysList = aPolysList;
}
/**
* Function GetSmoothedPoly
* returns a pointer to the corner-smoothed version of
......@@ -522,16 +550,6 @@ public:
// true when a zone was filled, false after deleting the filled areas
bool m_IsFilled;
/* set of filled polygons used to draw a zone as a filled area.
* from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
* (they are* all in one piece) In very simple cases m_FilledPolysList is same
* as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
* a polygon equivalent to m_Poly, without holes but with extra outline segment
* connecting "holes" with external main outline. In complex cases an outline
* described by m_Poly can have many filled areas
*/
std::vector <CPolyPt> m_FilledPolysList;
/* set of segments used to fill area, when fill zone by segment is used.
* ( m_FillMode == 1 )
* in this case segments have m_ZoneMinThickness width
......@@ -549,6 +567,16 @@ private:
// if priorities are equal, a DRC error is set
unsigned m_priority;
ZoneConnection m_PadConnection;
/* set of filled polygons used to draw a zone as a filled area.
* from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
* (they are* all in one piece) In very simple cases m_FilledPolysList is same
* as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
* a polygon equivalent to m_Poly, without holes but with extra outline segment
* connecting "holes" with external main outline. In complex cases an outline
* described by m_Poly can have many filled areas
*/
std::vector <CPolyPt> m_FilledPolysList;
};
......
......@@ -579,7 +579,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
// Remove filled areas in zone
ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii );
zone_container->m_FilledPolysList.clear();
zone_container->ClearFilledPolysList();
}
SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
......
......@@ -970,7 +970,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, OUTPUTFORMATTER* aFormatter, int aNe
}
// Save the PolysList
const std::vector< CPolyPt >& fv = aZone->m_FilledPolysList;
const std::vector< CPolyPt >& fv = aZone->GetFilledPolysList();
if( fv.size() )
{
......
......@@ -2258,6 +2258,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
else if( TESTLINE( "$POLYSCORNERS" ) )
{
// Read the PolysList (polygons used for fill areas in the zone)
std::vector<CPolyPt> polysList;
while( READLINE( m_reader ) )
{
......@@ -2273,8 +2274,9 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
bool end_contour = intParse( data, &data ); // end_countour was a bool when file saved, so '0' or '1' here
int utility = intParse( data );
zc->m_FilledPolysList.push_back( CPolyPt( x, y, end_contour, utility ) );
polysList.push_back( CPolyPt( x, y, end_contour, utility ) );
}
zc->AddFilledPolysList( polysList );
}
else if( TESTLINE( "$FILLSEGMENTS" ) )
......@@ -3569,7 +3571,7 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
}
// Save the PolysList
const CPOLY_PTS& fv = me->m_FilledPolysList;
const CPOLY_PTS& fv = me->GetFilledPolysList();
if( fv.size() )
{
fprintf( m_fp, "$POLYSCORNERS\n" );
......
......@@ -631,7 +631,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu*
AddMenuItem( zones_menu, ID_POPUP_PCB_FILL_ZONE, _( "Fill Zone" ),
KiBitmap( fill_zone_xpm ) );
if( edge_zone->m_FilledPolysList.size() > 0 )
if( edge_zone->GetFilledPolysList().size() > 0 )
{
AddMenuItem( zones_menu, ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE,
_( "Remove Filled Areas in Zone" ), KiBitmap( zone_unfill_xpm ) );
......
......@@ -523,7 +523,8 @@ void PlotTextePcb( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, TEXTE_PC
*/
void PlotFilledAreas( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_CONTAINER* aZone, EDA_DRAW_MODE_T trace_mode )
{
unsigned imax = aZone->m_FilledPolysList.size();
std::vector<CPolyPt> polysList = aZone->GetFilledPolysList();
unsigned imax = polysList.size();
if( imax == 0 ) // Nothing to draw
return;
......@@ -540,7 +541,7 @@ void PlotFilledAreas( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_
*/
for( unsigned ic = 0; ic < imax; ic++ )
{
CPolyPt* corner = &aZone->m_FilledPolysList[ic];
CPolyPt* corner = &polysList[ic];
cornerList.push_back( wxPoint( corner->x, corner->y) );
if( corner->end_contour ) // Plot the current filled area outline
......
......@@ -105,7 +105,7 @@ int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* aZone )
wxBusyCursor dummy; // Shows an hourglass cursor (removed by its destructor)
aZone->m_FilledPolysList.clear();
aZone->ClearFilledPolysList();
aZone->UnFill();
aZone->BuildFilledPolysListData( GetBoard() );
......
......@@ -471,6 +471,7 @@ int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
KPolygonSet& aKPolyList )
{
int count = 0;
std::vector<CPolyPt> polysList;
for( unsigned ii = 0; ii < aKPolyList.size(); ii++ )
{
......@@ -487,14 +488,15 @@ int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
// Flag this corner if starting a hole connection segment:
// This is used by draw functions to draw only useful segments (and not extra segments)
// corner.utility = (aBoolengine->GetPolygonPointEdgeType() == KB_FALSE_EDGE) ? 1 : 0;
aZone->m_FilledPolysList.push_back( corner );
polysList.push_back( corner );
count++;
}
corner.end_contour = true;
aZone->m_FilledPolysList.pop_back();
aZone->m_FilledPolysList.push_back( corner );
polysList.pop_back();
polysList.push_back( corner );
}
aZone->AddFilledPolysList( polysList );
return count;
}
......@@ -503,7 +505,8 @@ int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone,
KPolygonSet& aKPolyList )
{
unsigned corners_count = aZone->m_FilledPolysList.size();
std::vector<CPolyPt> polysList = aZone->GetFilledPolysList();
unsigned corners_count = polysList.size();
int count = 0;
unsigned ic = 0;
......@@ -511,7 +514,7 @@ int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone,
for( unsigned ii = 0; ii < corners_count; ii++ )
{
CPolyPt* corner = &aZone->m_FilledPolysList[ic];
CPolyPt* corner = &polysList[ic];
if( corner->end_contour )
polycount++;
......@@ -527,7 +530,7 @@ int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone,
{
for( ; ic < corners_count; ic++ )
{
CPolyPt* corner = &aZone->m_FilledPolysList[ic];
CPolyPt* corner = &polysList[ic];
cornerslist.push_back( KPolyPoint( corner->x, corner->y ) );
count++;
......
......@@ -28,7 +28,7 @@ void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode );
bool sort_areas( const ZONE_CONTAINER* ref, const ZONE_CONTAINER* tst )
{
if( ref->GetNet() == tst->GetNet() )
return ref->m_FilledPolysList.size() < tst->m_FilledPolysList.size();
return ref->GetFilledPolysList().size() < tst->GetFilledPolysList().size();
else
return ref->GetNet() < tst->GetNet();
}
......@@ -71,7 +71,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
continue;
if( (aNetcode >= 0) && ( aNetcode != curr_zone->GetNet() ) )
continue;
if( curr_zone->m_FilledPolysList.size() == 0 )
if( curr_zone->GetFilledPolysList().size() == 0 )
continue;
zones_candidates.push_back(curr_zone);
}
......@@ -120,10 +120,11 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
// test if a candidate is inside a filled area of this zone
unsigned indexstart = 0, indexend;
for( indexend = 0; indexend < curr_zone->m_FilledPolysList.size(); indexend++ )
std::vector<CPolyPt> polysList = curr_zone->GetFilledPolysList();
for( indexend = 0; indexend < polysList.size(); indexend++ )
{
// end of a filled sub-area found
if( curr_zone->m_FilledPolysList[indexend].end_contour )
if( polysList[indexend].end_contour )
{
subnet++;
EDA_RECT bbox = curr_zone->CalculateSubAreaBoundaryBox( indexstart, indexend );
......@@ -162,7 +163,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
if( bbox.Contains( pos1 ) )
{
if( TestPointInsidePolygon( curr_zone->m_FilledPolysList, indexstart,
if( TestPointInsidePolygon( polysList, indexstart,
indexend, pos1.x, pos1.y ) )
connected = true;
}
......@@ -170,7 +171,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
{
if( bbox.Contains( pos2 ) )
{
if( TestPointInsidePolygon( curr_zone->m_FilledPolysList,
if( TestPointInsidePolygon( polysList,
indexstart, indexend,
pos2.x, pos2.y ) )
connected = true;
......
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