Commit b2a76062 authored by jean-pierre charras's avatar jean-pierre charras

All: use CPOLYGONS_LIST, a typedef of std::vector<CPolyPt> to handle a Corners Polygons List.

This is a starting point of some code enhancements relative to polygons in Pcbew and 3D viewer.
parent ea990230
......@@ -30,15 +30,8 @@
#ifndef _3D_CANVAS_H_
#define _3D_CANVAS_H_
#include <wxBasePcbFrame.h> // for m_auimanager member.
#include <layers_id_colors_and_visibility.h> // Layers id definitions
#include <PolyLine.h> // for CPolyPt
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include <wx/glcanvas.h>
#include <wxBasePcbFrame.h> // for m_auimanager member.
#ifdef __WXMAC__
# ifdef __DARWIN__
......@@ -53,10 +46,6 @@
#include <3d_struct.h>
class BOARD_DESIGN_SETTINGS;
class TRACK;
class TEXTE_PCB;
class DRAWSEGMENT;
class ZONE_CONTAINER;
class EDA_3D_FRAME;
class S3D_VERTEX;
class SEGVIA;
......
......@@ -23,7 +23,7 @@
/**
* @file 3d_draw.cpp
*/
*/
#include <fctsys.h>
#include <common.h>
......@@ -50,14 +50,14 @@
// Imported function:
extern void SetGLColor( EDA_COLOR_T color );
extern void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits );
extern void Set_Object_Data( std::vector<S3D_VERTEX>& aVertices, double aBiuTo3DUnits );
extern void CheckGLError();
/* returns true if aLayer should be displayed, false otherwise
/* returns true if aLayer should be displayed, false otherwise
*/
static bool Is3DLayerEnabled( LAYER_NUM aLayer );
/* returns the Z orientation parameter 1.0 or -1.0 for aLayer
/* returns the Z orientation parameter 1.0 or -1.0 for aLayer
* Z orientation is 1.0 for all layers but "back" layers:
* LAYER_N_BACK , ADHESIVE_N_BACK, SOLDERPASTE_N_BACK ), SILKSCREEN_N_BACK
* used to calculate the Z orientation parameter for glNormal3f
......@@ -69,8 +69,8 @@ static GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer );
* with a line thickness = aWidth
* Used only to draw pads outlines on silkscreen layers.
*/
static void BuildPadShapeThickOutlineAsPolygon( D_PAD * aPad,
std::vector <CPolyPt>& aCornerBuffer,
static void BuildPadShapeThickOutlineAsPolygon( D_PAD* aPad,
CPOLYGONS_LIST& aCornerBuffer,
int aWidth,
int aCircleToSegmentsCount,
double aCorrectionFactor )
......@@ -83,7 +83,7 @@ static void BuildPadShapeThickOutlineAsPolygon( D_PAD * aPad,
}
// For other shapes, draw polygon outlines
std::vector <CPolyPt> corners;
CPOLYGONS_LIST corners;
aPad->BuildPadShapePolygon( corners, wxSize( 0, 0 ),
aCircleToSegmentsCount, aCorrectionFactor );
......@@ -97,6 +97,7 @@ static void BuildPadShapeThickOutlineAsPolygon( D_PAD * aPad,
}
}
void EDA_3D_CANVAS::Redraw( bool finish )
{
// SwapBuffer requires the window to be shown before calling
......@@ -145,6 +146,7 @@ void EDA_3D_CANVAS::Redraw( bool finish )
SwapBuffers();
}
void EDA_3D_CANVAS::BuildBoard3DView()
{
PCB_BASE_FRAME* pcbframe = Parent()->Parent();
......@@ -152,18 +154,19 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Number of segments to draw a circle using segments
const int segcountforcircle = 16;
double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle*2) );
double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle * 2) );
const int segcountLowQuality = 12; // segments to draw a circle with low quality
// to reduce time calculations
// for holes and items which do not need
// a fine representation
double correctionFactorLQ = 1.0 / cos( M_PI / (segcountLowQuality*2) );
std::vector <CPolyPt> bufferPolys;
double correctionFactorLQ = 1.0 / cos( M_PI / (segcountLowQuality * 2) );
CPOLYGONS_LIST bufferPolys;
bufferPolys.reserve( 200000 ); // Reserve for large board (tracks mainly)
std::vector <CPolyPt> bufferZonesPolys;
CPOLYGONS_LIST bufferZonesPolys;
bufferPolys.reserve( 500000 ); // Reserve for large board ( copper zones mainly )
std::vector <CPolyPt> currLayerHoles; // Contains holes for the current layer
std::vector <CPolyPt> allLayerHoles; // Contains through holes, calculated only once
CPOLYGONS_LIST currLayerHoles; // Contains holes for the current layer
CPOLYGONS_LIST allLayerHoles; // Contains through holes, calculated only once
allLayerHoles.reserve( 20000 );
bool throughHolesListBuilt = false; // flag to build the through hole polygon list only once
bool hightQualityMode = false;
......@@ -171,13 +174,13 @@ void EDA_3D_CANVAS::BuildBoard3DView()
for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER;
layer++ )
{
if( layer != LAST_COPPER_LAYER &&
layer >= g_Parm_3D_Visu.m_CopperLayersCount )
if( layer != LAST_COPPER_LAYER
&& layer >= g_Parm_3D_Visu.m_CopperLayersCount )
continue;
if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
continue;
bufferPolys.clear();
bufferZonesPolys.clear();
currLayerHoles.clear();
......@@ -185,7 +188,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Draw tracks:
for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() )
{
if( !track->IsOnLayer(layer) )
if( !track->IsOnLayer( layer ) )
continue;
track->TransformShapeWithClearanceToPolygon( bufferPolys,
......@@ -199,11 +202,12 @@ void EDA_3D_CANVAS::BuildBoard3DView()
int holediameter = track->GetDrillValue();
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
int hole_outer_radius = (holediameter + thickness) / 2;
if( shape != VIA_THROUGH )
TransformCircleToPolygon( currLayerHoles,
track->GetStart(), hole_outer_radius,
segcountLowQuality );
else if( ! throughHolesListBuilt )
else if( !throughHolesListBuilt )
TransformCircleToPolygon( allLayerHoles,
track->GetStart(), hole_outer_radius,
segcountLowQuality );
......@@ -214,16 +218,23 @@ void EDA_3D_CANVAS::BuildBoard3DView()
for( MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() )
{
module->TransformPadsShapesWithClearanceToPolygon( layer,
bufferPolys, 0, segcountforcircle, correctionFactor );
bufferPolys,
0,
segcountforcircle,
correctionFactor );
// Micro-wave modukes may have items on copper layers
module->TransformGraphicShapesWithClearanceToPolygonSet( layer,
bufferPolys, 0, segcountforcircle, correctionFactor );
bufferPolys,
0,
segcountforcircle,
correctionFactor );
// Add pad hole, if any
if( ! throughHolesListBuilt )
if( !throughHolesListBuilt )
{
D_PAD* pad = module->Pads();
for( ; pad != NULL; pad = pad->Next() )
pad->BuildPadDrillShapePolygon( allLayerHoles, 0,
segcountLowQuality );
......@@ -235,7 +246,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
{
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER * zone = pcb->GetArea( ii );
ZONE_CONTAINER* zone = pcb->GetArea( ii );
LAYER_NUM zonelayer = zone->GetLayer();
if( zonelayer == layer )
......@@ -248,20 +259,20 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// draw graphic items
for( BOARD_ITEM* item = pcb->m_Drawings; item; item = item->Next() )
{
if( ! item->IsOnLayer( layer ) )
if( !item->IsOnLayer( layer ) )
continue;
switch( item->Type() )
{
case PCB_LINE_T:
((DRAWSEGMENT*) item)->TransformShapeWithClearanceToPolygon(
( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
bufferPolys, 0,
segcountforcircle,
correctionFactor );
break;
case PCB_TEXT_T:
((TEXTE_PCB*) item)->TransformShapeWithClearanceToPolygonSet(
( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
bufferPolys, 0, segcountforcircle, correctionFactor );
break;
......@@ -283,6 +294,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Add holes in polygon list
currLayerHoles.insert( currLayerHoles.begin(),
allLayerHoles.begin(), allLayerHoles.end() );
if( currLayerHoles.size() > 0 )
AddPolygonCornersToKiPolygonList( currLayerHoles, polysetHoles );
......@@ -301,6 +313,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness,
g_Parm_3D_Visu.m_BiuTo3Dunits );
if( bufferZonesPolys.size() )
Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos,
thickness,
......@@ -313,8 +326,9 @@ void EDA_3D_CANVAS::BuildBoard3DView()
for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() )
{
if( track->Type() == PCB_VIA_T )
Draw3DViaHole( (SEGVIA *) track );
Draw3DViaHole( (SEGVIA*) track );
}
// Draw pads holes (vertical cylinders)
for( MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() )
{
......@@ -326,29 +340,30 @@ void EDA_3D_CANVAS::BuildBoard3DView()
for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER;
layer++ )
{
if( ! Is3DLayerEnabled( layer ) )
if( !Is3DLayerEnabled( layer ) )
continue;
if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
continue;
bufferPolys.clear();
for( BOARD_ITEM* item = pcb->m_Drawings; item; item = item->Next() )
{
if( ! item->IsOnLayer( layer ) )
if( !item->IsOnLayer( layer ) )
continue;
switch( item->Type() )
{
case PCB_LINE_T:
((DRAWSEGMENT*) item)->TransformShapeWithClearanceToPolygon(
( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
bufferPolys, 0,
segcountforcircle,
correctionFactor );
break;
case PCB_TEXT_T:
((TEXTE_PCB*) item)->TransformShapeWithClearanceToPolygonSet(
( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
bufferPolys, 0, segcountforcircle, correctionFactor );
break;
......@@ -368,6 +383,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
{
if( !pad->IsOnLayer( layer ) )
continue;
BuildPadShapeThickOutlineAsPolygon( pad, bufferPolys,
linewidth,
segcountforcircle, correctionFactor );
......@@ -375,10 +391,16 @@ void EDA_3D_CANVAS::BuildBoard3DView()
}
else
module->TransformPadsShapesWithClearanceToPolygon( layer,
bufferPolys, 0, segcountforcircle, correctionFactor );
bufferPolys,
0,
segcountforcircle,
correctionFactor );
module->TransformGraphicShapesWithClearanceToPolygonSet( layer,
bufferPolys, 0, segcountforcircle, correctionFactor );
bufferPolys,
0,
segcountforcircle,
correctionFactor );
}
// bufferPolys contains polygons to merge. Many overlaps .
......@@ -395,6 +417,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
if( layer == EDGE_N )
{
thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT )
......@@ -417,6 +440,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
module->ReadAndInsert3DComponentShape( this );
}
GLuint EDA_3D_CANVAS::CreateDrawGL_List()
{
PCB_BASE_FRAME* pcbframe = Parent()->Parent();
......@@ -434,7 +458,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
// draw axis
if (g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS])
if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS] )
{
glEnable( GL_COLOR_MATERIAL );
SetGLColor( WHITE );
......@@ -457,7 +481,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
// Draw Board:
// For testing purpose only display calculation time to generate 3D data
//#define PRINT_CALCULATION_TIME
// #define PRINT_CALCULATION_TIME
#ifdef PRINT_CALCULATION_TIME
unsigned strtime = GetRunningMicroSecs();
......@@ -477,7 +501,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
#ifdef PRINT_CALCULATION_TIME
unsigned endtime = GetRunningMicroSecs();
wxString msg;
msg.Printf( "Built data %.1f ms", (double)(endtime-strtime)/1000 );
msg.Printf( "Built data %.1f ms", (double) (endtime - strtime) / 1000 );
Parent()->SetStatusText( msg, 0 );
#endif
......@@ -504,10 +528,10 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) );
// Grid limits, in 3D units
double xmin = (brd_center_pos.x - xsize/2) * scale;
double xmax = (brd_center_pos.x + xsize/2) * scale;
double ymin = (brd_center_pos.y - ysize/2) * scale;
double ymax = (brd_center_pos.y + ysize/2) * scale;
double xmin = (brd_center_pos.x - xsize / 2) * scale;
double xmax = (brd_center_pos.x + xsize / 2) * scale;
double ymin = (brd_center_pos.y - ysize / 2) * scale;
double ymax = (brd_center_pos.y + ysize / 2) * scale;
double zmin = Millimeter2iu( -50 ) * scale;
double zmax = Millimeter2iu( 100 ) * scale;
......@@ -521,38 +545,39 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
int delta = KiROUND( ii * aGriSizeMM * IU_PER_MM );
if( delta <= xsize/2 ) // Draw grid lines parallel to X axis
if( delta <= xsize / 2 ) // Draw grid lines parallel to X axis
{
glBegin(GL_LINES);
glBegin( GL_LINES );
glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
glEnd();
if( ii != 0 )
{
glBegin(GL_LINES);
glBegin( GL_LINES );
glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
glEnd();
}
}
if( delta <= ysize/2 ) // Draw grid lines parallel to Y axis
if( delta <= ysize / 2 ) // Draw grid lines parallel to Y axis
{
glBegin(GL_LINES);
glBegin( GL_LINES );
glVertex3f( xmin, -(brd_center_pos.y + delta) * scale, zpos );
glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos );
glEnd();
if( ii != 0 )
{
glBegin(GL_LINES);
glBegin( GL_LINES );
glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos );
glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos );
glEnd();
}
}
if( ( delta > ysize/2 ) && ( delta > xsize/2 ) )
if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
break;
}
......@@ -569,20 +594,20 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
double delta = ii * aGriSizeMM * IU_PER_MM;
glBegin(GL_LINES);
glBegin( GL_LINES );
glVertex3f( (brd_center_pos.x + delta) * scale, -brd_center_pos.y * scale, zmin );
glVertex3f( (brd_center_pos.x + delta) * scale, -brd_center_pos.y * scale, zmax );
glEnd();
if( ii != 0 )
{
glBegin(GL_LINES);
glBegin( GL_LINES );
glVertex3f( (brd_center_pos.x - delta) * scale, -brd_center_pos.y * scale, zmin );
glVertex3f( (brd_center_pos.x - delta) * scale, -brd_center_pos.y * scale, zmax );
glEnd();
}
if( delta > xsize/2 )
if( delta > xsize / 2 )
break;
}
......@@ -597,18 +622,20 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
double delta = ii * aGriSizeMM * IU_PER_MM * scale;
if( delta <= zmax )
{ // Draw grid lines on Z axis (positive Z axis coordinates)
glBegin(GL_LINES);
glVertex3f(xmin, -brd_center_pos.y * scale, delta);
glVertex3f(xmax, -brd_center_pos.y * scale, delta);
{
// Draw grid lines on Z axis (positive Z axis coordinates)
glBegin( GL_LINES );
glVertex3f( xmin, -brd_center_pos.y * scale, delta );
glVertex3f( xmax, -brd_center_pos.y * scale, delta );
glEnd();
}
if( delta <= -zmin && ( ii != 0 ) )
{ // Draw grid lines on Z axis (negative Z axis coordinates)
glBegin(GL_LINES);
glVertex3f(xmin, -brd_center_pos.y * scale, -delta);
glVertex3f(xmax, -brd_center_pos.y * scale, -delta);
{
// Draw grid lines on Z axis (negative Z axis coordinates)
glBegin( GL_LINES );
glVertex3f( xmin, -brd_center_pos.y * scale, -delta );
glVertex3f( xmax, -brd_center_pos.y * scale, -delta );
glEnd();
}
......@@ -617,7 +644,8 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
}
}
void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA * aVia )
void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA* aVia )
{
LAYER_NUM top_layer, bottom_layer;
int inner_radius = aVia->GetDrillValue() / 2;
......@@ -628,11 +656,11 @@ void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA * aVia )
// Drawing via hole:
EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + aVia->GetShape() );
SetGLColor( color );
int height = g_Parm_3D_Visu.GetLayerZcoordBIU(top_layer) -
int height = g_Parm_3D_Visu.GetLayerZcoordBIU( top_layer ) -
g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) - thickness;
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(bottom_layer) + thickness/2;
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) + thickness / 2;
Draw3D_ZaxisCylinder( aVia->GetStart(), inner_radius + thickness/2, height,
Draw3D_ZaxisCylinder( aVia->GetStart(), inner_radius + thickness / 2, height,
thickness, zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
}
......@@ -678,23 +706,23 @@ void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas )
// Draw 3D pads.
void EDA_3D_CANVAS::Draw3DPadHole( D_PAD * aPad )
void EDA_3D_CANVAS::Draw3DPadHole( D_PAD* aPad )
{
// Draw the pad hole
wxSize drillsize = aPad->GetDrillSize();
bool hasHole = drillsize.x && drillsize.y;
if( ! hasHole )
if( !hasHole )
return;
// Store here the points to approximate hole by segments
std::vector <CPolyPt> holecornersBuffer;
CPOLYGONS_LIST holecornersBuffer;
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
int height = g_Parm_3D_Visu.GetLayerZcoordBIU(LAYER_N_FRONT) -
g_Parm_3D_Visu.GetLayerZcoordBIU(LAYER_N_BACK);
int height = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT ) -
g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
SetGLColor( DARKGRAY );
int holeZpoz = g_Parm_3D_Visu.GetLayerZcoordBIU(LAYER_N_BACK) + thickness/2;
int holeZpoz = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK ) + thickness / 2;
int holeHeight = height - thickness;
if( drillsize.x == drillsize.y ) // usual round hole
......@@ -731,13 +759,14 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD * aPad )
}
}
bool Is3DLayerEnabled( LAYER_NUM aLayer )
{
int flg;
// see if layer needs to be shown
// check the flags
switch (aLayer)
switch( aLayer )
{
case DRAW_N:
flg = g_Parm_3D_Visu.FL_DRAWINGS;
......
......@@ -41,7 +41,7 @@
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList,
void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits );
/** draw the solid polygon found in aPolysList
......@@ -55,7 +55,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysLi
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
void Draw3D_SolidHorizontalPolygonWithHoles( const std::vector<CPolyPt>& aPolysList,
void Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits );
/** draw a thick segment using 3D primitives, in a XY plane
......
......@@ -31,8 +31,6 @@
#define __3D_VIEWER_H__
#include <wxBasePcbFrame.h> // for m_auimanager member.
#include <layers_id_colors_and_visibility.h> // Layers id definitions
#include <PolyLine.h> // fot CPolyPt
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
......
......@@ -36,13 +36,13 @@
* We are using a lots polygons in calculations.
* and we are using 2 descriptions,
* one easy to use with boost::polygon (KI_POLYGON_SET)
* one easy to use in zones and in draw functions (std::vector<CPolyPt>)
* one easy to use in zones and in draw functions (CPOLYGONS_LIST)
* Copy polygons from a KI_POLYGON_SET set of polygons to
* a std::vector<CPolyPt> polygon list
* a CPOLYGONS_LIST polygon list
* Therefore we need conversion functions between these 2 descriptions
*/
void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList,
std::vector<CPolyPt>& aPolysList )
CPOLYGONS_LIST& aPolysList )
{
for( unsigned ii = 0; ii < aKiPolyList.size(); ii++ )
{
......@@ -64,14 +64,15 @@ void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList,
}
}
/**
* Helper function AddPolygonCornersToKiPolygonList
* This function adds a KI_POLYGON_SET description to a
* std::vector<CPolyPt> description
* CPOLYGONS_LIST description
* @param aCornersBuffer = source (set of polygons using CPolyPt corners descr)
* @param aPolysList = destination (set of polygons)
*/
void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer,
KI_POLYGON_SET& aKiPolyList )
{
std::vector<KI_POLY_POINT> cornerslist;
......@@ -79,6 +80,7 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
// Count the number of polygons in aCornersBuffer
int polycount = 0;
for( unsigned ii = 0; ii < corners_count; ii++ )
{
if( aCornersBuffer[ii].end_contour )
......@@ -93,6 +95,7 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
cornerslist.clear();
unsigned ii;
for( ii = icnt; ii < aCornersBuffer.size(); ii++ )
{
cornerslist.push_back( KI_POLY_POINT( aCornersBuffer[ii].x, aCornersBuffer[ii].y ) );
......@@ -118,7 +121,7 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
* Note: the polygon is inside the circle, so if you want to have the polygon
* outside the circle, you should give aRadius calculated with a corrrection factor
*/
void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformCircleToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCenter, int aRadius,
int aCircleToSegmentsCount )
{
......@@ -153,7 +156,7 @@ void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* Note: the polygon is inside the arc ends, so if you want to have the polygon
* outside the circle, you should give aStart and aEnd calculated with a correction factor
*/
void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformRoundedEndsSegmentToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aStart, wxPoint aEnd,
int aCircleToSegmentsCount,
int aWidth )
......@@ -233,7 +236,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the line
*/
void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformArcToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, wxPoint aStart, int aArcAngle,
int aCircleToSegmentsCount, int aWidth )
{
......@@ -272,6 +275,7 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
aCircleToSegmentsCount, aWidth );
}
/**
* Function TransformRingToPolygon
* Creates a polygon from a ring
......@@ -282,7 +286,7 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the ring
*/
void TransformRingToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformRingToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, int aRadius,
int aCircleToSegmentsCount, int aWidth )
{
......
......@@ -40,26 +40,26 @@
* We are using a lots polygons in calculations.
* and we are using 2 descriptions,
* one easy to use with boost::polygon (KI_POLYGON_SET)
* one easy to use in zones and in draw functions (std::vector<CPolyPt>)
* one easy to use in zones and in draw functions (CPOLYGONS_LIST)
* Copy polygons from a KI_POLYGON_SET set of polygons to
* a std::vector<CPolyPt> polygon list
* a CPOLYGONS_LIST corner polygon list
* Therefore we need conversion functions between these 2 descriptions
* This function converts a KI_POLYGON_SET description to a
* std::vector<CPolyPt> description
* CPOLYGONS_LIST description
* @param aKiPolyList = source (set of polygons)
* @param aPolysList = destination (set of polygons using CPolyPt corners descr)
*/
void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList,
std::vector<CPolyPt>& aPolysList );
CPOLYGONS_LIST& aPolysList );
/**
* Helper function AddPolygonCornersToKiPolygonList
* This function adds a KI_POLYGON_SET description to a
* std::vector<CPolyPt> description
* CPOLYGONS_LIST description
* @param aCornersBuffer = source (set of polygons using CPolyPt corners descr)
* @param aPolysList = destination (set of polygons)
*/
void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer,
KI_POLYGON_SET& aKiPolyList );
/**
......@@ -72,7 +72,7 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
* Note: the polygon is inside the circle, so if you want to have the polygon
* outside the circle, you should give aRadius calculated with a correction factor
*/
void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformCircleToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCenter, int aRadius,
int aCircleToSegmentsCount );
......@@ -88,7 +88,7 @@ void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* Note: the polygon is inside the arc ends, so if you want to have the polygon
* outside the circle, you should give aStart and aEnd calculated with a correction factor
*/
void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformRoundedEndsSegmentToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aStart, wxPoint aEnd,
int aCircleToSegmentsCount,
int aWidth );
......@@ -105,7 +105,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the line
*/
void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformArcToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, wxPoint aStart, int aArcAngle,
int aCircleToSegmentsCount, int aWidth );
......@@ -119,7 +119,7 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the ring
*/
void TransformRingToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformRingToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, int aRadius,
int aCircleToSegmentsCount, int aWidth );
......
......@@ -35,7 +35,7 @@
* initial radius * aCorrectionFactor
*/
void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
double aCorrectionFactor )
......@@ -86,7 +86,7 @@ void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
*/
void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
double aCorrectionFactor )
......@@ -166,12 +166,12 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
* keep arc radius when approximated by segments
*/
void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aCircleToSegmentsCount,
double aCorrectionFactor )
{
unsigned cornerscount = GetFilledPolysList().size();
std::vector <CPolyPt> polygonslist;
CPOLYGONS_LIST polygonslist;
if( cornerscount == 0 )
return;
......@@ -217,7 +217,7 @@ void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(
* @param aClearanceValue = the clearance around the pad
*/
void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue ) const
{
if( GetText().Length() == 0 )
......@@ -251,7 +251,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
* Convert the text shape to a set of polygons (one by segment)
* Used in filling zones calculations and 3D view
* Circles and arcs are approximated by segments
* aCornerBuffer = vector <CPolyPt> to store the polygon corners
* aCornerBuffer = CPOLYGONS_LIST to store the polygon corners
* aClearanceValue = the clearance around the text
* aCircleToSegmentsCount = the number of segments to approximate a circle
* aCorrectionFactor = the correction to apply to circles radius to keep
......@@ -263,7 +263,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
// so we cannot send them as arguments.
int s_textWidth;
int s_textCircle2SegmentCount;
std::vector <CPolyPt>* s_cornerBuffer;
CPOLYGONS_LIST* s_cornerBuffer;
// This is a call back function, used by DrawGraphicText to draw the 3D text shape:
static void addTextSegmToPoly( int x0, int y0, int xf, int yf )
......@@ -274,7 +274,7 @@ static void addTextSegmToPoly( int x0, int y0, int xf, int yf )
}
void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const
......@@ -334,7 +334,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
* clearance when the circle is approxiamted by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const
......@@ -375,7 +375,7 @@ void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& a
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TRACK:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCornerBuffer,
void TRACK:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const
......@@ -404,14 +404,14 @@ void TRACK:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
* Convert the pad shape to a closed polygon
* Used in filling zones calculations and 3D view generation
* Circles and arcs are approximated by segments
* aCornerBuffer = a vector < CPolyPt> to store the polygon corners
* aCornerBuffer = a CPOLYGONS_LIST to store the polygon corners
* aClearanceValue = the clearance around the pad
* aCircleToSegmentsCount = the number of segments to approximate a circle
* aCorrectionFactor = the correction to apply to circles radius to keep
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCornerBuffer,
void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const
......@@ -547,7 +547,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
* Note: for Round and oval pads this function is equivalent to
* TransformShapeWithClearanceToPolygon, but not for other shapes
*/
void D_PAD::BuildPadShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
void D_PAD::BuildPadShapePolygon( CPOLYGONS_LIST& aCornerBuffer,
wxSize aInflateValue, int aSegmentsPerCircle,
double aCorrectionFactor ) const
{
......@@ -584,7 +584,7 @@ void D_PAD::BuildPadShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
* depending on shape pad hole and orientation
* return false if the pad has no hole, true otherwise
*/
bool D_PAD::BuildPadDrillShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
bool D_PAD::BuildPadDrillShapePolygon( CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue, int aSegmentsPerCircle ) const
{
wxSize drillsize = GetDrillSize();
......@@ -658,7 +658,7 @@ bool D_PAD::BuildPadDrillShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
* and are used in microwave applications and they *DO NOT* have a thermal relief that
* change the shape by creating stubs and destroy their properties.
*/
void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
D_PAD& aPad,
int aThermalGap,
int aCopperThickness,
......
......@@ -211,7 +211,7 @@ public:
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const;
......
......@@ -37,6 +37,7 @@
#include <class_board_item.h>
#include <class_text_mod.h>
#include <PolyLine.h>
#include "zones.h"
class LINE_READER;
......@@ -46,7 +47,6 @@ class EDA_DRAW_PANEL;
class D_PAD;
class BOARD;
class MSG_PANEL_ITEM;
class CPolyPt;
/**
......@@ -268,7 +268,7 @@ public:
* initial radius * aCorrectionFactor
*/
void TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
double aCorrectionFactor );
......@@ -292,7 +292,7 @@ public:
*/
void TransformGraphicShapesWithClearanceToPolygonSet(
LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
double aCorrectionFactor );
......
......@@ -220,7 +220,7 @@ public:
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const;;
......@@ -317,7 +317,7 @@ public:
* @param aCorrectionFactor = the correction to apply to circles radius to keep
* the pad size when the circle is approximated by segments
*/
void BuildPadShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
void BuildPadShapePolygon( CPOLYGONS_LIST& aCornerBuffer,
wxSize aInflateValue, int aSegmentsPerCircle,
double aCorrectionFactor ) const;
......@@ -332,7 +332,7 @@ public:
* (used for round and oblong shapes only(16 to 32 is a good value)
* @return false if the pad has no hole, true otherwise
*/
bool BuildPadDrillShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
bool BuildPadDrillShapePolygon( CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue, int aSegmentsPerCircle ) const;
/**
......
......@@ -93,7 +93,7 @@ public:
* to the real clearance value (usually near from 1.0)
*/
void TransformBoundingBoxWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue ) const;
/**
......@@ -108,7 +108,7 @@ public:
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygonSet( std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygonSet( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const;
......
......@@ -175,7 +175,7 @@ public:
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor ) const;
......
......@@ -274,7 +274,7 @@ public:
* @param aCorrectionFactor = the correction to apply to arcs radius to roughly
* keep arc radius when approximated by segments
*/
void TransformSolidAreasShapesToPolygonSet( std::vector <CPolyPt>& aCornerBuffer,
void TransformSolidAreasShapesToPolygonSet( CPOLYGONS_LIST& aCornerBuffer,
int aCircleToSegmentsCount,
double aCorrectionFactor );
/**
......@@ -296,7 +296,7 @@ public:
* This function calls AddClearanceAreasPolygonsToPolysList()
* to add holes for pads and tracks and other items not in net.
*/
bool BuildFilledSolidAreasPolygons( BOARD* aPcb, std::vector <CPolyPt>* aCornerBuffer = NULL );
bool BuildFilledSolidAreasPolygons( BOARD* aPcb, CPOLYGONS_LIST* aCornerBuffer = NULL );
/**
* Function CopyPolygonsFromKiPolygonListToFilledPolysList
......@@ -339,7 +339,7 @@ public:
* @param aAddClearance = true to add a clearance area to the polygon
* false to create the outline polygon.
*/
void TransformOutlinesShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
void TransformOutlinesShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue,
bool aAddClearance );
/**
......@@ -506,7 +506,7 @@ public:
* returns a reference to the list of filled polygons.
* @return Reference to the list of filled polygons.
*/
const std::vector<CPolyPt>& GetFilledPolysList() const
const CPOLYGONS_LIST& GetFilledPolysList() const
{
return m_FilledPolysList;
}
......@@ -515,7 +515,7 @@ public:
* Function AddFilledPolysList
* sets the list of filled polygons.
*/
void AddFilledPolysList( std::vector<CPolyPt>& aPolysList )
void AddFilledPolysList( CPOLYGONS_LIST& aPolysList )
{
m_FilledPolysList = aPolysList;
}
......@@ -549,7 +549,7 @@ public:
void AddPolygon( std::vector< wxPoint >& aPolygon );
void AddFilledPolygon( std::vector< CPolyPt >& aPolygon )
void AddFilledPolygon( CPOLYGONS_LIST& aPolygon )
{
m_FilledPolysList.insert( m_FilledPolysList.end(), aPolygon.begin(), aPolygon.end() );
}
......@@ -652,7 +652,7 @@ private:
* 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;
CPOLYGONS_LIST m_FilledPolysList;
};
......
......@@ -1395,7 +1395,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
m_out->Print( 0, ")\n" );
const std::vector< CPolyPt >& cv = aZone->Outline()->m_CornersList;
const CPOLYGONS_LIST& cv = aZone->Outline()->m_CornersList;
int newLine = 0;
if( cv.size() )
......@@ -1403,7 +1403,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(polygon\n");
m_out->Print( aNestLevel+2, "(pts\n" );
for( std::vector< CPolyPt >::const_iterator it = cv.begin(); it != cv.end(); ++it )
for( CPOLYGONS_LIST::const_iterator it = cv.begin(); it != cv.end(); ++it )
{
if( newLine == 0 )
m_out->Print( aNestLevel+3, "(xy %s %s)",
......@@ -1443,7 +1443,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
}
// Save the PolysList
const std::vector< CPolyPt >& fv = aZone->GetFilledPolysList();
const CPOLYGONS_LIST& fv = aZone->GetFilledPolysList();
newLine = 0;
if( fv.size() )
......@@ -1451,7 +1451,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(filled_polygon\n" );
m_out->Print( aNestLevel+2, "(pts\n" );
for( std::vector< CPolyPt >::const_iterator it = fv.begin(); it != fv.end(); ++it )
for( CPOLYGONS_LIST::const_iterator it = fv.begin(); it != fv.end(); ++it )
{
if( newLine == 0 )
m_out->Print( aNestLevel+3, "(xy %s %s)",
......
......@@ -2346,7 +2346,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;
CPOLYGONS_LIST polysList;
while( ( line = READLINE( m_reader ) ) != NULL )
{
......@@ -3690,12 +3690,10 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
me->GetCornerSmoothingType(),
fmtBIU( me->GetCornerRadius() ).c_str() );
typedef std::vector< CPolyPt > CPOLY_PTS;
// Save the corner list
const CPOLY_PTS& cv = me->Outline()->m_CornersList;
const CPOLYGONS_LIST& cv = me->Outline()->m_CornersList;
for( CPOLY_PTS::const_iterator it = cv.begin(); it != cv.end(); ++it )
for( CPOLYGONS_LIST::const_iterator it = cv.begin(); it != cv.end(); ++it )
{
fprintf( m_fp, "ZCorner %s %d\n",
fmtBIUPair( it->x, it->y ).c_str(),
......@@ -3703,12 +3701,12 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
}
// Save the PolysList
const CPOLY_PTS& fv = me->GetFilledPolysList();
const CPOLYGONS_LIST& fv = me->GetFilledPolysList();
if( fv.size() )
{
fprintf( m_fp, "$POLYSCORNERS\n" );
for( CPOLY_PTS::const_iterator it = fv.begin(); it != fv.end(); ++it )
for( CPOLYGONS_LIST::const_iterator it = fv.begin(); it != fv.end(); ++it )
{
fprintf( m_fp, "%s %d %d\n",
fmtBIUPair( it->x, it->y ).c_str(),
......
......@@ -2371,7 +2371,7 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR )
T token;
// bigger scope since each filled_polygon is concatenated in here
std::vector< CPolyPt > pts;
CPOLYGONS_LIST pts;
auto_ptr< ZONE_CONTAINER > zone( new ZONE_CONTAINER( m_board ) );
......
......@@ -53,7 +53,7 @@
#include <pcbplot.h>
// Imported function
extern void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
extern void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer,
KI_POLYGON_SET& aKiPolyList );
// Local
/* Plot a solder mask layer.
......@@ -506,8 +506,8 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter,
// This extra margin is used to merge too close shapes
// (distance < aMinThickness), and will be removed when creating
// the actual shapes
std::vector <CPolyPt> bufferPolys; // Contains shapes to plot
std::vector <CPolyPt> initialPolys; // Contains exact shapes to plot
CPOLYGONS_LIST bufferPolys; // Contains shapes to plot
CPOLYGONS_LIST initialPolys; // Contains exact shapes to plot
/* calculates the coeff to compensate radius reduction of holes clearance
* due to the segment approx ( 1 /cos( PI/circleToSegmentsCount )
......
......@@ -506,7 +506,7 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
*/
void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone )
{
std::vector<CPolyPt> polysList = aZone->GetFilledPolysList();
const CPOLYGONS_LIST& polysList = aZone->GetFilledPolysList();
unsigned imax = polysList.size();
if( imax == 0 ) // Nothing to draw
......@@ -526,10 +526,10 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone )
*/
for( unsigned ic = 0; ic < imax; ic++ )
{
CPolyPt* corner = &polysList[ic];
cornerList.push_back( wxPoint( corner->x, corner->y) );
const CPolyPt& corner = polysList[ic];
cornerList.push_back( wxPoint( corner.x, corner.y) );
if( corner->end_contour ) // Plot the current filled area outline
if( corner.end_contour ) // Plot the current filled area outline
{
// First, close the outline
if( cornerList[0] != cornerList[cornerList.size() - 1] )
......
......@@ -55,7 +55,7 @@
*/
bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb,
std::vector <CPolyPt>* aCornerBuffer )
CPOLYGONS_LIST* aCornerBuffer )
{
if( aCornerBuffer == NULL )
m_FilledPolysList.clear();
......
......@@ -64,7 +64,7 @@
#include <convert_basic_shapes_to_polygon.h>
extern void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffer,
extern void BuildUnconnectedThermalStubsPolygonList( CPOLYGONS_LIST& aCornerBuffer,
BOARD* aPcb, ZONE_CONTAINER* aZone,
double aArcCorrection,
int aRoundPadThermalRotation);
......@@ -72,7 +72,7 @@ extern void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCorn
extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb,
ZONE_CONTAINER* aZone_container );
extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
extern void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
D_PAD& aPad,
int aThermalGap,
int aCopperThickness,
......@@ -187,7 +187,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
int item_clearance;
// static to avoid unnecessary memory allocation when filling many zones.
static std::vector <CPolyPt> cornerBufferPolysToSubstract;
static CPOLYGONS_LIST cornerBufferPolysToSubstract;
cornerBufferPolysToSubstract.clear();
/* Use a dummy pad to calculate hole clerance when a pad is not on all copper layers
......
......@@ -48,11 +48,11 @@
* false to create the outline polygon.
*/
void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer,
CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue, bool aAddClearance )
{
// Creates the zone outlines polygon (with linked holes if any)
std::vector <CPolyPt> zoneOutines;
CPOLYGONS_LIST zoneOutines;
BuildFilledSolidAreasPolygons( NULL, &zoneOutines );
// add clearance to outline
......@@ -119,14 +119,14 @@ void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon(
* Function BuildUnconnectedThermalStubsPolygonList
* Creates a set of polygons corresponding to stubs created by thermal shapes on pads
* which are not connected to a zone (dangling bridges)
* @param aCornerBuffer = a std::vector<CPolyPt> where to store polygons
* @param aCornerBuffer = a CPOLYGONS_LIST where to store polygons
* @param aPcb = the board.
* @param aZone = a pointer to the ZONE_CONTAINER to examine.
* @param aArcCorrection = a pointer to the ZONE_CONTAINER to examine.
* @param aRoundPadThermalRotation = the rotation in 1.0 degree for thermal stubs in round pads
*/
void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffer,
void BuildUnconnectedThermalStubsPolygonList( CPOLYGONS_LIST& aCornerBuffer,
BOARD* aPcb,
ZONE_CONTAINER* aZone,
double aArcCorrection,
......
......@@ -143,7 +143,7 @@ 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;
std::vector<CPolyPt> polysList = curr_zone->GetFilledPolysList();
const CPOLYGONS_LIST& polysList = curr_zone->GetFilledPolysList();
for( indexend = 0; indexend < polysList.size(); indexend++ )
{
// end of a filled sub-area found
......
......@@ -1204,7 +1204,7 @@ int CPolyLine::Distance( const wxPoint& aPoint )
* @param aPolysList = the list of corners of contours
* @param aPolygoneWithHole = a KI_POLYGON_WITH_HOLES to populate
*/
void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
void CopyPolysListToKiPolygonWithHole( const CPOLYGONS_LIST& aPolysList,
KI_POLYGON_WITH_HOLES& aPolygoneWithHole )
{
unsigned corners_count = aPolysList.size();
......@@ -1261,8 +1261,8 @@ void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
* @param aPolysListWithHoles = the list of corners of contours (haing holes
* @param aOnePolyList = a polygon with no holes
*/
void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysListWithHoles,
std::vector<CPolyPt>& aOnePolyList )
void ConvertPolysListWithHolesToOnePolygon( const CPOLYGONS_LIST& aPolysListWithHoles,
CPOLYGONS_LIST& aOnePolyList )
{
unsigned corners_count = aPolysListWithHoles.size();
......@@ -1338,9 +1338,7 @@ void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysL
aOnePolyList.push_back( corner );
}
corner.end_contour = true;
aOnePolyList.pop_back();
aOnePolyList.push_back( corner );
aOnePolyList.back().end_contour = true;
}
/**
......
......@@ -76,6 +76,14 @@ public:
{ return (x != cpt2.x) || (y != cpt2.y) || (end_contour != cpt2.end_contour); }
};
/**
* CPOLYGONS_LIST handle a list of contours.
* Each contour is a polygon, i.e. a list of corners.
* Each corner is a CPolyPt item.
* The last cornet of each contour has its end_contour member = true
*/
typedef std::vector<CPolyPt> CPOLYGONS_LIST;
class CPolyLine
{
......@@ -262,7 +270,7 @@ private:
int m_utility; // a flag used in some calculations
public:
std::vector <CPolyPt> m_CornersList; // array of points for corners
CPOLYGONS_LIST m_CornersList; // array of points for corners
std::vector <CSegment> m_HatchLines; // hatch lines showing the polygon area
};
......@@ -273,7 +281,7 @@ public:
* @param aPolysList = the list of corners of contours
* @param aPolygoneWithHole = a KI_POLYGON_WITH_HOLES to populate
*/
void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
void CopyPolysListToKiPolygonWithHole( const CPOLYGONS_LIST& aPolysList,
KI_POLYGON_WITH_HOLES& aPolygoneWithHole );
......@@ -286,7 +294,7 @@ void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
* @param aPolysListWithHoles = the list of corners of contours (haing holes
* @param aOnePolyList = a polygon with no holes
*/
void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysListWithHoles,
std::vector<CPolyPt>& aOnePolyList );
void ConvertPolysListWithHolesToOnePolygon( const CPOLYGONS_LIST& aPolysListWithHoles,
CPOLYGONS_LIST& aOnePolyList );
#endif // #ifndef POLYLINE_H
......@@ -26,7 +26,7 @@
#define OUTSIDE false
#define INSIDE true
bool TestPointInsidePolygon( std::vector <CPolyPt> aPolysList,
bool TestPointInsidePolygon( CPOLYGONS_LIST aPolysList,
int aIdxstart,
int aIdxend,
int aRefx,
......
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