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

Pcbnew: move files relative to autoroute/autoplace to autorouter folder.

fix nanometer compatibility.
minor code and comments cleaning (although theses files need a lot of code cleaning)
parent 64c1ea5c
......@@ -6,6 +6,7 @@ add_definitions(-DPCBNEW)
include_directories(BEFORE ${INC_BEFORE})
include_directories(
./dialogs
./autorouter
../3d-viewer
../common
${Boost_INCLUDE_DIR}
......@@ -85,16 +86,26 @@ set(PCBNEW_DIALOGS
dialogs/dialog_set_grid_base.cpp
)
set(PCBNEW_AUTOROUTER_SRCS
autorouter/automove.cpp
autorouter/autoplac.cpp
autorouter/autorout.cpp
autorouter/routing_matrix.cpp
autorouter/dist.cpp
autorouter/queue.cpp
autorouter/solve.cpp
autorouter/graphpcb.cpp
autorouter/work.cpp
)
set(PCBNEW_SRCS
${PCBNEW_AUTOROUTER_SRCS}
tool_modview.cpp
modview.cpp
modview_frame.cpp
pcbframe.cpp
attribut.cpp
automove.cpp
autoplac.cpp
autorout.cpp
board.cpp
board_items_to_polygon_shape_transform.cpp
board_undo_redo.cpp
block.cpp
......@@ -109,7 +120,6 @@ set(PCBNEW_SRCS
cross-probing.cpp
deltrack.cpp
${PCBNEW_DIALOGS}
dist.cpp
dragsegm.cpp
drc.cpp
drc_clearance_test_functions.cpp
......@@ -133,7 +143,6 @@ set(PCBNEW_SRCS
gendrill.cpp
globaleditpad.cpp
gpcb_exchange.cpp
graphpcb.cpp
highlight.cpp
hotkeys.cpp
hotkeys_board_editor.cpp
......@@ -173,10 +182,8 @@ set(PCBNEW_SRCS
plot_rtn.cpp
print_board_functions.cpp
printout_controler.cpp
queue.cpp
ratsnest.cpp
set_grid.cpp
solve.cpp
specctra.cpp
specctra_export.cpp
specctra_import.cpp
......@@ -189,7 +196,6 @@ set(PCBNEW_SRCS
tracepcb.cpp
tr_modif.cpp
trpiste.cpp
work.cpp
xchgmod.cpp
zones_convert_brd_items_to_polygons_with_Boost.cpp
zones_convert_to_polygons_aux_functions.cpp
......
/**
* @file ar_protos.h
*/
#ifndef _AR_PROTOS_H_
#define _AR_PROTOS_H_
#include <autorout.h>
class PCB_EDIT_FRAME;
class BOARD;
class D_PAD;
class RATSNEST_ITEM;
class TRACK;
int Propagation( PCB_EDIT_FRAME* frame );
/* Initialize a color value, the cells included in the board edge of the
* pad surface by pt_pad, with the margin reserved for isolation and the
* half width of the runway
* Parameters:
* Pt_pad: pointer to the description of the pad
* color: mask write in cells
* margin: add a value to the radius or half the score pad
* op_logic: type of writing in the cell (WRITE, OR)
*/
void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int type, int marge, int op_logic );
/* Draws a segment of track on the board. */
void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int type, int marge, int op_logic );
/* Uses the color value of all cells included in the board
* coord of the rectangle ux0, uy0 (top right corner)
* a ux1, uy1 (lower left corner) (coord PCB)
* the rectangle is horizontal (or vertical)
* masque_layer = mask layers;
* op_logic = WRITE_CELL, WRITE_OR_CELL, WRITE_XOR_CELL, WRITE_AND_CELL
*/
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int side, int color, int op_logic);
/* Same as above, but the rectangle is inclined angle angle. */
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int angle, int masque_layer, int color, int op_logic );
/* QUEUE.CPP */
void FreeQueue();
void InitQueue();
void GetQueue( int *, int *, int *, int *, int * );
int SetQueue( int, int, int, int, int, int, int );
void ReSetQueue( int, int, int, int, int, int, int );
/* WORK.CPP */
void InitWork();
void ReInitWork();
int SetWork( int, int, int , int, int, RATSNEST_ITEM *, int );
void GetWork( int *, int *, int *, int *, int *, RATSNEST_ITEM ** );
void SortWork(); /* order the work items; shortest first */
/* DIST.CPP */
int GetApxDist( int, int, int, int );
int CalcDist( int, int, int ,int );
/* BOARD.CPP */
int Build_Work( BOARD * Pcb );
void PlaceCells( BOARD * Pcb, int net_code, int flag = 0 );
MATRIX_CELL GetCell( int aRow, int aCol, int aSide);
void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
DIST_CELL GetDist( int aRow, int aCol, int aSide );
void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
int GetDir( int aRow, int aCol, int aSide );
void SetDir( int aRow, int aCol, int aSide, int aDir);
#endif // _AR_PROTOS_H_
......@@ -38,7 +38,7 @@
#include <pcbcommon.h>
#include <protos.h>
#include <ar_protos.h>
#include <autorout.h>
#include <cell.h>
#include <colors_selection.h>
......@@ -46,6 +46,7 @@
#include <class_module.h>
#include <class_track.h>
#include <class_drawsegment.h>
#include <convert_to_biu.h>
#define GAIN 16
......@@ -150,11 +151,11 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
lay_tmp_BOTTOM = Route_Layer_BOTTOM;
lay_tmp_TOP = Route_Layer_TOP;
Board.m_GridRouting = (int) GetScreen()->GetGridSize().x;
RoutingMatrix.m_GridRouting = (int) GetScreen()->GetGridSize().x;
// Ensure Board.m_GridRouting has a reasonable value:
if( Board.m_GridRouting < 10 )
Board.m_GridRouting = 10; // Min value = 1/1000 inch
if( RoutingMatrix.m_GridRouting < 10*IU_PER_MILS )
RoutingMatrix.m_GridRouting = 10*IU_PER_MILS; // Min value = 1/1000 inch
/* Compute module parameters used in auto place */
Module = GetBoard()->m_Modules;
......@@ -371,7 +372,7 @@ end_of_tst:
CurrPosition = memopos;
Board.UnInitBoard();
RoutingMatrix.UnInitBoard();
Route_Layer_TOP = lay_tmp_TOP;
Route_Layer_BOTTOM = lay_tmp_BOTTOM;
......@@ -397,13 +398,13 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
GRSetDrawMode( DC, GR_COPY );
for( ii = 0; ii < Board.m_Nrows; ii++ )
for( ii = 0; ii < RoutingMatrix.m_Nrows; ii++ )
{
oy = bbbox.GetY() + ( ii * Board.m_GridRouting );
oy = bbbox.GetY() + ( ii * RoutingMatrix.m_GridRouting );
for( jj = 0; jj < Board.m_Ncols; jj++ )
for( jj = 0; jj < RoutingMatrix.m_Ncols; jj++ )
{
ox = bbbox.GetX() + (jj * Board.m_GridRouting);
ox = bbbox.GetX() + (jj * RoutingMatrix.m_GridRouting);
color = BLACK;
top_state = GetCell( ii, jj, TOP );
......@@ -438,7 +439,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
EDA_ITEM* PtStruct;
wxString msg;
Board.UnInitBoard();
RoutingMatrix.UnInitBoard();
bbbox = GetBoard()->ComputeBoundingBox( true );
......@@ -449,19 +450,19 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
}
/* The boundary box must have its start point on placing grid: */
bbbox.SetX( bbbox.GetX() - ( bbbox.GetX() % Board.m_GridRouting ) );
bbbox.SetY( bbbox.GetY() - ( bbbox.GetY() % Board.m_GridRouting ) );
bbbox.SetX( bbbox.GetX() - ( bbbox.GetX() % RoutingMatrix.m_GridRouting ) );
bbbox.SetY( bbbox.GetY() - ( bbbox.GetY() % RoutingMatrix.m_GridRouting ) );
/* The boundary box must have its end point on placing grid: */
wxPoint end = bbbox.GetEnd();
end.x -= end.x % Board.m_GridRouting;
end.x += Board.m_GridRouting;
end.y -= end.y % Board.m_GridRouting;
end.y += Board.m_GridRouting;
end.x -= end.x % RoutingMatrix.m_GridRouting;
end.x += RoutingMatrix.m_GridRouting;
end.y -= end.y % RoutingMatrix.m_GridRouting;
end.y += RoutingMatrix.m_GridRouting;
bbbox.SetEnd( end );
Nrows = bbbox.GetHeight() / Board.m_GridRouting;
Ncols = bbbox.GetWidth() / Board.m_GridRouting;
Nrows = bbbox.GetHeight() / RoutingMatrix.m_GridRouting;
Ncols = bbbox.GetWidth() / RoutingMatrix.m_GridRouting;
/* get a small margin for memory allocation: */
Ncols += 2; Nrows += 2;
NbCells = Ncols * Nrows;
......@@ -480,10 +481,10 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
m_messagePanel->SetMessage( 22, wxT( "S" ),
( Nb_Sides == TWO_SIDES ) ? wxT( "2" ) : wxT( "1" ), WHITE );
Board.InitBoard();
RoutingMatrix.InitBoard();
/* Display memory usage. */
msg.Printf( wxT( "%d" ), Board.m_MemSize / 1024 );
msg.Printf( wxT( "%d" ), RoutingMatrix.m_MemSize / 1024 );
m_messagePanel->SetMessage( 24, wxT( "Mem(Kb)" ), msg, CYAN );
Route_Layer_BOTTOM = LAYER_N_FRONT;
......@@ -499,7 +500,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
TmpSegm.SetLayer( -1 );
TmpSegm.SetNet( -1 );
TmpSegm.m_Width = Board.m_GridRouting / 2;
TmpSegm.m_Width = RoutingMatrix.m_GridRouting / 2;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
......@@ -519,7 +520,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
TmpSegm.m_Param = DrawSegm->GetAngle();
TraceSegmentPcb( GetBoard(), &TmpSegm, HOLE | CELL_is_EDGE,
Board.m_GridRouting, WRITE_CELL );
RoutingMatrix.m_GridRouting, WRITE_CELL );
break;
case PCB_TEXT_T:
......@@ -543,8 +544,8 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
}
/* Initialize top layer. */
if( Board.m_BoardSide[TOP] )
memcpy( Board.m_BoardSide[TOP], Board.m_BoardSide[BOTTOM],
if( RoutingMatrix.m_BoardSide[TOP] )
memcpy( RoutingMatrix.m_BoardSide[TOP], RoutingMatrix.m_BoardSide[BOTTOM],
NbCells * sizeof(MATRIX_CELL) );
return 1;
......@@ -556,7 +557,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
{
int ox, oy, fx, fy;
int marge = Board.m_GridRouting / 2;
int marge = RoutingMatrix.m_GridRouting / 2;
int layerMask;
D_PAD* Pad;
......@@ -612,7 +613,7 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
}
/* Trace clearance. */
marge = ( Board.m_GridRouting * Module->m_PadNum ) / GAIN;
marge = ( RoutingMatrix.m_GridRouting * Module->m_PadNum ) / GAIN;
CreateKeepOutRectangle( GetBoard(), ox, oy, fx, fy, marge, KEEP_OUT_MARGIN, layerMask );
}
......@@ -643,8 +644,8 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
CurrPosition.y = bbbox.GetY() - oy;
/* Module placement on grid. */
CurrPosition.x -= CurrPosition.x % Board.m_GridRouting;
CurrPosition.y -= CurrPosition.y % Board.m_GridRouting;
CurrPosition.x -= CurrPosition.x % RoutingMatrix.m_GridRouting;
CurrPosition.y -= CurrPosition.y % RoutingMatrix.m_GridRouting;
g_Offset_Module.x = cx - CurrPosition.x;
g_Offset_Module.y = cy - CurrPosition.y;
......@@ -680,7 +681,7 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
SetStatusText( wxT( "Score ??, pos ??" ) );
for( ; CurrPosition.x < bbbox.GetRight() - fx;
CurrPosition.x += Board.m_GridRouting )
CurrPosition.x += RoutingMatrix.m_GridRouting )
{
wxYield();
......@@ -702,12 +703,12 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
CurrPosition.y = bbbox.GetY() - oy;
/* Placement on grid. */
CurrPosition.y -= CurrPosition.y % Board.m_GridRouting;
CurrPosition.y -= CurrPosition.y % RoutingMatrix.m_GridRouting;
DrawModuleOutlines( m_canvas, aDC, aModule );
for( ; CurrPosition.y < bbbox.GetBottom() - fy;
CurrPosition.y += Board.m_GridRouting )
CurrPosition.y += RoutingMatrix.m_GridRouting )
{
/* Erase traces. */
DrawModuleOutlines( m_canvas, aDC, aModule );
......@@ -785,16 +786,16 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
ux1 -= Pcb->GetBoundingBox().GetX();
uy1 -= Pcb->GetBoundingBox().GetY();
row_max = uy1 / Board.m_GridRouting;
col_max = ux1 / Board.m_GridRouting;
row_min = uy0 / Board.m_GridRouting;
row_max = uy1 / RoutingMatrix.m_GridRouting;
col_max = ux1 / RoutingMatrix.m_GridRouting;
row_min = uy0 / RoutingMatrix.m_GridRouting;
if( uy0 > row_min * Board.m_GridRouting )
if( uy0 > row_min * RoutingMatrix.m_GridRouting )
row_min++;
col_min = ux0 / Board.m_GridRouting;
col_min = ux0 / RoutingMatrix.m_GridRouting;
if( ux0 > col_min * Board.m_GridRouting )
if( ux0 > col_min * RoutingMatrix.m_GridRouting )
col_min++;
if( row_min < 0 )
......@@ -842,16 +843,16 @@ unsigned int CalculateKeepOutArea( BOARD* Pcb, int ux0, int uy0, int ux1, int uy
ux1 -= Pcb->GetBoundingBox().GetX();
uy1 -= Pcb->GetBoundingBox().GetY();
row_max = uy1 / Board.m_GridRouting;
col_max = ux1 / Board.m_GridRouting;
row_min = uy0 / Board.m_GridRouting;
row_max = uy1 / RoutingMatrix.m_GridRouting;
col_max = ux1 / RoutingMatrix.m_GridRouting;
row_min = uy0 / RoutingMatrix.m_GridRouting;
if( uy0 > row_min * Board.m_GridRouting )
if( uy0 > row_min * RoutingMatrix.m_GridRouting )
row_min++;
col_min = ux0 / Board.m_GridRouting;
col_min = ux0 / RoutingMatrix.m_GridRouting;
if( ux0 > col_min * Board.m_GridRouting )
if( ux0 > col_min * RoutingMatrix.m_GridRouting )
col_min++;
if( row_min < 0 )
......@@ -914,7 +915,7 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
return error;
}
marge = ( Board.m_GridRouting * Module->m_PadNum ) / GAIN;
marge = ( RoutingMatrix.m_GridRouting * Module->m_PadNum ) / GAIN;
return CalculateKeepOutArea( Pcb, ox - marge, oy - marge, fx + marge, fy + marge, side );
}
......@@ -1019,22 +1020,22 @@ static void CreateKeepOutRectangle( BOARD* Pcb,
ux0 -= marge; ux1 += marge;
uy0 -= marge; uy1 += marge;
pmarge = marge / Board.m_GridRouting;
pmarge = marge / RoutingMatrix.m_GridRouting;
if( pmarge < 1 )
pmarge = 1;
/* Calculate the coordinate limits of the rectangle. */
row_max = uy1 / Board.m_GridRouting;
col_max = ux1 / Board.m_GridRouting;
row_min = uy0 / Board.m_GridRouting;
row_max = uy1 / RoutingMatrix.m_GridRouting;
col_max = ux1 / RoutingMatrix.m_GridRouting;
row_min = uy0 / RoutingMatrix.m_GridRouting;
if( uy0 > row_min * Board.m_GridRouting )
if( uy0 > row_min * RoutingMatrix.m_GridRouting )
row_min++;
col_min = ux0 / Board.m_GridRouting;
col_min = ux0 / RoutingMatrix.m_GridRouting;
if( ux0 > col_min * Board.m_GridRouting )
if( ux0 > col_min * RoutingMatrix.m_GridRouting )
col_min++;
if( row_min < 0 )
......
......@@ -11,14 +11,15 @@
#include <pcbnew.h>
#include <cell.h>
#include <zones.h>
#include <ar_protos.h>
#include <class_board.h>
#include <class_module.h>
#include <class_track.h>
#include <convert_to_biu.h>
#include <autorout.h>
int E_scale; /* Scaling factor of distance tables. */
int Nb_Sides; /* Number of layer for autorouting (0 or 1) */
int Nrows = ILLEGAL;
int Ncols = ILLEGAL;
......@@ -28,8 +29,7 @@ int ClosNodes; /* total number of nodes closed */
int MoveNodes; /* total number of nodes moved */
int MaxNodes; /* maximum number of nodes opened at one time */
MATRIX_ROUTING_HEAD Board; /* 2-sided board */
MATRIX_ROUTING_HEAD RoutingMatrix; // routing matrix (grid) to route 2-sided boards
/* init board, route traces*/
void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
......@@ -139,18 +139,14 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
start = time( NULL );
/* Calculation of no fixed routing to 5 mils and more. */
Board.m_GridRouting = (int)GetScreen()->GetGridSize().x;
if( Board.m_GridRouting < 50 )
Board.m_GridRouting = 50;
RoutingMatrix.m_GridRouting = (int)GetScreen()->GetGridSize().x;
E_scale = Board.m_GridRouting / 50;
if( RoutingMatrix.m_GridRouting < (5*IU_PER_MILS) )
RoutingMatrix.m_GridRouting = 5*IU_PER_MILS;
if( E_scale < 1 )
E_scale = 1;
/* Calculated ncol and nrow, matrix size for routing. */
Board.ComputeMatrixSize( GetBoard() );
RoutingMatrix.ComputeMatrixSize( GetBoard() );
m_messagePanel->EraseMsgBox();
......@@ -160,10 +156,10 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
if( Route_Layer_TOP != Route_Layer_BOTTOM )
Nb_Sides = TWO_SIDES;
if( Board.InitBoard() < 0 )
if( RoutingMatrix.InitBoard() < 0 )
{
wxMessageBox( _( "No memory for autorouting" ) );
Board.UnInitBoard(); /* Free memory. */
RoutingMatrix.UnInitBoard(); /* Free memory. */
return;
}
......@@ -173,7 +169,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
/* Construction of the track list for router. */
Build_Work( GetBoard() );
// DisplayBoard(m_canvas, DC);
// DisplayRoutingMatrix( m_canvas, DC );
if( Nb_Sides == TWO_SIDES )
Solve( DC, TWO_SIDES ); /* double face */
......@@ -183,7 +179,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
/* Free memory. */
FreeQueue();
InitWork(); /* Free memory for the list of router connections. */
Board.UnInitBoard();
RoutingMatrix.UnInitBoard();
stop = time( NULL ) - start;
msg.Printf( wxT( "time = %d second%s" ), stop, ( stop == 1 ) ? wxT( "" ) : wxT( "s" ) );
SetStatusText( msg );
......@@ -207,13 +203,11 @@ void PCB_EDIT_FRAME::Reset_Noroutable( wxDC* DC )
/* DEBUG Function: displays the routing matrix */
void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC )
void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC )
{
int row, col, i, j;
int dcell0, dcell1 = 0, color;
int maxi;
maxi = 600 / Ncols;
int maxi = 600 / Ncols;
maxi = ( maxi * 3 ) / 4;
if( !maxi )
......@@ -221,9 +215,9 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC )
GRSetDrawMode( DC, GR_COPY );
for( col = 0; col < Ncols; col++ )
for( int col = 0; col < Ncols; col++ )
{
for( row = 0; row < Nrows; row++ )
for( int row = 0; row < Nrows; row++ )
{
color = 0;
dcell0 = GetCell( row, col, BOTTOM );
......@@ -251,8 +245,8 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC )
#define DRAW_OFFSET_Y 20
// if( color )
{
for( i = 0; i < maxi; i++ )
for( j = 0; j < maxi; j++ )
for( int i = 0; i < maxi; i++ )
for( int j = 0; j < maxi; j++ )
GRPutPixel( panel->GetClipBox(), DC,
( col * maxi ) + i + DRAW_OFFSET_X,
( row * maxi ) + j + DRAW_OFFSET_Y, color );
......
......@@ -57,8 +57,6 @@ enum CommandOpt {
};
extern int E_scale; /* Scaling factor of distance tables. */
#define ONE_SIDE 0
#define TWO_SIDES 1
......@@ -126,7 +124,7 @@ public:
void UnInitBoard();
};
extern MATRIX_ROUTING_HEAD Board; /* 2-sided board */
extern MATRIX_ROUTING_HEAD RoutingMatrix; /* 2-sided board */
/* Constants used to trace the cells on the BOARD */
......@@ -136,5 +134,78 @@ extern MATRIX_ROUTING_HEAD Board; /* 2-sided board */
#define WRITE_AND_CELL 3
#define WRITE_ADD_CELL 4
// Functions:
class PCB_EDIT_FRAME;
class BOARD;
class D_PAD;
class RATSNEST_ITEM;
class TRACK;
int Propagation( PCB_EDIT_FRAME* frame );
/* Initialize a color value, the cells included in the board edge of the
* pad surface by pt_pad, with the margin reserved for isolation and the
* half width of the runway
* Parameters:
* Pt_pad: pointer to the description of the pad
* color: mask write in cells
* margin: add a value to the radius or half the score pad
* op_logic: type of writing in the cell (WRITE, OR)
*/
void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int type, int marge, int op_logic );
/* Draws a segment of track on the board. */
void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int type, int marge, int op_logic );
/* Uses the color value of all cells included in the board
* coord of the rectangle ux0, uy0 (top right corner)
* a ux1, uy1 (lower left corner) (coord PCB)
* the rectangle is horizontal (or vertical)
* masque_layer = mask layers;
* op_logic = WRITE_CELL, WRITE_OR_CELL, WRITE_XOR_CELL, WRITE_AND_CELL
*/
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int side, int color, int op_logic);
/* Same as above, but the rectangle is inclined angle angle. */
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int angle, int masque_layer, int color, int op_logic );
/* QUEUE.CPP */
void FreeQueue();
void InitQueue();
void GetQueue( int *, int *, int *, int *, int * );
int SetQueue( int, int, int, int, int, int, int );
void ReSetQueue( int, int, int, int, int, int, int );
/* WORK.CPP */
void InitWork();
void ReInitWork();
int SetWork( int, int, int , int, int, RATSNEST_ITEM *, int );
void GetWork( int *, int *, int *, int *, int *, RATSNEST_ITEM ** );
void SortWork(); /* order the work items; shortest first */
/* DIST.CPP */
int GetApxDist( int r1, int c1, int r2, int c2 );
int CalcDist(int x,int y,int z ,int side );
/* BOARD.CPP */
int Build_Work( BOARD * Pcb );
void PlaceCells( BOARD * Pcb, int net_code, int flag = 0 );
MATRIX_CELL GetCell( int aRow, int aCol, int aSide);
void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
DIST_CELL GetDist( int aRow, int aCol, int aSide );
void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
int GetDir( int aRow, int aCol, int aSide );
void SetDir( int aRow, int aCol, int aSide, int aDir);
#endif // AUTOROUT_H
......@@ -3,20 +3,17 @@
* @brief Routines to calculate PCB editor auto routing distances.
*/
#include <fctsys.h>
#include <macros.h>
#include <common.h>
#include <pcbnew.h>
#include <autorout.h>
#include <cell.h>
/* The tables of distances and keep out areas are established on the basis of not
* routing of 50 units (the pitch between the cells is 50 units) The true distance
* is computed by a scaling factor
/* The tables of distances and keep out areas are established on the basis of a
* 50 units grid size (the pitch between the cells is 50 units).
* The actual distance could be computed by a scaling factor, but this is
* not needed, we can use only reduced values
*/
/* calculate approximate distance
/* calculate approximate distance (manhattan distance)
*/
int GetApxDist( int r1, int c1, int r2, int c2 )
{
......@@ -28,27 +25,13 @@ int GetApxDist( int r1, int c1, int r2, int c2 )
if( ( d2 = c1 - c2 ) < 0 ) /* get absolute column delta */
d2 = -d2;
return ( d1+d2 ) * 50 * E_scale;
if( !d1 ) /* in same row? */
return d2 * 50 * E_scale; /* 50 mils per cell */
if( !d2 ) /* in same column? */
return d1 *50 * E_scale; /* 50 mils per cell */
if( d1 > d2 ) /* get smaller into d1 */
{
EXCHG(d1,d2);
}
d2 -= d1; /* get non-diagonal part of approximate "route" */
return ( ( ( d1 * 71 ) + ( d2 * 50 ) ) * E_scale ); /* 71 mils diagonally per cell */
return ( d1+d2 ) * 50;
}
/* distance to go thru a cell (en mils) */
static int dist[10][10] = { /* OT=Otherside, OR=Origin (source) cell */
static const int dist[10][10] =
{ /* OT=Otherside, OR=Origin (source) cell */
/*..........N, NE, E, SE, S, SW, W, NW, OT, OR */
/* N */ { 50, 60, 35, 60, 99, 60, 35, 60, 12, 12 },
/* NE */ { 60, 71, 60, 71, 60, 99, 60, 71, 23, 23 },
......@@ -61,10 +44,11 @@ static int dist[10][10] = { /* OT=Otherside, OR=Origin (source) cell */
/* OT */ { 12, 23, 12, 23, 12, 23, 12, 23, 99, 99 },
/* OR */ { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }
};
};
/* penalty for extraneous holes and corners, scaled by sharpness of turn */
static int penalty[10][10] = { /* OT=Otherside, OR=Origin (source) cell */
static const int penalty[10][10] =
{ /* OT=Otherside, OR=Origin (source) cell */
/*......... N, NE, E, SE, S, SW, W, NW, OT, OR */
/* N */ { 0, 5, 10, 15, 20, 15, 10, 5, 50, 0 },
/* NE */ { 5, 0, 5, 10, 15, 20, 15, 10, 50, 0 },
......@@ -77,11 +61,12 @@ static int penalty[10][10] = { /* OT=Otherside, OR=Origin (source) cell */
/* OT */ { 50, 50, 50, 50, 50, 50, 50, 50, 100, 0 },
/* OR */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
};
/* penalty pour directions preferencielles */
#define PN 20
static int dir_penalty_TOP[10][10] = {
static const int dir_penalty_TOP[10][10] =
{
/* OT=Otherside, OR=Origin (source) cell */
/*......... N, NE, E, SE, S, SW, W, NW, OT, OR */
/* N */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 },
......@@ -95,9 +80,10 @@ static int dir_penalty_TOP[10][10] = {
/* OT */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 },
/* OR */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }
};
};
static int dir_penalty_BOTTOM[10][10] = {
static int dir_penalty_BOTTOM[10][10] =
{
/* OT=Otherside, OR=Origin (source) cell */
/*......... N, NE, E, SE, S, SW, W, NW, OT, OR */
/* N */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 },
......@@ -111,7 +97,7 @@ static int dir_penalty_BOTTOM[10][10] = {
/* OT */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 },
/* OR */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }
};
};
/*
** x is the direction to enter the cell of interest.
......@@ -122,11 +108,9 @@ static int dir_penalty_BOTTOM[10][10] = {
** the calculation is driven by the tables above.
*/
/************************************/
/* int CalcDist(int x,int y,int z ) */
/************************************/
/* calculate distance of a trace through a cell */
/* calculate distance (with penalty) of a trace through a cell
*/
int CalcDist(int x,int y,int z ,int side )
{
int adjust, ldist;
......
......@@ -13,38 +13,25 @@
#include <class_track.h>
#include <pcbnew.h>
#include <autorout.h>
#include <cell.h>
#include <ar_protos.h>
int ToMatrixCoordinate( int aPhysicalCoordinate );
void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color );
void TraceArc( int ux0,
int uy0,
int ux1,
int uy1,
void TraceArc( int ux0, int uy0,
int ux1, int uy1,
int ArcAngle,
int lg,
int layer,
int color,
int lg, int layer, int color,
int op_logic );
static void DrawSegmentQcq( int ux0,
int uy0,
int ux1,
int uy1,
int lg,
int layer,
int color,
static void DrawSegmentQcq( int ux0, int uy0,
int ux1, int uy1,
int lg, int layer, int color,
int op_logic );
static void TraceFilledCircle( BOARD* aPcb,
int cx,
int cy,
int radius,
int cx, int cy, int radius,
int aLayerMask,
int color,
int op_logic );
......@@ -71,19 +58,6 @@ static void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
} \
}
/**
* Function ToMatrixCoordinate
* compute the coordinate in the routing matrix from the real (board) value
* @param aPhysicalCoordinate = value to convert
* @return the coordinate relative to the matrix
*/
int ToMatrixCoordinate( int aPhysicalCoordinate )
{
return aPhysicalCoordinate / Board.m_GridRouting;
}
void PlacePad( BOARD* aPcb, D_PAD* aPad, int color, int marge, int op_logic )
{
int dx, dy;
......@@ -108,7 +82,7 @@ void PlacePad( BOARD* aPcb, D_PAD* aPad, int color, int marge, int op_logic )
dy += abs( aPad->GetDelta().x ) / 2;
}
// The pad is a rectangle horizontally or vertically.
// The pad is a rectangle ( horizontal or vertical )
if( int( aPad->GetOrientation() ) % 900 == 0 )
{
// Orientation turned 90 deg.
......@@ -131,18 +105,16 @@ void PlacePad( BOARD* aPcb, D_PAD* aPad, int color, int marge, int op_logic )
}
/* Initialize a color value, the cells included in the board area of the
* circle center cx, cy.
/* Set to color the cells included in the circle
* Parameters:
* center: cx, cy.
* radius: a value add to the radius or half the score pad
* aLayerMask: layer occupied
* color: mask write in cells
* op_logic: type of writing in the cell (WRITE, OR)
*/
void TraceFilledCircle( BOARD* aPcb,
int cx,
int cy,
int radius,
int cx, int cy, int radius,
int aLayerMask,
int color,
int op_logic )
......@@ -151,17 +123,12 @@ void TraceFilledCircle( BOARD* aPcb,
int ux0, uy0, ux1, uy1;
int row_max, col_max, row_min, col_min;
int trace = 0;
float fdistmin, fdistx, fdisty;
double fdistmin, fdistx, fdisty;
void (* WriteCell)( int, int, int, MATRIX_CELL );
int tstwrite = 0;
int distmin;
// Determine occupied layer.
/* Single routing layer on bitmap and BOTTOM
* Route_Layer_B = Route_Layer_A */
if( aLayerMask & GetLayerMask( Route_Layer_BOTTOM ) )
trace = 1; // Trace on BOTTOM
......@@ -208,10 +175,10 @@ void TraceFilledCircle( BOARD* aPcb,
uy1 = cy + radius;
// Calculate limit coordinates of cells belonging to the rectangle.
row_max = uy1 / Board.m_GridRouting;
col_max = ux1 / Board.m_GridRouting;
row_min = uy0 / Board.m_GridRouting; // if (uy0 > row_min*Board.m_GridRouting) row_min++;
col_min = ux0 / Board.m_GridRouting; // if (ux0 > col_min*Board.m_GridRouting) col_min++;
row_max = uy1 / RoutingMatrix.m_GridRouting;
col_max = ux1 / RoutingMatrix.m_GridRouting;
row_min = uy0 / RoutingMatrix.m_GridRouting; // if (uy0 > row_min*Board.m_GridRouting) row_min++;
col_min = ux0 / RoutingMatrix.m_GridRouting; // if (ux0 > col_min*Board.m_GridRouting) col_min++;
if( row_min < 0 )
row_min = 0;
......@@ -232,16 +199,16 @@ void TraceFilledCircle( BOARD* aPcb,
if( col_min > col_max )
col_max = col_min;
fdistmin = (float) distmin * distmin;
fdistmin = (double) distmin * distmin;
for( row = row_min; row <= row_max; row++ )
{
fdisty = (float) ( cy - ( row * Board.m_GridRouting ) );
fdisty = (double) ( cy - ( row * RoutingMatrix.m_GridRouting ) );
fdisty *= fdisty;
for( col = col_min; col <= col_max; col++ )
{
fdistx = (float) ( cx - ( col * Board.m_GridRouting ) );
fdistx = (double) ( cx - ( col * RoutingMatrix.m_GridRouting ) );
fdistx *= fdistx;
if( fdistmin <= ( fdistx + fdisty ) )
......@@ -263,17 +230,17 @@ void TraceFilledCircle( BOARD* aPcb,
/* If no cell has been written, it affects the 4 neighboring diagonal
* (Adverse event: pad off grid in the center of the 4 neighboring
* diagonal) */
distmin = Board.m_GridRouting / 2 + 1;
fdistmin = ( (float) distmin * distmin ) * 2; // Distance to center point diagonally
distmin = RoutingMatrix.m_GridRouting / 2 + 1;
fdistmin = ( (double) distmin * distmin ) * 2; // Distance to center point diagonally
for( row = row_min; row <= row_max; row++ )
{
fdisty = (float) ( cy - ( row * Board.m_GridRouting ) );
fdisty = (double) ( cy - ( row * RoutingMatrix.m_GridRouting ) );
fdisty *= fdisty;
for( col = col_min; col <= col_max; col++ )
{
fdistx = (float) ( cx - ( col * Board.m_GridRouting ) );
fdistx = (double) ( cx - ( col * RoutingMatrix.m_GridRouting ) );
fdistx *= fdistx;
if( fdistmin <= ( fdistx + fdisty ) )
......@@ -391,9 +358,9 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_
if( y1 < y0 )
EXCHG( y0, y1 );
dy = y0 / Board.m_GridRouting;
lim = y1 / Board.m_GridRouting;
dx = x0 / Board.m_GridRouting;
dy = y0 / RoutingMatrix.m_GridRouting;
lim = y1 / RoutingMatrix.m_GridRouting;
dx = x0 / RoutingMatrix.m_GridRouting;
// Clipping limits of board.
if( ( dx < 0 ) || ( dx >= Ncols ) )
......@@ -418,9 +385,9 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_
if( x1 < x0 )
EXCHG( x0, x1 );
dx = x0 / Board.m_GridRouting;
lim = x1 / Board.m_GridRouting;
dy = y0 / Board.m_GridRouting;
dx = x0 / RoutingMatrix.m_GridRouting;
lim = x1 / RoutingMatrix.m_GridRouting;
dy = y0 / RoutingMatrix.m_GridRouting;
// Clipping limits of board.
if( ( dy < 0 ) || ( dy >= Nrows ) )
......@@ -448,16 +415,16 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_
EXCHG( x1, x0 ); EXCHG( y1, y0 );
}
dx = x0 / Board.m_GridRouting;
lim = x1 / Board.m_GridRouting;
dy = y0 / Board.m_GridRouting;
dx = x0 / RoutingMatrix.m_GridRouting;
lim = x1 / RoutingMatrix.m_GridRouting;
dy = y0 / RoutingMatrix.m_GridRouting;
inc = 1;
if( y1 < y0 )
inc = -1;
il = lim - dx; cumul = il / 2;
delta = abs( y1 - y0 ) / Board.m_GridRouting;
delta = abs( y1 - y0 ) / RoutingMatrix.m_GridRouting;
for( ; dx <= lim; )
{
......@@ -484,16 +451,17 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_
EXCHG( y1, y0 );
}
dy = y0 / Board.m_GridRouting;
lim = y1 / Board.m_GridRouting;
dx = x0 / Board.m_GridRouting;
dy = y0 / RoutingMatrix.m_GridRouting;
lim = y1 / RoutingMatrix.m_GridRouting;
dx = x0 / RoutingMatrix.m_GridRouting;
inc = 1;
if( x1 < x0 )
inc = -1;
il = lim - dy; cumul = il / 2;
delta = abs( x1 - x0 ) / Board.m_GridRouting;
il = lim - dy;
cumul = il / 2;
delta = abs( x1 - x0 ) / RoutingMatrix.m_GridRouting;
for( ; dy <= lim; )
{
......@@ -563,16 +531,16 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
uy1 -= aPcb->GetBoundingBox().GetY();
// Calculating limits coord cells belonging to the rectangle.
row_max = uy1 / Board.m_GridRouting;
col_max = ux1 / Board.m_GridRouting;
row_min = uy0 / Board.m_GridRouting;
row_max = uy1 / RoutingMatrix.m_GridRouting;
col_max = ux1 / RoutingMatrix.m_GridRouting;
row_min = uy0 / RoutingMatrix.m_GridRouting;
if( uy0 > row_min * Board.m_GridRouting )
if( uy0 > row_min * RoutingMatrix.m_GridRouting )
row_min++;
col_min = ux0 / Board.m_GridRouting;
col_min = ux0 / RoutingMatrix.m_GridRouting;
if( ux0 > col_min * Board.m_GridRouting )
if( ux0 > col_min * RoutingMatrix.m_GridRouting )
col_min++;
if( row_min < 0 )
......@@ -660,16 +628,16 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
+ (double) ( cy - uy0 ) * ( cy - uy0 ) );
// Calculating coordinate limits belonging to the rectangle.
row_max = ( cy + radius ) / Board.m_GridRouting;
col_max = ( cx + radius ) / Board.m_GridRouting;
row_min = ( cy - radius ) / Board.m_GridRouting;
row_max = ( cy + radius ) / RoutingMatrix.m_GridRouting;
col_max = ( cx + radius ) / RoutingMatrix.m_GridRouting;
row_min = ( cy - radius ) / RoutingMatrix.m_GridRouting;
if( uy0 > row_min * Board.m_GridRouting )
if( uy0 > row_min * RoutingMatrix.m_GridRouting )
row_min++;
col_min = ( cx - radius ) / Board.m_GridRouting;
col_min = ( cx - radius ) / RoutingMatrix.m_GridRouting;
if( ux0 > col_min * Board.m_GridRouting )
if( ux0 > col_min * RoutingMatrix.m_GridRouting )
col_min++;
if( row_min < 0 )
......@@ -688,8 +656,8 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
{
for( col = col_min; col <= col_max; col++ )
{
rotrow = row * Board.m_GridRouting;
rotcol = col * Board.m_GridRouting;
rotrow = row * RoutingMatrix.m_GridRouting;
rotcol = col * RoutingMatrix.m_GridRouting;
RotatePoint( &rotcol, &rotrow, cx, cy, -angle );
if( rotrow <= uy0 )
......@@ -715,9 +683,8 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
/* Fills all cells inside a segment
* half-width lg, org ux, ux end y0, y1
* is set to color.
* coordinates are in PCB units (0.1 mil) are relative to the Board
* half-width = lg, org = ux0,uy0 end = ux1,uy1
* coordinates are in PCB units
*/
void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
int color, int op_logic )
......@@ -768,27 +735,27 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
if( uy1 < uy0 )
inc = -1;
demi_pas = Board.m_GridRouting / 2;
demi_pas = RoutingMatrix.m_GridRouting / 2;
col_min = ( ux0 - lg ) / Board.m_GridRouting;
col_min = ( ux0 - lg ) / RoutingMatrix.m_GridRouting;
if( col_min < 0 )
col_min = 0;
col_max = ( ux1 + lg + demi_pas ) / Board.m_GridRouting;
col_max = ( ux1 + lg + demi_pas ) / RoutingMatrix.m_GridRouting;
if( col_max > ( Ncols - 1 ) )
col_max = Ncols - 1;
if( inc > 0 )
{
row_min = ( uy0 - lg ) / Board.m_GridRouting;
row_max = ( uy1 + lg + demi_pas ) / Board.m_GridRouting;
row_min = ( uy0 - lg ) / RoutingMatrix.m_GridRouting;
row_max = ( uy1 + lg + demi_pas ) / RoutingMatrix.m_GridRouting;
}
else
{
row_min = ( uy1 - lg ) / Board.m_GridRouting;
row_max = ( uy0 + lg + demi_pas ) / Board.m_GridRouting;
row_min = ( uy1 - lg ) / RoutingMatrix.m_GridRouting;
row_max = ( uy0 + lg + demi_pas ) / RoutingMatrix.m_GridRouting;
}
if( row_min < 0 )
......@@ -823,11 +790,11 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
for( col = col_min; col <= col_max; col++ )
{
int cxr;
cxr = ( col * Board.m_GridRouting ) - ux0;
cxr = ( col * RoutingMatrix.m_GridRouting ) - ux0;
for( row = row_min; row <= row_max; row++ )
{
cy = (row * Board.m_GridRouting) - uy0;
cy = (row * RoutingMatrix.m_GridRouting) - uy0;
cx = cxr;
RotatePoint( &cx, &cy, angle );
......@@ -864,10 +831,9 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
}
/* Fills all cells BOARD contained in the circle
* half-width lg center ux, ux through y0, y1 is set to color.
* coord in PCB units (0.1 million) relating to the origin
* pt_pcb-> m_PcbBox.m_Xmin, Y's board.
/* Fills all cells of the routing matrix contained in the circle
* half-width = lg, center = ux0, uy0, ux1,uy1 is a point on the circle.
* coord are in PCB units.
*/
void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
int color, int op_logic )
......@@ -908,9 +874,10 @@ void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
}
/* Fills all BOARD cells contained in the arc of "L" angle half-width lg
* ux center, starting in ux y0, y1 is set to color. Coordinates are in
* PCB units (0.1 mil) relating to the origin pt_pcb-> Pcb_oX, Y's board.
/* Fills all routing matrix cells contained in the arc
* angle = ArcAngle, half-width lg
* center = ux0,uy0, starting at ux1, uy1. Coordinates are in
* PCB units.
*/
void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg,
int layer, int color, int op_logic )
......
......@@ -34,7 +34,7 @@
#include <pcbnew.h>
#include <cell.h>
#include <ar_protos.h>
#include <autorout.h>
#include <class_board.h>
#include <class_module.h>
......@@ -342,7 +342,7 @@ int Build_Work( BOARD* Pcb )
D_PAD* pt_pad;
int r1, r2, c1, c2, current_net_code;
RATSNEST_ITEM* pt_ch;
int demi_pas = Board.m_GridRouting / 2;
int demi_pas = RoutingMatrix.m_GridRouting / 2;
wxString msg;
EDA_RECT bbbox = Pcb->GetBoundingBox();
......@@ -371,7 +371,7 @@ int Build_Work( BOARD* Pcb )
current_net_code = pt_pad->GetNet();
pt_ch = pt_rats;
r1 = ( pt_pad->GetPosition().y - bbbox.GetY() + demi_pas ) / Board.m_GridRouting;
r1 = ( pt_pad->GetPosition().y - bbbox.GetY() + demi_pas ) / RoutingMatrix.m_GridRouting;
if( r1 < 0 || r1 >= Nrows )
{
......@@ -381,7 +381,7 @@ int Build_Work( BOARD* Pcb )
return 0;
}
c1 = ( pt_pad->GetPosition().x - bbbox.GetX() + demi_pas ) / Board.m_GridRouting;
c1 = ( pt_pad->GetPosition().x - bbbox.GetX() + demi_pas ) / RoutingMatrix.m_GridRouting;
if( c1 < 0 || c1 >= Ncols )
{
......@@ -394,7 +394,7 @@ int Build_Work( BOARD* Pcb )
pt_pad = pt_rats->m_PadEnd;
r2 = ( pt_pad->GetPosition().y - bbbox.GetY()
+ demi_pas ) / Board.m_GridRouting;
+ demi_pas ) / RoutingMatrix.m_GridRouting;
if( r2 < 0 || r2 >= Nrows )
{
......@@ -404,7 +404,7 @@ int Build_Work( BOARD* Pcb )
return 0;
}
c2 = ( pt_pad->GetPosition().x - bbbox.GetX() + demi_pas ) / Board.m_GridRouting;
c2 = ( pt_pad->GetPosition().x - bbbox.GetX() + demi_pas ) / RoutingMatrix.m_GridRouting;
if( c2 < 0 || c2 >= Ncols )
{
......@@ -429,7 +429,7 @@ MATRIX_CELL GetCell( int aRow, int aCol, int aSide )
{
MATRIX_CELL* p;
p = Board.m_BoardSide[aSide];
p = RoutingMatrix.m_BoardSide[aSide];
return p[aRow * Ncols + aCol];
}
......@@ -440,7 +440,7 @@ void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
MATRIX_CELL* p;
p = Board.m_BoardSide[aSide];
p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] = x;
}
......@@ -451,7 +451,7 @@ void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
MATRIX_CELL* p;
p = Board.m_BoardSide[aSide];
p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] |= x;
}
......@@ -462,7 +462,7 @@ void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
MATRIX_CELL* p;
p = Board.m_BoardSide[aSide];
p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] ^= x;
}
......@@ -473,7 +473,7 @@ void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
MATRIX_CELL* p;
p = Board.m_BoardSide[aSide];
p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] &= x;
}
......@@ -484,7 +484,7 @@ void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
MATRIX_CELL* p;
p = Board.m_BoardSide[aSide];
p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] += x;
}
......@@ -494,7 +494,7 @@ DIST_CELL GetDist( int aRow, int aCol, int aSide ) /* fetch distance cell */
{
DIST_CELL* p;
p = Board.m_DistSide[aSide];
p = RoutingMatrix.m_DistSide[aSide];
return p[aRow * Ncols + aCol];
}
......@@ -504,7 +504,7 @@ void SetDist( int aRow, int aCol, int aSide, DIST_CELL x )
{
DIST_CELL* p;
p = Board.m_DistSide[aSide];
p = RoutingMatrix.m_DistSide[aSide];
p[aRow * Ncols + aCol] = x;
}
......@@ -514,7 +514,7 @@ int GetDir( int aRow, int aCol, int aSide )
{
DIR_CELL* p;
p = Board.m_DirSide[aSide];
p = RoutingMatrix.m_DirSide[aSide];
return (int) (p[aRow * Ncols + aCol]);
}
......@@ -524,6 +524,6 @@ void SetDir( int aRow, int aCol, int aSide, int x )
{
DIR_CELL* p;
p = Board.m_DirSide[aSide];
p = RoutingMatrix.m_DirSide[aSide];
p[aRow * Ncols + aCol] = (char) x;
}
......@@ -40,7 +40,7 @@
#include <pcbnew.h>
#include <protos.h>
#include <ar_protos.h>
#include <autorout.h>
#include <cell.h>
......@@ -104,7 +104,7 @@ static PICKED_ITEMS_LIST s_ItemsListPicker;
* [] [0] = row [] (1] = col was added to the coord of the midpoint for
* Get the coord of the 8 neighboring points.
*/
static int delta[8][2] =
static const int delta[8][2] =
{
{ 1, -1 }, /* northwest */
{ 1, 0 }, /* north */
......@@ -116,7 +116,7 @@ static int delta[8][2] =
{ -1, 1 } /* southeast */
};
static int ndir[8] =
static const int ndir[8] =
{
/* for building paths back to source */
FROM_SOUTHEAST, FROM_SOUTH, FROM_SOUTHWEST,
......@@ -316,10 +316,10 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
}
pt_cur_ch = pt_cur_ch;
segm_oX = GetBoard()->GetBoundingBox().GetX() + (Board.m_GridRouting * col_source);
segm_oY = GetBoard()->GetBoundingBox().GetY() + (Board.m_GridRouting * row_source);
segm_fX = GetBoard()->GetBoundingBox().GetX() + (Board.m_GridRouting * col_target);
segm_fY = GetBoard()->GetBoundingBox().GetY() + (Board.m_GridRouting * row_target);
segm_oX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_source);
segm_oY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_source);
segm_fX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_target);
segm_fY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_target);
/* Draw segment. */
GRLine( m_canvas->GetClipBox(),
......@@ -434,8 +434,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
/* clear direction flags */
i = Nrows * Ncols * sizeof(DIR_CELL);
memset( Board.m_DirSide[TOP], FROM_NOWHERE, i );
memset( Board.m_DirSide[BOTTOM], FROM_NOWHERE, i );
memset( RoutingMatrix.m_DirSide[TOP], FROM_NOWHERE, i );
memset( RoutingMatrix.m_DirSide[BOTTOM], FROM_NOWHERE, i );
lastopen = lastclos = lastmove = 0;
......@@ -467,9 +467,9 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
* On the routing grid (1 grid point must be in the pad)
*/
{
int cX = ( Board.m_GridRouting * col_source )
int cX = ( RoutingMatrix.m_GridRouting * col_source )
+ pcbframe->GetBoard()->GetBoundingBox().GetX();
int cY = ( Board.m_GridRouting * row_source )
int cY = ( RoutingMatrix.m_GridRouting * row_source )
+ pcbframe->GetBoard()->GetBoundingBox().GetY();
int dx = pt_cur_ch->m_PadStart->GetSize().x / 2;
int dy = pt_cur_ch->m_PadStart->GetSize().y / 2;
......@@ -482,9 +482,9 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) )
goto end_of_route;
cX = ( Board.m_GridRouting * col_target )
cX = ( RoutingMatrix.m_GridRouting * col_target )
+ pcbframe->GetBoard()->GetBoundingBox().GetX();
cY = ( Board.m_GridRouting * row_target )
cY = ( RoutingMatrix.m_GridRouting * row_target )
+ pcbframe->GetBoard()->GetBoundingBox().GetY();
dx = pt_cur_ch->m_PadEnd->GetSize().x / 2;
dy = pt_cur_ch->m_PadEnd->GetSize().y / 2;
......@@ -1171,11 +1171,11 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
g_CurrentTrackSegment->m_Start.x =
g_CurrentTrackSegment->m_End.x = pcb->GetBoundingBox().GetX() +
( Board.m_GridRouting * row );
( RoutingMatrix.m_GridRouting * row );
g_CurrentTrackSegment->m_Start.y =
g_CurrentTrackSegment->m_End.y = pcb->GetBoundingBox().GetY() +
( Board.m_GridRouting * col );
( RoutingMatrix.m_GridRouting * col );
g_CurrentTrackSegment->m_Width = pcb->GetCurrentViaSize();
g_CurrentTrackSegment->m_Shape = pcb->GetDesignSettings().m_CurrentViaType;
......@@ -1195,9 +1195,9 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
g_CurrentTrackSegment->SetState( TRACK_AR, ON );
g_CurrentTrackSegment->m_End.x = pcb->GetBoundingBox().GetX() +
( Board.m_GridRouting * row );
( RoutingMatrix.m_GridRouting * row );
g_CurrentTrackSegment->m_End.y = pcb->GetBoundingBox().GetY() +
( Board.m_GridRouting * col );
( RoutingMatrix.m_GridRouting * col );
g_CurrentTrackSegment->SetNet( current_net_code );
if( g_CurrentTrackSegment->Back() == NULL ) /* Start trace. */
......
......@@ -32,8 +32,8 @@
#include <common.h>
#include <pcbnew.h>
#include <autorout.h>
#include <cell.h>
#include <ar_protos.h>
struct CWORK /* a unit of work is a hole-pair to connect */
......@@ -57,12 +57,6 @@ static CWORK* Tail = NULL;
static CWORK* Current = NULL;
void InitWork();
void ReInitWork();
int SetWork( int, int, int, int, int, RATSNEST_ITEM*, int );
void GetWork( int*, int*, int*, int*, int*, RATSNEST_ITEM** );
void SortWork();
/* initialize the work list */
void InitWork()
......@@ -220,14 +214,14 @@ void SortWork()
}
/* Calculate the cost of a net:
/* Calculate the cost of a ratsnest:
* cost = (| dx | + | dy |) * disability
* disability = 1 if dx or dy = 0, max if | dx | # | dy |
*/
static int GetCost( int r1, int c1, int r2, int c2 )
{
int dx, dy, mx, my;
float incl;
double incl;
dx = abs( c2 - c1 );
dy = abs( r2 - r1 );
......@@ -241,7 +235,7 @@ static int GetCost( int r1, int c1, int r2, int c2 )
}
if( mx )
incl += (2 * (float) my / mx);
incl += (2 * (double) my / mx);
return (int) ( ( dx + dy ) * incl );
}
......@@ -15,7 +15,6 @@
#include <pcbnew.h>
#include <dialog_exchange_modules_base.h>
#include <ar_protos.h>
#include <wildcards_and_files_ext.h>
static char* quiet_gcc_4_4_3; // GCC 4.4.3 and next ..
......
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