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 @@ ...@@ -30,15 +30,8 @@
#ifndef _3D_CANVAS_H_ #ifndef _3D_CANVAS_H_
#define _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 <wx/glcanvas.h>
#include <wxBasePcbFrame.h> // for m_auimanager member.
#ifdef __WXMAC__ #ifdef __WXMAC__
# ifdef __DARWIN__ # ifdef __DARWIN__
...@@ -53,10 +46,6 @@ ...@@ -53,10 +46,6 @@
#include <3d_struct.h> #include <3d_struct.h>
class BOARD_DESIGN_SETTINGS; class BOARD_DESIGN_SETTINGS;
class TRACK;
class TEXTE_PCB;
class DRAWSEGMENT;
class ZONE_CONTAINER;
class EDA_3D_FRAME; class EDA_3D_FRAME;
class S3D_VERTEX; class S3D_VERTEX;
class SEGVIA; class SEGVIA;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/** /**
* @file 3d_draw.cpp * @file 3d_draw.cpp
*/ */
#include <fctsys.h> #include <fctsys.h>
#include <common.h> #include <common.h>
...@@ -49,19 +49,19 @@ ...@@ -49,19 +49,19 @@
#include <3d_draw_basic_functions.h> #include <3d_draw_basic_functions.h>
// Imported function: // Imported function:
extern void SetGLColor( EDA_COLOR_T color ); 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(); 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 ); 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: * Z orientation is 1.0 for all layers but "back" layers:
* LAYER_N_BACK , ADHESIVE_N_BACK, SOLDERPASTE_N_BACK ), SILKSCREEN_N_BACK * LAYER_N_BACK , ADHESIVE_N_BACK, SOLDERPASTE_N_BACK ), SILKSCREEN_N_BACK
* used to calculate the Z orientation parameter for glNormal3f * used to calculate the Z orientation parameter for glNormal3f
*/ */
static GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer ); static GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer );
/* Helper function BuildPadShapeThickOutlineAsPolygon: /* Helper function BuildPadShapeThickOutlineAsPolygon:
...@@ -69,34 +69,35 @@ static GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer ); ...@@ -69,34 +69,35 @@ static GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer );
* with a line thickness = aWidth * with a line thickness = aWidth
* Used only to draw pads outlines on silkscreen layers. * Used only to draw pads outlines on silkscreen layers.
*/ */
static void BuildPadShapeThickOutlineAsPolygon( D_PAD * aPad, static void BuildPadShapeThickOutlineAsPolygon( D_PAD* aPad,
std::vector <CPolyPt>& aCornerBuffer, CPOLYGONS_LIST& aCornerBuffer,
int aWidth, int aWidth,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) double aCorrectionFactor )
{ {
if( aPad->GetShape() == PAD_CIRCLE ) // Draw a ring if( aPad->GetShape() == PAD_CIRCLE ) // Draw a ring
{ {
TransformRingToPolygon( aCornerBuffer, aPad->ReturnShapePos(), TransformRingToPolygon( aCornerBuffer, aPad->ReturnShapePos(),
aPad->GetSize().x / 2, aCircleToSegmentsCount, aWidth ); aPad->GetSize().x / 2, aCircleToSegmentsCount, aWidth );
return; return;
} }
// For other shapes, draw polygon outlines // For other shapes, draw polygon outlines
std::vector <CPolyPt> corners; CPOLYGONS_LIST corners;
aPad->BuildPadShapePolygon( corners, wxSize( 0, 0 ), aPad->BuildPadShapePolygon( corners, wxSize( 0, 0 ),
aCircleToSegmentsCount, aCorrectionFactor ); aCircleToSegmentsCount, aCorrectionFactor );
// Add outlines as thick segments in polygon buffer // Add outlines as thick segments in polygon buffer
for( unsigned ii = 0, jj = corners.size() - 1; ii < corners.size(); jj = ii, ii++ ) for( unsigned ii = 0, jj = corners.size() - 1; ii < corners.size(); jj = ii, ii++ )
{ {
TransformRoundedEndsSegmentToPolygon( aCornerBuffer, TransformRoundedEndsSegmentToPolygon( aCornerBuffer,
wxPoint( corners[jj].x, corners[jj].y ), wxPoint( corners[jj].x, corners[jj].y ),
wxPoint( corners[ii].x, corners[ii].y ), wxPoint( corners[ii].x, corners[ii].y ),
aCircleToSegmentsCount, aWidth ); aCircleToSegmentsCount, aWidth );
} }
} }
void EDA_3D_CANVAS::Redraw( bool finish ) void EDA_3D_CANVAS::Redraw( bool finish )
{ {
// SwapBuffer requires the window to be shown before calling // SwapBuffer requires the window to be shown before calling
...@@ -145,39 +146,41 @@ void EDA_3D_CANVAS::Redraw( bool finish ) ...@@ -145,39 +146,41 @@ void EDA_3D_CANVAS::Redraw( bool finish )
SwapBuffers(); SwapBuffers();
} }
void EDA_3D_CANVAS::BuildBoard3DView() void EDA_3D_CANVAS::BuildBoard3DView()
{ {
PCB_BASE_FRAME* pcbframe = Parent()->Parent(); PCB_BASE_FRAME* pcbframe = Parent()->Parent();
BOARD* pcb = pcbframe->GetBoard(); BOARD* pcb = pcbframe->GetBoard();
// Number of segments to draw a circle using segments // Number of segments to draw a circle using segments
const int segcountforcircle = 16; 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 const int segcountLowQuality = 12; // segments to draw a circle with low quality
// to reduce time calculations // to reduce time calculations
// for holes and items which do not need // for holes and items which do not need
// a fine representation // a fine representation
double correctionFactorLQ = 1.0 / cos( M_PI / (segcountLowQuality*2) ); double correctionFactorLQ = 1.0 / cos( M_PI / (segcountLowQuality * 2) );
std::vector <CPolyPt> bufferPolys; CPOLYGONS_LIST bufferPolys;
bufferPolys.reserve( 200000 ); // Reserve for large board (tracks mainly)
std::vector <CPolyPt> bufferZonesPolys; bufferPolys.reserve( 200000 ); // Reserve for large board (tracks mainly)
bufferPolys.reserve( 500000 ); // Reserve for large board ( copper zones mainly ) CPOLYGONS_LIST bufferZonesPolys;
std::vector <CPolyPt> currLayerHoles; // Contains holes for the current layer bufferPolys.reserve( 500000 ); // Reserve for large board ( copper zones mainly )
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 ); allLayerHoles.reserve( 20000 );
bool throughHolesListBuilt = false; // flag to build the through hole polygon list only once bool throughHolesListBuilt = false; // flag to build the through hole polygon list only once
bool hightQualityMode = false; bool hightQualityMode = false;
for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER;
layer++ ) layer++ )
{ {
if( layer != LAST_COPPER_LAYER
if( layer != LAST_COPPER_LAYER && && layer >= g_Parm_3D_Visu.m_CopperLayersCount )
layer >= g_Parm_3D_Visu.m_CopperLayersCount )
continue; continue;
if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ) if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
continue; continue;
bufferPolys.clear(); bufferPolys.clear();
bufferZonesPolys.clear(); bufferZonesPolys.clear();
currLayerHoles.clear(); currLayerHoles.clear();
...@@ -185,25 +188,26 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -185,25 +188,26 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Draw tracks: // Draw tracks:
for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() ) for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() )
{ {
if( !track->IsOnLayer(layer) ) if( !track->IsOnLayer( layer ) )
continue; continue;
track->TransformShapeWithClearanceToPolygon( bufferPolys, track->TransformShapeWithClearanceToPolygon( bufferPolys,
0, segcountforcircle, 0, segcountforcircle,
correctionFactor ); correctionFactor );
// Add via hole // Add via hole
if( track->Type() == PCB_VIA_T ) if( track->Type() == PCB_VIA_T )
{ {
int shape = track->GetShape(); int shape = track->GetShape();
int holediameter = track->GetDrillValue(); int holediameter = track->GetDrillValue();
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU(); int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
int hole_outer_radius = (holediameter + thickness) / 2; int hole_outer_radius = (holediameter + thickness) / 2;
if( shape != VIA_THROUGH ) if( shape != VIA_THROUGH )
TransformCircleToPolygon( currLayerHoles, TransformCircleToPolygon( currLayerHoles,
track->GetStart(), hole_outer_radius, track->GetStart(), hole_outer_radius,
segcountLowQuality ); segcountLowQuality );
else if( ! throughHolesListBuilt ) else if( !throughHolesListBuilt )
TransformCircleToPolygon( allLayerHoles, TransformCircleToPolygon( allLayerHoles,
track->GetStart(), hole_outer_radius, track->GetStart(), hole_outer_radius,
segcountLowQuality ); segcountLowQuality );
...@@ -214,16 +218,23 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -214,16 +218,23 @@ void EDA_3D_CANVAS::BuildBoard3DView()
for( MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() ) for( MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() )
{ {
module->TransformPadsShapesWithClearanceToPolygon( layer, module->TransformPadsShapesWithClearanceToPolygon( layer,
bufferPolys, 0, segcountforcircle, correctionFactor ); bufferPolys,
0,
segcountforcircle,
correctionFactor );
// Micro-wave modukes may have items on copper layers // Micro-wave modukes may have items on copper layers
module->TransformGraphicShapesWithClearanceToPolygonSet( layer, module->TransformGraphicShapesWithClearanceToPolygonSet( layer,
bufferPolys, 0, segcountforcircle, correctionFactor ); bufferPolys,
0,
segcountforcircle,
correctionFactor );
// Add pad hole, if any // Add pad hole, if any
if( ! throughHolesListBuilt ) if( !throughHolesListBuilt )
{ {
D_PAD* pad = module->Pads(); D_PAD* pad = module->Pads();
for( ; pad != NULL; pad = pad->Next() ) for( ; pad != NULL; pad = pad->Next() )
pad->BuildPadDrillShapePolygon( allLayerHoles, 0, pad->BuildPadDrillShapePolygon( allLayerHoles, 0,
segcountLowQuality ); segcountLowQuality );
...@@ -235,34 +246,34 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -235,34 +246,34 @@ void EDA_3D_CANVAS::BuildBoard3DView()
{ {
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ ) 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(); LAYER_NUM zonelayer = zone->GetLayer();
if( zonelayer == layer ) if( zonelayer == layer )
zone->TransformSolidAreasShapesToPolygonSet( zone->TransformSolidAreasShapesToPolygonSet(
hightQualityMode ? bufferPolys : bufferZonesPolys, hightQualityMode ? bufferPolys : bufferZonesPolys,
segcountLowQuality, correctionFactorLQ ); segcountLowQuality, correctionFactorLQ );
} }
} }
// draw graphic items // draw graphic items
for( BOARD_ITEM* item = pcb->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = pcb->m_Drawings; item; item = item->Next() )
{ {
if( ! item->IsOnLayer( layer ) ) if( !item->IsOnLayer( layer ) )
continue; continue;
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_LINE_T: case PCB_LINE_T:
((DRAWSEGMENT*) item)->TransformShapeWithClearanceToPolygon( ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
bufferPolys, 0, bufferPolys, 0,
segcountforcircle, segcountforcircle,
correctionFactor ); correctionFactor );
break; break;
case PCB_TEXT_T: case PCB_TEXT_T:
((TEXTE_PCB*) item)->TransformShapeWithClearanceToPolygonSet( ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
bufferPolys, 0, segcountforcircle, correctionFactor ); bufferPolys, 0, segcountforcircle, correctionFactor );
break; break;
default: default:
...@@ -274,8 +285,8 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -274,8 +285,8 @@ void EDA_3D_CANVAS::BuildBoard3DView()
if( bufferPolys.size() == 0 ) if( bufferPolys.size() == 0 )
continue; continue;
KI_POLYGON_SET currLayerPolyset; KI_POLYGON_SET currLayerPolyset;
KI_POLYGON_SET polysetHoles; KI_POLYGON_SET polysetHoles;
// Add polygons, without holes // Add polygons, without holes
AddPolygonCornersToKiPolygonList( bufferPolys, currLayerPolyset ); AddPolygonCornersToKiPolygonList( bufferPolys, currLayerPolyset );
...@@ -283,6 +294,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -283,6 +294,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Add holes in polygon list // Add holes in polygon list
currLayerHoles.insert( currLayerHoles.begin(), currLayerHoles.insert( currLayerHoles.begin(),
allLayerHoles.begin(), allLayerHoles.end() ); allLayerHoles.begin(), allLayerHoles.end() );
if( currLayerHoles.size() > 0 ) if( currLayerHoles.size() > 0 )
AddPolygonCornersToKiPolygonList( currLayerHoles, polysetHoles ); AddPolygonCornersToKiPolygonList( currLayerHoles, polysetHoles );
...@@ -290,8 +302,8 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -290,8 +302,8 @@ void EDA_3D_CANVAS::BuildBoard3DView()
currLayerPolyset -= polysetHoles; currLayerPolyset -= polysetHoles;
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer ); EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer ); int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer ); int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
SetGLColor( color ); SetGLColor( color );
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
...@@ -301,6 +313,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -301,6 +313,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness, thickness,
g_Parm_3D_Visu.m_BiuTo3Dunits ); g_Parm_3D_Visu.m_BiuTo3Dunits );
if( bufferZonesPolys.size() ) if( bufferZonesPolys.size() )
Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos, Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos,
thickness, thickness,
...@@ -313,10 +326,11 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -313,10 +326,11 @@ void EDA_3D_CANVAS::BuildBoard3DView()
for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() ) for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() )
{ {
if( track->Type() == PCB_VIA_T ) if( track->Type() == PCB_VIA_T )
Draw3DViaHole( (SEGVIA *) track ); Draw3DViaHole( (SEGVIA*) track );
} }
// Draw pads holes (vertical cylinders) // Draw pads holes (vertical cylinders)
for( MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() ) for( MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() )
{ {
for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() ) for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() )
Draw3DPadHole( pad ); Draw3DPadHole( pad );
...@@ -326,30 +340,31 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -326,30 +340,31 @@ void EDA_3D_CANVAS::BuildBoard3DView()
for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER; for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER;
layer++ ) layer++ )
{ {
if( ! Is3DLayerEnabled( layer ) ) if( !Is3DLayerEnabled( layer ) )
continue; continue;
if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ) if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
continue; continue;
bufferPolys.clear(); bufferPolys.clear();
for( BOARD_ITEM* item = pcb->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = pcb->m_Drawings; item; item = item->Next() )
{ {
if( ! item->IsOnLayer( layer ) ) if( !item->IsOnLayer( layer ) )
continue; continue;
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_LINE_T: case PCB_LINE_T:
((DRAWSEGMENT*) item)->TransformShapeWithClearanceToPolygon( ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
bufferPolys, 0, bufferPolys, 0,
segcountforcircle, segcountforcircle,
correctionFactor ); correctionFactor );
break; break;
case PCB_TEXT_T: case PCB_TEXT_T:
((TEXTE_PCB*) item)->TransformShapeWithClearanceToPolygonSet( ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
bufferPolys, 0, segcountforcircle, correctionFactor ); bufferPolys, 0, segcountforcircle, correctionFactor );
break; break;
default: default:
...@@ -361,24 +376,31 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -361,24 +376,31 @@ void EDA_3D_CANVAS::BuildBoard3DView()
{ {
if( layer == SILKSCREEN_N_FRONT || layer == SILKSCREEN_N_BACK ) if( layer == SILKSCREEN_N_FRONT || layer == SILKSCREEN_N_BACK )
{ {
D_PAD* pad = module->Pads(); D_PAD* pad = module->Pads();
int linewidth = g_DrawDefaultLineThickness; int linewidth = g_DrawDefaultLineThickness;
for( ; pad != NULL; pad = pad->Next() ) for( ; pad != NULL; pad = pad->Next() )
{ {
if( !pad->IsOnLayer( layer ) ) if( !pad->IsOnLayer( layer ) )
continue; continue;
BuildPadShapeThickOutlineAsPolygon( pad, bufferPolys, BuildPadShapeThickOutlineAsPolygon( pad, bufferPolys,
linewidth, linewidth,
segcountforcircle, correctionFactor ); segcountforcircle, correctionFactor );
} }
} }
else else
module->TransformPadsShapesWithClearanceToPolygon( layer, module->TransformPadsShapesWithClearanceToPolygon( layer,
bufferPolys, 0, segcountforcircle, correctionFactor ); bufferPolys,
0,
segcountforcircle,
correctionFactor );
module->TransformGraphicShapesWithClearanceToPolygonSet( layer, module->TransformGraphicShapesWithClearanceToPolygonSet( layer,
bufferPolys, 0, segcountforcircle, correctionFactor ); bufferPolys,
0,
segcountforcircle,
correctionFactor );
} }
// bufferPolys contains polygons to merge. Many overlaps . // bufferPolys contains polygons to merge. Many overlaps .
...@@ -386,15 +408,16 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -386,15 +408,16 @@ void EDA_3D_CANVAS::BuildBoard3DView()
if( bufferPolys.size() == 0 ) if( bufferPolys.size() == 0 )
continue; continue;
KI_POLYGON_SET currLayerPolyset; KI_POLYGON_SET currLayerPolyset;
KI_POLYGON_SET polyset; KI_POLYGON_SET polyset;
AddPolygonCornersToKiPolygonList( bufferPolys, polyset ); AddPolygonCornersToKiPolygonList( bufferPolys, polyset );
// merge polys: // merge polys:
currLayerPolyset += polyset; currLayerPolyset += polyset;
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer ); EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer ); int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer ); int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
if( layer == EDGE_N ) if( layer == EDGE_N )
{ {
thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT ) thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT )
...@@ -417,12 +440,13 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -417,12 +440,13 @@ void EDA_3D_CANVAS::BuildBoard3DView()
module->ReadAndInsert3DComponentShape( this ); module->ReadAndInsert3DComponentShape( this );
} }
GLuint EDA_3D_CANVAS::CreateDrawGL_List() GLuint EDA_3D_CANVAS::CreateDrawGL_List()
{ {
PCB_BASE_FRAME* pcbframe = Parent()->Parent(); PCB_BASE_FRAME* pcbframe = Parent()->Parent();
BOARD* pcb = pcbframe->GetBoard(); BOARD* pcb = pcbframe->GetBoard();
wxBusyCursor dummy; wxBusyCursor dummy;
m_gllist = glGenLists( 1 ); m_gllist = glGenLists( 1 );
...@@ -434,7 +458,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -434,7 +458,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
// draw axis // 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 ); glEnable( GL_COLOR_MATERIAL );
SetGLColor( WHITE ); SetGLColor( WHITE );
...@@ -457,7 +481,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -457,7 +481,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
// Draw Board: // Draw Board:
// For testing purpose only display calculation time to generate 3D data // For testing purpose only display calculation time to generate 3D data
//#define PRINT_CALCULATION_TIME // #define PRINT_CALCULATION_TIME
#ifdef PRINT_CALCULATION_TIME #ifdef PRINT_CALCULATION_TIME
unsigned strtime = GetRunningMicroSecs(); unsigned strtime = GetRunningMicroSecs();
...@@ -467,7 +491,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -467,7 +491,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
// Draw grid // Draw grid
if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] ) if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] )
DrawGrid( g_Parm_3D_Visu.m_3D_Grid ); DrawGrid( g_Parm_3D_Visu.m_3D_Grid );
glEndList(); glEndList();
...@@ -475,9 +499,9 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -475,9 +499,9 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
CheckGLError(); CheckGLError();
#ifdef PRINT_CALCULATION_TIME #ifdef PRINT_CALCULATION_TIME
unsigned endtime = GetRunningMicroSecs(); unsigned endtime = GetRunningMicroSecs();
wxString msg; 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 ); Parent()->SetStatusText( msg, 0 );
#endif #endif
...@@ -489,27 +513,27 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -489,27 +513,27 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
// and a vertical grid (XZ plane and Y = 0) // and a vertical grid (XZ plane and Y = 0)
void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM ) void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
{ {
double zpos = 0.0; double zpos = 0.0;
EDA_COLOR_T gridcolor = DARKGRAY; // Color of grid lines EDA_COLOR_T gridcolor = DARKGRAY; // Color of grid lines
EDA_COLOR_T gridcolor_marker = LIGHTGRAY; // Color of grid lines every 5 lines EDA_COLOR_T gridcolor_marker = LIGHTGRAY; // Color of grid lines every 5 lines
double scale = g_Parm_3D_Visu.m_BiuTo3Dunits; double scale = g_Parm_3D_Visu.m_BiuTo3Dunits;
glNormal3f( 0.0, 0.0, 1.0 ); glNormal3f( 0.0, 0.0, 1.0 );
wxSize brd_size = g_Parm_3D_Visu.m_BoardSize; wxSize brd_size = g_Parm_3D_Visu.m_BoardSize;
wxPoint brd_center_pos = g_Parm_3D_Visu.m_BoardPos; wxPoint brd_center_pos = g_Parm_3D_Visu.m_BoardPos;
NEGATE( brd_center_pos.y ); NEGATE( brd_center_pos.y );
int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ); int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) );
int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ); int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) );
// Grid limits, in 3D units // Grid limits, in 3D units
double xmin = (brd_center_pos.x - xsize/2) * scale; double xmin = (brd_center_pos.x - xsize / 2) * scale;
double xmax = (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 ymin = (brd_center_pos.y - ysize / 2) * scale;
double ymax = (brd_center_pos.y + ysize/2) * scale; double ymax = (brd_center_pos.y + ysize / 2) * scale;
double zmin = Millimeter2iu( -50 ) * scale; double zmin = Millimeter2iu( -50 ) * scale;
double zmax = Millimeter2iu( 100 ) * scale; double zmax = Millimeter2iu( 100 ) * scale;
// Draw horizontal grid centered on 3D origin (center of the board) // Draw horizontal grid centered on 3D origin (center of the board)
for( int ii = 0; ; ii++ ) for( int ii = 0; ; ii++ )
...@@ -521,38 +545,39 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM ) ...@@ -521,38 +545,39 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
int delta = KiROUND( ii * aGriSizeMM * IU_PER_MM ); 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, -ymin, zpos );
glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos ); glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
glEnd(); glEnd();
if( ii != 0 ) 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, -ymin, zpos );
glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos ); glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
glEnd(); 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( xmin, -(brd_center_pos.y + delta) * scale, zpos );
glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos ); glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos );
glEnd(); glEnd();
if( ii != 0 ) if( ii != 0 )
{ {
glBegin(GL_LINES); glBegin( GL_LINES );
glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos ); glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos );
glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos ); glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos );
glEnd(); glEnd();
} }
} }
if( ( delta > ysize/2 ) && ( delta > xsize/2 ) ) if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
break; break;
} }
...@@ -569,20 +594,20 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM ) ...@@ -569,20 +594,20 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
double delta = ii * aGriSizeMM * IU_PER_MM; 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, zmin );
glVertex3f( (brd_center_pos.x + delta) * scale, -brd_center_pos.y * scale, zmax ); glVertex3f( (brd_center_pos.x + delta) * scale, -brd_center_pos.y * scale, zmax );
glEnd(); glEnd();
if( ii != 0 ) 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, zmin );
glVertex3f( (brd_center_pos.x - delta) * scale, -brd_center_pos.y * scale, zmax ); glVertex3f( (brd_center_pos.x - delta) * scale, -brd_center_pos.y * scale, zmax );
glEnd(); glEnd();
} }
if( delta > xsize/2 ) if( delta > xsize / 2 )
break; break;
} }
...@@ -594,21 +619,23 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM ) ...@@ -594,21 +619,23 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
else else
SetGLColor( gridcolor_marker ); SetGLColor( gridcolor_marker );
double delta = ii * aGriSizeMM * IU_PER_MM * scale; double delta = ii * aGriSizeMM * IU_PER_MM * scale;
if( delta <= zmax ) if( delta <= zmax )
{ // Draw grid lines on Z axis (positive Z axis coordinates) {
glBegin(GL_LINES); // Draw grid lines on Z axis (positive Z axis coordinates)
glVertex3f(xmin, -brd_center_pos.y * scale, delta); glBegin( GL_LINES );
glVertex3f(xmax, -brd_center_pos.y * scale, delta); glVertex3f( xmin, -brd_center_pos.y * scale, delta );
glVertex3f( xmax, -brd_center_pos.y * scale, delta );
glEnd(); glEnd();
} }
if( delta <= -zmin && ( ii != 0 ) ) if( delta <= -zmin && ( ii != 0 ) )
{ // Draw grid lines on Z axis (negative Z axis coordinates) {
glBegin(GL_LINES); // Draw grid lines on Z axis (negative Z axis coordinates)
glVertex3f(xmin, -brd_center_pos.y * scale, -delta); glBegin( GL_LINES );
glVertex3f(xmax, -brd_center_pos.y * scale, -delta); glVertex3f( xmin, -brd_center_pos.y * scale, -delta );
glVertex3f( xmax, -brd_center_pos.y * scale, -delta );
glEnd(); glEnd();
} }
...@@ -617,22 +644,23 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM ) ...@@ -617,22 +644,23 @@ 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; LAYER_NUM top_layer, bottom_layer;
int inner_radius = aVia->GetDrillValue() / 2; int inner_radius = aVia->GetDrillValue() / 2;
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU(); int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
aVia->ReturnLayerPair( &top_layer, &bottom_layer ); aVia->ReturnLayerPair( &top_layer, &bottom_layer );
// Drawing via hole: // Drawing via hole:
EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + aVia->GetShape() ); EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + aVia->GetShape() );
SetGLColor( color ); 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; 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 ); thickness, zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
} }
...@@ -640,7 +668,7 @@ void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA * aVia ) ...@@ -640,7 +668,7 @@ void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA * aVia )
void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas ) void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas )
{ {
// Draw module shape: 3D shape if exists (or module outlines if not exists) // Draw module shape: 3D shape if exists (or module outlines if not exists)
S3D_MASTER* struct3D = m_3D_Drawings; S3D_MASTER* struct3D = m_3D_Drawings;
if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] ) if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] )
{ {
...@@ -678,24 +706,24 @@ void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas ) ...@@ -678,24 +706,24 @@ void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas )
// Draw 3D pads. // Draw 3D pads.
void EDA_3D_CANVAS::Draw3DPadHole( D_PAD * aPad ) void EDA_3D_CANVAS::Draw3DPadHole( D_PAD* aPad )
{ {
// Draw the pad hole // Draw the pad hole
wxSize drillsize = aPad->GetDrillSize(); wxSize drillsize = aPad->GetDrillSize();
bool hasHole = drillsize.x && drillsize.y; bool hasHole = drillsize.x && drillsize.y;
if( ! hasHole ) if( !hasHole )
return; return;
// Store here the points to approximate hole by segments // Store here the points to approximate hole by segments
std::vector <CPolyPt> holecornersBuffer; CPOLYGONS_LIST holecornersBuffer;
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU(); int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
int height = g_Parm_3D_Visu.GetLayerZcoordBIU(LAYER_N_FRONT) - int height = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT ) -
g_Parm_3D_Visu.GetLayerZcoordBIU(LAYER_N_BACK); g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
SetGLColor( DARKGRAY ); 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; int holeHeight = height - thickness;
if( drillsize.x == drillsize.y ) // usual round hole if( drillsize.x == drillsize.y ) // usual round hole
{ {
...@@ -706,7 +734,7 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD * aPad ) ...@@ -706,7 +734,7 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD * aPad )
else // Oblong hole else // Oblong hole
{ {
wxPoint ends_offset; wxPoint ends_offset;
int width; int width;
if( drillsize.x > drillsize.y ) // Horizontal oval if( drillsize.x > drillsize.y ) // Horizontal oval
{ {
...@@ -721,9 +749,9 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD * aPad ) ...@@ -721,9 +749,9 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD * aPad )
RotatePoint( &ends_offset, aPad->GetOrientation() ); RotatePoint( &ends_offset, aPad->GetOrientation() );
wxPoint start = aPad->GetPosition() + ends_offset; wxPoint start = aPad->GetPosition() + ends_offset;
wxPoint end = aPad->GetPosition() - ends_offset; wxPoint end = aPad->GetPosition() - ends_offset;
int hole_radius = ( width + thickness ) / 2; int hole_radius = ( width + thickness ) / 2;
// Draw the hole // Draw the hole
Draw3D_ZaxisOblongCylinder( start, end, hole_radius, holeHeight, Draw3D_ZaxisOblongCylinder( start, end, hole_radius, holeHeight,
...@@ -731,33 +759,34 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD * aPad ) ...@@ -731,33 +759,34 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD * aPad )
} }
} }
bool Is3DLayerEnabled( LAYER_NUM aLayer ) bool Is3DLayerEnabled( LAYER_NUM aLayer )
{ {
int flg; int flg;
// see if layer needs to be shown // see if layer needs to be shown
// check the flags // check the flags
switch (aLayer) switch( aLayer )
{ {
case DRAW_N: case DRAW_N:
flg = g_Parm_3D_Visu.FL_DRAWINGS; flg = g_Parm_3D_Visu.FL_DRAWINGS;
break; break;
case COMMENT_N: case COMMENT_N:
flg = g_Parm_3D_Visu.FL_COMMENTS; flg = g_Parm_3D_Visu.FL_COMMENTS;
break; break;
case ECO1_N: case ECO1_N:
flg = g_Parm_3D_Visu.FL_ECO1; flg = g_Parm_3D_Visu.FL_ECO1;
break; break;
case ECO2_N: case ECO2_N:
flg = g_Parm_3D_Visu.FL_ECO2; flg = g_Parm_3D_Visu.FL_ECO2;
break; break;
default: default:
// the layer was not a layer with a flag, so show it // the layer was not a layer with a flag, so show it
return true; return true;
} }
// if the layer has a flag, return the flag // if the layer has a flag, return the flag
...@@ -770,10 +799,10 @@ GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer ) ...@@ -770,10 +799,10 @@ GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer )
double nZ = 1.0; double nZ = 1.0;
if( ( aLayer == LAYER_N_BACK ) if( ( aLayer == LAYER_N_BACK )
|| ( aLayer == ADHESIVE_N_BACK ) || ( aLayer == ADHESIVE_N_BACK )
|| ( aLayer == SOLDERPASTE_N_BACK ) || ( aLayer == SOLDERPASTE_N_BACK )
|| ( aLayer == SILKSCREEN_N_BACK ) || ( aLayer == SILKSCREEN_N_BACK )
|| ( aLayer == SOLDERMASK_N_BACK ) ) || ( aLayer == SOLDERMASK_N_BACK ) )
nZ = -1.0; nZ = -1.0;
return nZ; return nZ;
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
* The top side is located at aZpos + aThickness / 2 * The top side is located at aZpos + aThickness / 2
* The bottom 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 ); int aZpos, int aThickness, double aBiuTo3DUnits );
/** draw the solid polygon found in aPolysList /** draw the solid polygon found in aPolysList
...@@ -55,7 +55,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysLi ...@@ -55,7 +55,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysLi
* The top side is located at aZpos + aThickness / 2 * The top side is located at aZpos + aThickness / 2
* The bottom 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 ); int aZpos, int aThickness, double aBiuTo3DUnits );
/** draw a thick segment using 3D primitives, in a XY plane /** draw a thick segment using 3D primitives, in a XY plane
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#define __3D_VIEWER_H__ #define __3D_VIEWER_H__
#include <wxBasePcbFrame.h> // for m_auimanager member. #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 #if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h. #error Please set wxUSE_GLCANVAS to 1 in setup.h.
......
...@@ -36,24 +36,24 @@ ...@@ -36,24 +36,24 @@
* We are using a lots polygons in calculations. * We are using a lots polygons in calculations.
* and we are using 2 descriptions, * and we are using 2 descriptions,
* one easy to use with boost::polygon (KI_POLYGON_SET) * 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 * 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 * Therefore we need conversion functions between these 2 descriptions
*/ */
void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList, void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList,
std::vector<CPolyPt>& aPolysList ) CPOLYGONS_LIST& aPolysList )
{ {
for( unsigned ii = 0; ii < aKiPolyList.size(); ii++ ) for( unsigned ii = 0; ii < aKiPolyList.size(); ii++ )
{ {
KI_POLYGON& poly = aKiPolyList[ii]; KI_POLYGON& poly = aKiPolyList[ii];
CPolyPt corner( 0, 0, false ); CPolyPt corner( 0, 0, false );
for( unsigned jj = 0; jj < poly.size(); jj++ ) for( unsigned jj = 0; jj < poly.size(); jj++ )
{ {
KI_POLY_POINT point = *(poly.begin() + jj); KI_POLY_POINT point = *(poly.begin() + jj);
corner.x = point.x(); corner.x = point.x();
corner.y = point.y(); corner.y = point.y();
corner.end_contour = false; corner.end_contour = false;
aPolysList.push_back( corner ); aPolysList.push_back( corner );
} }
...@@ -64,21 +64,23 @@ void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList, ...@@ -64,21 +64,23 @@ void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList,
} }
} }
/** /**
* Helper function AddPolygonCornersToKiPolygonList * Helper function AddPolygonCornersToKiPolygonList
* This function adds a KI_POLYGON_SET description to a * 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 aCornersBuffer = source (set of polygons using CPolyPt corners descr)
* @param aPolysList = destination (set of polygons) * @param aPolysList = destination (set of polygons)
*/ */
void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer, void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer,
KI_POLYGON_SET& aKiPolyList ) KI_POLYGON_SET& aKiPolyList )
{ {
std::vector<KI_POLY_POINT> cornerslist; std::vector<KI_POLY_POINT> cornerslist;
unsigned corners_count = aCornersBuffer.size(); unsigned corners_count = aCornersBuffer.size();
// Count the number of polygons in aCornersBuffer // Count the number of polygons in aCornersBuffer
int polycount = 0; int polycount = 0;
for( unsigned ii = 0; ii < corners_count; ii++ ) for( unsigned ii = 0; ii < corners_count; ii++ )
{ {
if( aCornersBuffer[ii].end_contour ) if( aCornersBuffer[ii].end_contour )
...@@ -89,10 +91,11 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer, ...@@ -89,10 +91,11 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
for( unsigned icnt = 0; icnt < corners_count; ) for( unsigned icnt = 0; icnt < corners_count; )
{ {
KI_POLYGON poly; KI_POLYGON poly;
cornerslist.clear(); cornerslist.clear();
unsigned ii; unsigned ii;
for( ii = icnt; ii < aCornersBuffer.size(); ii++ ) for( ii = icnt; ii < aCornersBuffer.size(); ii++ )
{ {
cornerslist.push_back( KI_POLY_POINT( aCornersBuffer[ii].x, aCornersBuffer[ii].y ) ); cornerslist.push_back( KI_POLY_POINT( aCornersBuffer[ii].x, aCornersBuffer[ii].y ) );
...@@ -118,19 +121,19 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer, ...@@ -118,19 +121,19 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
* Note: the polygon is inside the circle, so if you want to have the polygon * 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 * 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, wxPoint aCenter, int aRadius,
int aCircleToSegmentsCount ) int aCircleToSegmentsCount )
{ {
wxPoint corner_position; wxPoint corner_position;
int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree
int halfstep = 1800 / aCircleToSegmentsCount; // the starting value for rot angles int halfstep = 1800 / aCircleToSegmentsCount; // the starting value for rot angles
for( int ii = 0; ii < aCircleToSegmentsCount; ii++ ) for( int ii = 0; ii < aCircleToSegmentsCount; ii++ )
{ {
corner_position.x = aRadius; corner_position.x = aRadius;
corner_position.y = 0; corner_position.y = 0;
int angle = (ii * delta) + halfstep; int angle = (ii * delta) + halfstep;
RotatePoint( &corner_position.x, &corner_position.y, angle ); RotatePoint( &corner_position.x, &corner_position.y, angle );
corner_position += aCenter; corner_position += aCenter;
CPolyPt polypoint( corner_position.x, corner_position.y ); CPolyPt polypoint( corner_position.x, corner_position.y );
...@@ -153,28 +156,28 @@ void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer, ...@@ -153,28 +156,28 @@ void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* Note: the polygon is inside the arc ends, so if you want to have the polygon * 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 * 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, wxPoint aStart, wxPoint aEnd,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
int aWidth ) int aWidth )
{ {
int radius = aWidth / 2; int radius = aWidth / 2;
wxPoint endp = aEnd - aStart; // end point coordinate for the same segment starting at (0,0) wxPoint endp = aEnd - aStart; // end point coordinate for the same segment starting at (0,0)
wxPoint startp = aStart; wxPoint startp = aStart;
wxPoint corner; wxPoint corner;
CPolyPt polypoint; CPolyPt polypoint;
// normalize the position in order to have endp.x >= 0; // normalize the position in order to have endp.x >= 0;
if( endp.x < 0 ) if( endp.x < 0 )
{ {
endp = aStart - aEnd; endp = aStart - aEnd;
startp = aEnd; startp = aEnd;
} }
int delta_angle = ArcTangente( endp.y, endp.x ); // delta_angle is in 0.1 degrees int delta_angle = ArcTangente( endp.y, endp.x ); // delta_angle is in 0.1 degrees
int seg_len = KiROUND( EuclideanNorm( endp ) ); int seg_len = KiROUND( EuclideanNorm( endp ) );
int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree
// Compute the outlines of the segment, and creates a polygon // Compute the outlines of the segment, and creates a polygon
// add right rounded end: // add right rounded end:
...@@ -233,7 +236,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer, ...@@ -233,7 +236,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle * @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the line * @param aWidth = width (thickness) of the line
*/ */
void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer, void TransformArcToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, wxPoint aStart, int aArcAngle, wxPoint aCentre, wxPoint aStart, int aArcAngle,
int aCircleToSegmentsCount, int aWidth ) int aCircleToSegmentsCount, int aWidth )
{ {
...@@ -254,8 +257,8 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer, ...@@ -254,8 +257,8 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
} }
// Compute the ends of segments and creates poly // Compute the ends of segments and creates poly
wxPoint curr_end = arc_start; wxPoint curr_end = arc_start;
wxPoint curr_start = arc_start; wxPoint curr_start = arc_start;
for( int ii = delta; ii < aArcAngle; ii += delta ) for( int ii = delta; ii < aArcAngle; ii += delta )
{ {
...@@ -272,6 +275,7 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer, ...@@ -272,6 +275,7 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
aCircleToSegmentsCount, aWidth ); aCircleToSegmentsCount, aWidth );
} }
/** /**
* Function TransformRingToPolygon * Function TransformRingToPolygon
* Creates a polygon from a ring * Creates a polygon from a ring
...@@ -282,50 +286,50 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer, ...@@ -282,50 +286,50 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle * @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the ring * @param aWidth = width (thickness) of the ring
*/ */
void TransformRingToPolygon( std::vector <CPolyPt>& aCornerBuffer, void TransformRingToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, int aRadius, wxPoint aCentre, int aRadius,
int aCircleToSegmentsCount, int aWidth ) int aCircleToSegmentsCount, int aWidth )
{ {
int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree
// Compute the corners posituions and creates poly // Compute the corners posituions and creates poly
wxPoint curr_point; wxPoint curr_point;
int inner_radius = aRadius - ( aWidth / 2 ); int inner_radius = aRadius - ( aWidth / 2 );
int outer_radius = inner_radius + aWidth; int outer_radius = inner_radius + aWidth;
CPolyPt polycorner; CPolyPt polycorner;
// Draw the inner circle of the ring // Draw the inner circle of the ring
for( int ii = 0; ii < 3600; ii += delta ) for( int ii = 0; ii < 3600; ii += delta )
{ {
curr_point.x = inner_radius; curr_point.x = inner_radius;
curr_point.y = 0; curr_point.y = 0;
RotatePoint( &curr_point, ii ); RotatePoint( &curr_point, ii );
curr_point += aCentre; curr_point += aCentre;
polycorner.x = curr_point.x; polycorner.x = curr_point.x;
polycorner.y = curr_point.y; polycorner.y = curr_point.y;
aCornerBuffer.push_back( polycorner ); aCornerBuffer.push_back( polycorner );
} }
// Draw the last point of inner circle // Draw the last point of inner circle
polycorner.x = aCentre.x + inner_radius; polycorner.x = aCentre.x + inner_radius;
polycorner.y = aCentre.y; polycorner.y = aCentre.y;
aCornerBuffer.push_back( polycorner ); aCornerBuffer.push_back( polycorner );
// Draw the outer circle of the ring // Draw the outer circle of the ring
for( int ii = 0; ii < 3600; ii += delta ) for( int ii = 0; ii < 3600; ii += delta )
{ {
curr_point.x = outer_radius; curr_point.x = outer_radius;
curr_point.y = 0; curr_point.y = 0;
RotatePoint( &curr_point, -ii ); RotatePoint( &curr_point, -ii );
curr_point += aCentre; curr_point += aCentre;
polycorner.x = curr_point.x; polycorner.x = curr_point.x;
polycorner.y = curr_point.y; polycorner.y = curr_point.y;
aCornerBuffer.push_back( polycorner ); aCornerBuffer.push_back( polycorner );
} }
// Draw the last point of outer circle // Draw the last point of outer circle
polycorner.x = aCentre.x + outer_radius; polycorner.x = aCentre.x + outer_radius;
polycorner.y = aCentre.y; polycorner.y = aCentre.y;
aCornerBuffer.push_back( polycorner ); aCornerBuffer.push_back( polycorner );
// Close the polygon // Close the polygon
......
...@@ -40,26 +40,26 @@ ...@@ -40,26 +40,26 @@
* We are using a lots polygons in calculations. * We are using a lots polygons in calculations.
* and we are using 2 descriptions, * and we are using 2 descriptions,
* one easy to use with boost::polygon (KI_POLYGON_SET) * 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 * 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 * Therefore we need conversion functions between these 2 descriptions
* This function converts a KI_POLYGON_SET description to a * This function converts a KI_POLYGON_SET description to a
* std::vector<CPolyPt> description * CPOLYGONS_LIST description
* @param aKiPolyList = source (set of polygons) * @param aKiPolyList = source (set of polygons)
* @param aPolysList = destination (set of polygons using CPolyPt corners descr) * @param aPolysList = destination (set of polygons using CPolyPt corners descr)
*/ */
void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList, void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList,
std::vector<CPolyPt>& aPolysList ); CPOLYGONS_LIST& aPolysList );
/** /**
* Helper function AddPolygonCornersToKiPolygonList * Helper function AddPolygonCornersToKiPolygonList
* This function adds a KI_POLYGON_SET description to a * 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 aCornersBuffer = source (set of polygons using CPolyPt corners descr)
* @param aPolysList = destination (set of polygons) * @param aPolysList = destination (set of polygons)
*/ */
void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer, void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer,
KI_POLYGON_SET& aKiPolyList ); KI_POLYGON_SET& aKiPolyList );
/** /**
...@@ -72,7 +72,7 @@ void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer, ...@@ -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 * 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 * 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, wxPoint aCenter, int aRadius,
int aCircleToSegmentsCount ); int aCircleToSegmentsCount );
...@@ -88,7 +88,7 @@ void TransformCircleToPolygon( std::vector <CPolyPt>& aCornerBuffer, ...@@ -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 * 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 * 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, wxPoint aStart, wxPoint aEnd,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
int aWidth ); int aWidth );
...@@ -105,7 +105,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer, ...@@ -105,7 +105,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle * @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the line * @param aWidth = width (thickness) of the line
*/ */
void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer, void TransformArcToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, wxPoint aStart, int aArcAngle, wxPoint aCentre, wxPoint aStart, int aArcAngle,
int aCircleToSegmentsCount, int aWidth ); int aCircleToSegmentsCount, int aWidth );
...@@ -119,7 +119,7 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer, ...@@ -119,7 +119,7 @@ void TransformArcToPolygon( std::vector <CPolyPt>& aCornerBuffer,
* @param aCircleToSegmentsCount = the number of segments to approximate a circle * @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aWidth = width (thickness) of the ring * @param aWidth = width (thickness) of the ring
*/ */
void TransformRingToPolygon( std::vector <CPolyPt>& aCornerBuffer, void TransformRingToPolygon( CPOLYGONS_LIST& aCornerBuffer,
wxPoint aCentre, int aRadius, wxPoint aCentre, int aRadius,
int aCircleToSegmentsCount, int aWidth ); int aCircleToSegmentsCount, int aWidth );
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
* initial radius * aCorrectionFactor * initial radius * aCorrectionFactor
*/ */
void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer, void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer, CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue, int aInflateValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) double aCorrectionFactor )
...@@ -86,7 +86,7 @@ void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer, ...@@ -86,7 +86,7 @@ void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
*/ */
void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
LAYER_NUM aLayer, LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer, CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue, int aInflateValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) double aCorrectionFactor )
...@@ -166,12 +166,12 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( ...@@ -166,12 +166,12 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
* keep arc radius when approximated by segments * keep arc radius when approximated by segments
*/ */
void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet( void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(
std::vector <CPolyPt>& aCornerBuffer, CPOLYGONS_LIST& aCornerBuffer,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) double aCorrectionFactor )
{ {
unsigned cornerscount = GetFilledPolysList().size(); unsigned cornerscount = GetFilledPolysList().size();
std::vector <CPolyPt> polygonslist; CPOLYGONS_LIST polygonslist;
if( cornerscount == 0 ) if( cornerscount == 0 )
return; return;
...@@ -217,7 +217,7 @@ void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet( ...@@ -217,7 +217,7 @@ void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(
* @param aClearanceValue = the clearance around the pad * @param aClearanceValue = the clearance around the pad
*/ */
void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon( void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer, CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue ) const int aClearanceValue ) const
{ {
if( GetText().Length() == 0 ) if( GetText().Length() == 0 )
...@@ -251,7 +251,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon( ...@@ -251,7 +251,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
* Convert the text shape to a set of polygons (one by segment) * Convert the text shape to a set of polygons (one by segment)
* Used in filling zones calculations and 3D view * Used in filling zones calculations and 3D view
* Circles and arcs are approximated by segments * 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 * aClearanceValue = the clearance around the text
* aCircleToSegmentsCount = the number of segments to approximate a circle * aCircleToSegmentsCount = the number of segments to approximate a circle
* aCorrectionFactor = the correction to apply to circles radius to keep * aCorrectionFactor = the correction to apply to circles radius to keep
...@@ -263,7 +263,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon( ...@@ -263,7 +263,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
// so we cannot send them as arguments. // so we cannot send them as arguments.
int s_textWidth; int s_textWidth;
int s_textCircle2SegmentCount; 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: // 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 ) 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 ) ...@@ -274,7 +274,7 @@ static void addTextSegmToPoly( int x0, int y0, int xf, int yf )
} }
void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
std::vector <CPolyPt>& aCornerBuffer, CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue, int aClearanceValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) const double aCorrectionFactor ) const
...@@ -334,7 +334,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( ...@@ -334,7 +334,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
* clearance when the circle is approxiamted by segment bigger or equal * clearance when the circle is approxiamted by segment bigger or equal
* to the real clearance value (usually near from 1.0) * 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 aClearanceValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) const double aCorrectionFactor ) const
...@@ -375,7 +375,7 @@ void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& a ...@@ -375,7 +375,7 @@ void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& a
* clearance when the circle is approximated by segment bigger or equal * clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0) * 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 aClearanceValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) const double aCorrectionFactor ) const
...@@ -404,17 +404,17 @@ void TRACK:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor ...@@ -404,17 +404,17 @@ void TRACK:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
* Convert the pad shape to a closed polygon * Convert the pad shape to a closed polygon
* Used in filling zones calculations and 3D view generation * Used in filling zones calculations and 3D view generation
* Circles and arcs are approximated by segments * 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 * aClearanceValue = the clearance around the pad
* aCircleToSegmentsCount = the number of segments to approximate a circle * aCircleToSegmentsCount = the number of segments to approximate a circle
* aCorrectionFactor = the correction to apply to circles radius to keep * aCorrectionFactor = the correction to apply to circles radius to keep
* clearance when the circle is approximated by segment bigger or equal * clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0) * 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 aClearanceValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) const double aCorrectionFactor ) const
{ {
wxPoint corner_position; wxPoint corner_position;
int angle; int angle;
...@@ -547,7 +547,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor ...@@ -547,7 +547,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
* Note: for Round and oval pads this function is equivalent to * Note: for Round and oval pads this function is equivalent to
* TransformShapeWithClearanceToPolygon, but not for other shapes * 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, wxSize aInflateValue, int aSegmentsPerCircle,
double aCorrectionFactor ) const double aCorrectionFactor ) const
{ {
...@@ -584,7 +584,7 @@ void D_PAD::BuildPadShapePolygon( std::vector <CPolyPt>& aCornerBuffer, ...@@ -584,7 +584,7 @@ void D_PAD::BuildPadShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
* depending on shape pad hole and orientation * depending on shape pad hole and orientation
* return false if the pad has no hole, true otherwise * 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 int aInflateValue, int aSegmentsPerCircle ) const
{ {
wxSize drillsize = GetDrillSize(); wxSize drillsize = GetDrillSize();
...@@ -658,14 +658,14 @@ bool D_PAD::BuildPadDrillShapePolygon( std::vector <CPolyPt>& aCornerBuffer, ...@@ -658,14 +658,14 @@ bool D_PAD::BuildPadDrillShapePolygon( std::vector <CPolyPt>& aCornerBuffer,
* and are used in microwave applications and they *DO NOT* have a thermal relief that * 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. * change the shape by creating stubs and destroy their properties.
*/ */
void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer, void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
D_PAD& aPad, D_PAD& aPad,
int aThermalGap, int aThermalGap,
int aCopperThickness, int aCopperThickness,
int aMinThicknessValue, int aMinThicknessValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor, double aCorrectionFactor,
int aThermalRot ) int aThermalRot )
{ {
wxPoint corner, corner_end; wxPoint corner, corner_end;
wxPoint PadShapePos = aPad.ReturnShapePos(); /* Note: for pad having a shape offset, wxPoint PadShapePos = aPad.ReturnShapePos(); /* Note: for pad having a shape offset,
......
...@@ -211,10 +211,10 @@ public: ...@@ -211,10 +211,10 @@ public:
* clearance when the circle is approximated by segment bigger or equal * clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0) * to the real clearance value (usually near from 1.0)
*/ */
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer, void TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue, int aClearanceValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) const; double aCorrectionFactor ) const;
virtual wxString GetSelectMenuText() const; virtual wxString GetSelectMenuText() const;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <class_board_item.h> #include <class_board_item.h>
#include <class_text_mod.h> #include <class_text_mod.h>
#include <PolyLine.h>
#include "zones.h" #include "zones.h"
class LINE_READER; class LINE_READER;
...@@ -46,7 +47,6 @@ class EDA_DRAW_PANEL; ...@@ -46,7 +47,6 @@ class EDA_DRAW_PANEL;
class D_PAD; class D_PAD;
class BOARD; class BOARD;
class MSG_PANEL_ITEM; class MSG_PANEL_ITEM;
class CPolyPt;
/** /**
...@@ -268,10 +268,10 @@ public: ...@@ -268,10 +268,10 @@ public:
* initial radius * aCorrectionFactor * initial radius * aCorrectionFactor
*/ */
void TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer, void TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer, CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue, int aInflateValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ); double aCorrectionFactor );
/** /**
* function TransformGraphicShapesWithClearanceToPolygonSet * function TransformGraphicShapesWithClearanceToPolygonSet
...@@ -292,10 +292,10 @@ public: ...@@ -292,10 +292,10 @@ public:
*/ */
void TransformGraphicShapesWithClearanceToPolygonSet( void TransformGraphicShapesWithClearanceToPolygonSet(
LAYER_NUM aLayer, LAYER_NUM aLayer,
std::vector <CPolyPt>& aCornerBuffer, CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue, int aInflateValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ); double aCorrectionFactor );
/** /**
......
...@@ -186,16 +186,16 @@ public: ...@@ -186,16 +186,16 @@ public:
void SetDrillShape( PAD_SHAPE_T aDrillShape ) { m_DrillShape = aDrillShape; } void SetDrillShape( PAD_SHAPE_T aDrillShape ) { m_DrillShape = aDrillShape; }
PAD_SHAPE_T GetDrillShape() const { return m_DrillShape; } PAD_SHAPE_T GetDrillShape() const { return m_DrillShape; }
void SetLayerMask( LAYER_MSK aLayerMask ) { m_layerMask = aLayerMask; } void SetLayerMask( LAYER_MSK aLayerMask ) { m_layerMask = aLayerMask; }
LAYER_MSK GetLayerMask() const { return m_layerMask; } LAYER_MSK GetLayerMask() const { return m_layerMask; }
void SetAttribute( PAD_ATTR_T aAttribute ); void SetAttribute( PAD_ATTR_T aAttribute );
PAD_ATTR_T GetAttribute() const { return m_Attribute; } PAD_ATTR_T GetAttribute() const { return m_Attribute; }
void SetPadToDieLength( int aLength ) { m_LengthPadToDie = aLength; } void SetPadToDieLength( int aLength ) { m_LengthPadToDie = aLength; }
int GetPadToDieLength() const { return m_LengthPadToDie; } int GetPadToDieLength() const { return m_LengthPadToDie; }
int GetLocalSolderMaskMargin() const { return m_LocalSolderMaskMargin; } int GetLocalSolderMaskMargin() const { return m_LocalSolderMaskMargin; }
void SetLocalSolderMaskMargin( int aMargin ) { m_LocalSolderMaskMargin = aMargin; } void SetLocalSolderMaskMargin( int aMargin ) { m_LocalSolderMaskMargin = aMargin; }
int GetLocalClearance() const { return m_LocalClearance; } int GetLocalClearance() const { return m_LocalClearance; }
...@@ -220,7 +220,7 @@ public: ...@@ -220,7 +220,7 @@ public:
* clearance when the circle is approximated by segment bigger or equal * clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0) * to the real clearance value (usually near from 1.0)
*/ */
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer, void TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue, int aClearanceValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) const;; double aCorrectionFactor ) const;;
...@@ -317,7 +317,7 @@ public: ...@@ -317,7 +317,7 @@ public:
* @param aCorrectionFactor = the correction to apply to circles radius to keep * @param aCorrectionFactor = the correction to apply to circles radius to keep
* the pad size when the circle is approximated by segments * 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, wxSize aInflateValue, int aSegmentsPerCircle,
double aCorrectionFactor ) const; double aCorrectionFactor ) const;
...@@ -332,7 +332,7 @@ public: ...@@ -332,7 +332,7 @@ public:
* (used for round and oblong shapes only(16 to 32 is a good value) * (used for round and oblong shapes only(16 to 32 is a good value)
* @return false if the pad has no hole, true otherwise * @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; int aInflateValue, int aSegmentsPerCircle ) const;
/** /**
......
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
* to the real clearance value (usually near from 1.0) * to the real clearance value (usually near from 1.0)
*/ */
void TransformBoundingBoxWithClearanceToPolygon( void TransformBoundingBoxWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer, CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue ) const; int aClearanceValue ) const;
/** /**
...@@ -108,10 +108,10 @@ public: ...@@ -108,10 +108,10 @@ public:
* clearance when the circle is approximated by segment bigger or equal * clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0) * to the real clearance value (usually near from 1.0)
*/ */
void TransformShapeWithClearanceToPolygonSet( std::vector <CPolyPt>& aCornerBuffer, void TransformShapeWithClearanceToPolygonSet( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue, int aClearanceValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) const; double aCorrectionFactor ) const;
wxString GetSelectMenuText() const; wxString GetSelectMenuText() const;
......
...@@ -175,10 +175,10 @@ public: ...@@ -175,10 +175,10 @@ public:
* clearance when the circle is approximated by segment bigger or equal * clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0) * to the real clearance value (usually near from 1.0)
*/ */
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer, void TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue, int aClearanceValue,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ) const; double aCorrectionFactor ) const;
/** /**
* Function SetDrill * Function SetDrill
* sets the drill value for vias. * sets the drill value for vias.
......
...@@ -274,7 +274,7 @@ public: ...@@ -274,7 +274,7 @@ public:
* @param aCorrectionFactor = the correction to apply to arcs radius to roughly * @param aCorrectionFactor = the correction to apply to arcs radius to roughly
* keep arc radius when approximated by segments * keep arc radius when approximated by segments
*/ */
void TransformSolidAreasShapesToPolygonSet( std::vector <CPolyPt>& aCornerBuffer, void TransformSolidAreasShapesToPolygonSet( CPOLYGONS_LIST& aCornerBuffer,
int aCircleToSegmentsCount, int aCircleToSegmentsCount,
double aCorrectionFactor ); double aCorrectionFactor );
/** /**
...@@ -296,7 +296,7 @@ public: ...@@ -296,7 +296,7 @@ public:
* This function calls AddClearanceAreasPolygonsToPolysList() * This function calls AddClearanceAreasPolygonsToPolysList()
* to add holes for pads and tracks and other items not in net. * 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 * Function CopyPolygonsFromKiPolygonListToFilledPolysList
...@@ -339,7 +339,7 @@ public: ...@@ -339,7 +339,7 @@ public:
* @param aAddClearance = true to add a clearance area to the polygon * @param aAddClearance = true to add a clearance area to the polygon
* false to create the outline polygon. * false to create the outline polygon.
*/ */
void TransformOutlinesShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer, void TransformOutlinesShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue, int aClearanceValue,
bool aAddClearance ); bool aAddClearance );
/** /**
...@@ -506,7 +506,7 @@ public: ...@@ -506,7 +506,7 @@ public:
* returns a reference to the list of filled polygons. * returns a reference to the list of filled polygons.
* @return 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; return m_FilledPolysList;
} }
...@@ -515,7 +515,7 @@ public: ...@@ -515,7 +515,7 @@ public:
* Function AddFilledPolysList * Function AddFilledPolysList
* sets the list of filled polygons. * sets the list of filled polygons.
*/ */
void AddFilledPolysList( std::vector<CPolyPt>& aPolysList ) void AddFilledPolysList( CPOLYGONS_LIST& aPolysList )
{ {
m_FilledPolysList = aPolysList; m_FilledPolysList = aPolysList;
} }
...@@ -549,7 +549,7 @@ public: ...@@ -549,7 +549,7 @@ public:
void AddPolygon( std::vector< wxPoint >& aPolygon ); 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() ); m_FilledPolysList.insert( m_FilledPolysList.end(), aPolygon.begin(), aPolygon.end() );
} }
...@@ -652,7 +652,7 @@ private: ...@@ -652,7 +652,7 @@ private:
* connecting "holes" with external main outline. In complex cases an outline * connecting "holes" with external main outline. In complex cases an outline
* described by m_Poly can have many filled areas * 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 ...@@ -1395,7 +1395,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
m_out->Print( 0, ")\n" ); 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; int newLine = 0;
if( cv.size() ) if( cv.size() )
...@@ -1403,7 +1403,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const ...@@ -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+1, "(polygon\n");
m_out->Print( aNestLevel+2, "(pts\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 ) if( newLine == 0 )
m_out->Print( aNestLevel+3, "(xy %s %s)", m_out->Print( aNestLevel+3, "(xy %s %s)",
...@@ -1443,7 +1443,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const ...@@ -1443,7 +1443,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
} }
// Save the PolysList // Save the PolysList
const std::vector< CPolyPt >& fv = aZone->GetFilledPolysList(); const CPOLYGONS_LIST& fv = aZone->GetFilledPolysList();
newLine = 0; newLine = 0;
if( fv.size() ) if( fv.size() )
...@@ -1451,7 +1451,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const ...@@ -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+1, "(filled_polygon\n" );
m_out->Print( aNestLevel+2, "(pts\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 ) if( newLine == 0 )
m_out->Print( aNestLevel+3, "(xy %s %s)", m_out->Print( aNestLevel+3, "(xy %s %s)",
......
...@@ -2346,7 +2346,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() ...@@ -2346,7 +2346,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
else if( TESTLINE( "$POLYSCORNERS" ) ) else if( TESTLINE( "$POLYSCORNERS" ) )
{ {
// Read the PolysList (polygons used for fill areas in the zone) // Read the PolysList (polygons used for fill areas in the zone)
std::vector<CPolyPt> polysList; CPOLYGONS_LIST polysList;
while( ( line = READLINE( m_reader ) ) != NULL ) while( ( line = READLINE( m_reader ) ) != NULL )
{ {
...@@ -3690,12 +3690,10 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const ...@@ -3690,12 +3690,10 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
me->GetCornerSmoothingType(), me->GetCornerSmoothingType(),
fmtBIU( me->GetCornerRadius() ).c_str() ); fmtBIU( me->GetCornerRadius() ).c_str() );
typedef std::vector< CPolyPt > CPOLY_PTS;
// Save the corner list // 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", fprintf( m_fp, "ZCorner %s %d\n",
fmtBIUPair( it->x, it->y ).c_str(), fmtBIUPair( it->x, it->y ).c_str(),
...@@ -3703,12 +3701,12 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const ...@@ -3703,12 +3701,12 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
} }
// Save the PolysList // Save the PolysList
const CPOLY_PTS& fv = me->GetFilledPolysList(); const CPOLYGONS_LIST& fv = me->GetFilledPolysList();
if( fv.size() ) if( fv.size() )
{ {
fprintf( m_fp, "$POLYSCORNERS\n" ); 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", fprintf( m_fp, "%s %d %d\n",
fmtBIUPair( it->x, it->y ).c_str(), fmtBIUPair( it->x, it->y ).c_str(),
......
...@@ -2371,7 +2371,7 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR ) ...@@ -2371,7 +2371,7 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR )
T token; T token;
// bigger scope since each filled_polygon is concatenated in here // 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 ) ); auto_ptr< ZONE_CONTAINER > zone( new ZONE_CONTAINER( m_board ) );
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
#include <pcbplot.h> #include <pcbplot.h>
// Imported function // Imported function
extern void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer, extern void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer,
KI_POLYGON_SET& aKiPolyList ); KI_POLYGON_SET& aKiPolyList );
// Local // Local
/* Plot a solder mask layer. /* Plot a solder mask layer.
...@@ -506,8 +506,8 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, ...@@ -506,8 +506,8 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter,
// This extra margin is used to merge too close shapes // This extra margin is used to merge too close shapes
// (distance < aMinThickness), and will be removed when creating // (distance < aMinThickness), and will be removed when creating
// the actual shapes // the actual shapes
std::vector <CPolyPt> bufferPolys; // Contains shapes to plot CPOLYGONS_LIST bufferPolys; // Contains shapes to plot
std::vector <CPolyPt> initialPolys; // Contains exact shapes to plot CPOLYGONS_LIST initialPolys; // Contains exact shapes to plot
/* calculates the coeff to compensate radius reduction of holes clearance /* calculates the coeff to compensate radius reduction of holes clearance
* due to the segment approx ( 1 /cos( PI/circleToSegmentsCount ) * due to the segment approx ( 1 /cos( PI/circleToSegmentsCount )
......
...@@ -506,7 +506,7 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte ) ...@@ -506,7 +506,7 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
*/ */
void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone ) void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone )
{ {
std::vector<CPolyPt> polysList = aZone->GetFilledPolysList(); const CPOLYGONS_LIST& polysList = aZone->GetFilledPolysList();
unsigned imax = polysList.size(); unsigned imax = polysList.size();
if( imax == 0 ) // Nothing to draw if( imax == 0 ) // Nothing to draw
...@@ -526,10 +526,10 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone ) ...@@ -526,10 +526,10 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone )
*/ */
for( unsigned ic = 0; ic < imax; ic++ ) for( unsigned ic = 0; ic < imax; ic++ )
{ {
CPolyPt* corner = &polysList[ic]; const CPolyPt& corner = polysList[ic];
cornerList.push_back( wxPoint( corner->x, corner->y) ); 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 // First, close the outline
if( cornerList[0] != cornerList[cornerList.size() - 1] ) if( cornerList[0] != cornerList[cornerList.size() - 1] )
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
*/ */
bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb, bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb,
std::vector <CPolyPt>* aCornerBuffer ) CPOLYGONS_LIST* aCornerBuffer )
{ {
if( aCornerBuffer == NULL ) if( aCornerBuffer == NULL )
m_FilledPolysList.clear(); m_FilledPolysList.clear();
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
#include <convert_basic_shapes_to_polygon.h> #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, BOARD* aPcb, ZONE_CONTAINER* aZone,
double aArcCorrection, double aArcCorrection,
int aRoundPadThermalRotation); int aRoundPadThermalRotation);
...@@ -72,7 +72,7 @@ extern void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCorn ...@@ -72,7 +72,7 @@ extern void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCorn
extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb, extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb,
ZONE_CONTAINER* aZone_container ); ZONE_CONTAINER* aZone_container );
extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer, extern void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
D_PAD& aPad, D_PAD& aPad,
int aThermalGap, int aThermalGap,
int aCopperThickness, int aCopperThickness,
...@@ -187,7 +187,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -187,7 +187,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
int item_clearance; int item_clearance;
// static to avoid unnecessary memory allocation when filling many zones. // static to avoid unnecessary memory allocation when filling many zones.
static std::vector <CPolyPt> cornerBufferPolysToSubstract; static CPOLYGONS_LIST cornerBufferPolysToSubstract;
cornerBufferPolysToSubstract.clear(); cornerBufferPolysToSubstract.clear();
/* Use a dummy pad to calculate hole clerance when a pad is not on all copper layers /* Use a dummy pad to calculate hole clerance when a pad is not on all copper layers
......
...@@ -48,11 +48,11 @@ ...@@ -48,11 +48,11 @@
* false to create the outline polygon. * false to create the outline polygon.
*/ */
void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon( void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer, CPOLYGONS_LIST& aCornerBuffer,
int aClearanceValue, bool aAddClearance ) int aClearanceValue, bool aAddClearance )
{ {
// Creates the zone outlines polygon (with linked holes if any) // Creates the zone outlines polygon (with linked holes if any)
std::vector <CPolyPt> zoneOutines; CPOLYGONS_LIST zoneOutines;
BuildFilledSolidAreasPolygons( NULL, &zoneOutines ); BuildFilledSolidAreasPolygons( NULL, &zoneOutines );
// add clearance to outline // add clearance to outline
...@@ -119,14 +119,14 @@ void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon( ...@@ -119,14 +119,14 @@ void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon(
* Function BuildUnconnectedThermalStubsPolygonList * Function BuildUnconnectedThermalStubsPolygonList
* Creates a set of polygons corresponding to stubs created by thermal shapes on pads * Creates a set of polygons corresponding to stubs created by thermal shapes on pads
* which are not connected to a zone (dangling bridges) * 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 aPcb = the board.
* @param aZone = a pointer to the ZONE_CONTAINER to examine. * @param aZone = a pointer to the ZONE_CONTAINER to examine.
* @param aArcCorrection = 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 * @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, BOARD* aPcb,
ZONE_CONTAINER* aZone, ZONE_CONTAINER* aZone,
double aArcCorrection, double aArcCorrection,
......
...@@ -143,7 +143,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -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 // test if a candidate is inside a filled area of this zone
unsigned indexstart = 0, indexend; 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++ ) for( indexend = 0; indexend < polysList.size(); indexend++ )
{ {
// end of a filled sub-area found // end of a filled sub-area found
......
...@@ -1204,7 +1204,7 @@ int CPolyLine::Distance( const wxPoint& aPoint ) ...@@ -1204,7 +1204,7 @@ int CPolyLine::Distance( const wxPoint& aPoint )
* @param aPolysList = the list of corners of contours * @param aPolysList = the list of corners of contours
* @param aPolygoneWithHole = a KI_POLYGON_WITH_HOLES to populate * @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 ) KI_POLYGON_WITH_HOLES& aPolygoneWithHole )
{ {
unsigned corners_count = aPolysList.size(); unsigned corners_count = aPolysList.size();
...@@ -1261,8 +1261,8 @@ void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList, ...@@ -1261,8 +1261,8 @@ void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
* @param aPolysListWithHoles = the list of corners of contours (haing holes * @param aPolysListWithHoles = the list of corners of contours (haing holes
* @param aOnePolyList = a polygon with no holes * @param aOnePolyList = a polygon with no holes
*/ */
void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysListWithHoles, void ConvertPolysListWithHolesToOnePolygon( const CPOLYGONS_LIST& aPolysListWithHoles,
std::vector<CPolyPt>& aOnePolyList ) CPOLYGONS_LIST& aOnePolyList )
{ {
unsigned corners_count = aPolysListWithHoles.size(); unsigned corners_count = aPolysListWithHoles.size();
...@@ -1338,9 +1338,7 @@ void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysL ...@@ -1338,9 +1338,7 @@ void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysL
aOnePolyList.push_back( corner ); aOnePolyList.push_back( corner );
} }
corner.end_contour = true; aOnePolyList.back().end_contour = true;
aOnePolyList.pop_back();
aOnePolyList.push_back( corner );
} }
/** /**
......
...@@ -76,6 +76,14 @@ public: ...@@ -76,6 +76,14 @@ public:
{ return (x != cpt2.x) || (y != cpt2.y) || (end_contour != cpt2.end_contour); } { 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 class CPolyLine
{ {
...@@ -191,7 +199,7 @@ public: ...@@ -191,7 +199,7 @@ public:
const wxPoint& GetPos( int ic ) const { return m_CornersList[ic]; } const wxPoint& GetPos( int ic ) const { return m_CornersList[ic]; }
int GetEndContour( int ic ); int GetEndContour( int ic );
int GetUtility( int ic ) const { return m_CornersList[ic].m_utility; }; int GetUtility( int ic ) const { return m_CornersList[ic].m_utility; };
void SetUtility( int ic, int utility ) { m_CornersList[ic].m_utility = utility; }; void SetUtility( int ic, int utility ) { m_CornersList[ic].m_utility = utility; };
...@@ -262,7 +270,7 @@ private: ...@@ -262,7 +270,7 @@ private:
int m_utility; // a flag used in some calculations int m_utility; // a flag used in some calculations
public: 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 std::vector <CSegment> m_HatchLines; // hatch lines showing the polygon area
}; };
...@@ -273,8 +281,8 @@ public: ...@@ -273,8 +281,8 @@ public:
* @param aPolysList = the list of corners of contours * @param aPolysList = the list of corners of contours
* @param aPolygoneWithHole = a KI_POLYGON_WITH_HOLES to populate * @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 ); KI_POLYGON_WITH_HOLES& aPolygoneWithHole );
/** /**
...@@ -286,7 +294,7 @@ void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList, ...@@ -286,7 +294,7 @@ void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
* @param aPolysListWithHoles = the list of corners of contours (haing holes * @param aPolysListWithHoles = the list of corners of contours (haing holes
* @param aOnePolyList = a polygon with no holes * @param aOnePolyList = a polygon with no holes
*/ */
void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysListWithHoles, void ConvertPolysListWithHolesToOnePolygon( const CPOLYGONS_LIST& aPolysListWithHoles,
std::vector<CPolyPt>& aOnePolyList ); CPOLYGONS_LIST& aOnePolyList );
#endif // #ifndef POLYLINE_H #endif // #ifndef POLYLINE_H
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
#define OUTSIDE false #define OUTSIDE false
#define INSIDE true #define INSIDE true
bool TestPointInsidePolygon( std::vector <CPolyPt> aPolysList, bool TestPointInsidePolygon( CPOLYGONS_LIST aPolysList,
int aIdxstart, int aIdxstart,
int aIdxend, int aIdxend,
int aRefx, int aRefx,
int aRefy) int aRefy)
/** /**
* Function TestPointInsidePolygon * Function TestPointInsidePolygon
......
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