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) ...@@ -6,6 +6,7 @@ add_definitions(-DPCBNEW)
include_directories(BEFORE ${INC_BEFORE}) include_directories(BEFORE ${INC_BEFORE})
include_directories( include_directories(
./dialogs ./dialogs
./autorouter
../3d-viewer ../3d-viewer
../common ../common
${Boost_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
...@@ -85,16 +86,26 @@ set(PCBNEW_DIALOGS ...@@ -85,16 +86,26 @@ set(PCBNEW_DIALOGS
dialogs/dialog_set_grid_base.cpp 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 set(PCBNEW_SRCS
${PCBNEW_AUTOROUTER_SRCS}
tool_modview.cpp tool_modview.cpp
modview.cpp modview.cpp
modview_frame.cpp modview_frame.cpp
pcbframe.cpp pcbframe.cpp
attribut.cpp attribut.cpp
automove.cpp
autoplac.cpp
autorout.cpp
board.cpp
board_items_to_polygon_shape_transform.cpp board_items_to_polygon_shape_transform.cpp
board_undo_redo.cpp board_undo_redo.cpp
block.cpp block.cpp
...@@ -109,7 +120,6 @@ set(PCBNEW_SRCS ...@@ -109,7 +120,6 @@ set(PCBNEW_SRCS
cross-probing.cpp cross-probing.cpp
deltrack.cpp deltrack.cpp
${PCBNEW_DIALOGS} ${PCBNEW_DIALOGS}
dist.cpp
dragsegm.cpp dragsegm.cpp
drc.cpp drc.cpp
drc_clearance_test_functions.cpp drc_clearance_test_functions.cpp
...@@ -133,7 +143,6 @@ set(PCBNEW_SRCS ...@@ -133,7 +143,6 @@ set(PCBNEW_SRCS
gendrill.cpp gendrill.cpp
globaleditpad.cpp globaleditpad.cpp
gpcb_exchange.cpp gpcb_exchange.cpp
graphpcb.cpp
highlight.cpp highlight.cpp
hotkeys.cpp hotkeys.cpp
hotkeys_board_editor.cpp hotkeys_board_editor.cpp
...@@ -173,10 +182,8 @@ set(PCBNEW_SRCS ...@@ -173,10 +182,8 @@ set(PCBNEW_SRCS
plot_rtn.cpp plot_rtn.cpp
print_board_functions.cpp print_board_functions.cpp
printout_controler.cpp printout_controler.cpp
queue.cpp
ratsnest.cpp ratsnest.cpp
set_grid.cpp set_grid.cpp
solve.cpp
specctra.cpp specctra.cpp
specctra_export.cpp specctra_export.cpp
specctra_import.cpp specctra_import.cpp
...@@ -189,7 +196,6 @@ set(PCBNEW_SRCS ...@@ -189,7 +196,6 @@ set(PCBNEW_SRCS
tracepcb.cpp tracepcb.cpp
tr_modif.cpp tr_modif.cpp
trpiste.cpp trpiste.cpp
work.cpp
xchgmod.cpp xchgmod.cpp
zones_convert_brd_items_to_polygons_with_Boost.cpp zones_convert_brd_items_to_polygons_with_Boost.cpp
zones_convert_to_polygons_aux_functions.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 @@ ...@@ -38,7 +38,7 @@
#include <pcbcommon.h> #include <pcbcommon.h>
#include <protos.h> #include <protos.h>
#include <ar_protos.h> #include <autorout.h>
#include <cell.h> #include <cell.h>
#include <colors_selection.h> #include <colors_selection.h>
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <class_module.h> #include <class_module.h>
#include <class_track.h> #include <class_track.h>
#include <class_drawsegment.h> #include <class_drawsegment.h>
#include <convert_to_biu.h>
#define GAIN 16 #define GAIN 16
...@@ -150,11 +151,11 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) ...@@ -150,11 +151,11 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
lay_tmp_BOTTOM = Route_Layer_BOTTOM; lay_tmp_BOTTOM = Route_Layer_BOTTOM;
lay_tmp_TOP = Route_Layer_TOP; 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: // Ensure Board.m_GridRouting has a reasonable value:
if( Board.m_GridRouting < 10 ) if( RoutingMatrix.m_GridRouting < 10*IU_PER_MILS )
Board.m_GridRouting = 10; // Min value = 1/1000 inch RoutingMatrix.m_GridRouting = 10*IU_PER_MILS; // Min value = 1/1000 inch
/* Compute module parameters used in auto place */ /* Compute module parameters used in auto place */
Module = GetBoard()->m_Modules; Module = GetBoard()->m_Modules;
...@@ -371,7 +372,7 @@ end_of_tst: ...@@ -371,7 +372,7 @@ end_of_tst:
CurrPosition = memopos; CurrPosition = memopos;
Board.UnInitBoard(); RoutingMatrix.UnInitBoard();
Route_Layer_TOP = lay_tmp_TOP; Route_Layer_TOP = lay_tmp_TOP;
Route_Layer_BOTTOM = lay_tmp_BOTTOM; Route_Layer_BOTTOM = lay_tmp_BOTTOM;
...@@ -397,13 +398,13 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC ) ...@@ -397,13 +398,13 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
GRSetDrawMode( DC, GR_COPY ); 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; color = BLACK;
top_state = GetCell( ii, jj, TOP ); top_state = GetCell( ii, jj, TOP );
...@@ -438,7 +439,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard() ...@@ -438,7 +439,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
EDA_ITEM* PtStruct; EDA_ITEM* PtStruct;
wxString msg; wxString msg;
Board.UnInitBoard(); RoutingMatrix.UnInitBoard();
bbbox = GetBoard()->ComputeBoundingBox( true ); bbbox = GetBoard()->ComputeBoundingBox( true );
...@@ -449,19 +450,19 @@ int PCB_EDIT_FRAME::GenPlaceBoard() ...@@ -449,19 +450,19 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
} }
/* The boundary box must have its start point on placing grid: */ /* The boundary box must have its start point on placing grid: */
bbbox.SetX( bbbox.GetX() - ( bbbox.GetX() % Board.m_GridRouting ) ); bbbox.SetX( bbbox.GetX() - ( bbbox.GetX() % RoutingMatrix.m_GridRouting ) );
bbbox.SetY( bbbox.GetY() - ( bbbox.GetY() % Board.m_GridRouting ) ); bbbox.SetY( bbbox.GetY() - ( bbbox.GetY() % RoutingMatrix.m_GridRouting ) );
/* The boundary box must have its end point on placing grid: */ /* The boundary box must have its end point on placing grid: */
wxPoint end = bbbox.GetEnd(); wxPoint end = bbbox.GetEnd();
end.x -= end.x % Board.m_GridRouting; end.x -= end.x % RoutingMatrix.m_GridRouting;
end.x += Board.m_GridRouting; end.x += RoutingMatrix.m_GridRouting;
end.y -= end.y % Board.m_GridRouting; end.y -= end.y % RoutingMatrix.m_GridRouting;
end.y += Board.m_GridRouting; end.y += RoutingMatrix.m_GridRouting;
bbbox.SetEnd( end ); bbbox.SetEnd( end );
Nrows = bbbox.GetHeight() / Board.m_GridRouting; Nrows = bbbox.GetHeight() / RoutingMatrix.m_GridRouting;
Ncols = bbbox.GetWidth() / Board.m_GridRouting; Ncols = bbbox.GetWidth() / RoutingMatrix.m_GridRouting;
/* get a small margin for memory allocation: */ /* get a small margin for memory allocation: */
Ncols += 2; Nrows += 2; Ncols += 2; Nrows += 2;
NbCells = Ncols * Nrows; NbCells = Ncols * Nrows;
...@@ -480,10 +481,10 @@ int PCB_EDIT_FRAME::GenPlaceBoard() ...@@ -480,10 +481,10 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
m_messagePanel->SetMessage( 22, wxT( "S" ), m_messagePanel->SetMessage( 22, wxT( "S" ),
( Nb_Sides == TWO_SIDES ) ? wxT( "2" ) : wxT( "1" ), WHITE ); ( Nb_Sides == TWO_SIDES ) ? wxT( "2" ) : wxT( "1" ), WHITE );
Board.InitBoard(); RoutingMatrix.InitBoard();
/* Display memory usage. */ /* 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 ); m_messagePanel->SetMessage( 24, wxT( "Mem(Kb)" ), msg, CYAN );
Route_Layer_BOTTOM = LAYER_N_FRONT; Route_Layer_BOTTOM = LAYER_N_FRONT;
...@@ -499,7 +500,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard() ...@@ -499,7 +500,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
TmpSegm.SetLayer( -1 ); TmpSegm.SetLayer( -1 );
TmpSegm.SetNet( -1 ); TmpSegm.SetNet( -1 );
TmpSegm.m_Width = Board.m_GridRouting / 2; TmpSegm.m_Width = RoutingMatrix.m_GridRouting / 2;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
...@@ -519,7 +520,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard() ...@@ -519,7 +520,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
TmpSegm.m_Param = DrawSegm->GetAngle(); TmpSegm.m_Param = DrawSegm->GetAngle();
TraceSegmentPcb( GetBoard(), &TmpSegm, HOLE | CELL_is_EDGE, TraceSegmentPcb( GetBoard(), &TmpSegm, HOLE | CELL_is_EDGE,
Board.m_GridRouting, WRITE_CELL ); RoutingMatrix.m_GridRouting, WRITE_CELL );
break; break;
case PCB_TEXT_T: case PCB_TEXT_T:
...@@ -543,8 +544,8 @@ int PCB_EDIT_FRAME::GenPlaceBoard() ...@@ -543,8 +544,8 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
} }
/* Initialize top layer. */ /* Initialize top layer. */
if( Board.m_BoardSide[TOP] ) if( RoutingMatrix.m_BoardSide[TOP] )
memcpy( Board.m_BoardSide[TOP], Board.m_BoardSide[BOTTOM], memcpy( RoutingMatrix.m_BoardSide[TOP], RoutingMatrix.m_BoardSide[BOTTOM],
NbCells * sizeof(MATRIX_CELL) ); NbCells * sizeof(MATRIX_CELL) );
return 1; return 1;
...@@ -556,7 +557,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard() ...@@ -556,7 +557,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module ) void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
{ {
int ox, oy, fx, fy; int ox, oy, fx, fy;
int marge = Board.m_GridRouting / 2; int marge = RoutingMatrix.m_GridRouting / 2;
int layerMask; int layerMask;
D_PAD* Pad; D_PAD* Pad;
...@@ -612,7 +613,7 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module ) ...@@ -612,7 +613,7 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
} }
/* Trace clearance. */ /* 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 ); CreateKeepOutRectangle( GetBoard(), ox, oy, fx, fy, marge, KEEP_OUT_MARGIN, layerMask );
} }
...@@ -643,8 +644,8 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) ...@@ -643,8 +644,8 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
CurrPosition.y = bbbox.GetY() - oy; CurrPosition.y = bbbox.GetY() - oy;
/* Module placement on grid. */ /* Module placement on grid. */
CurrPosition.x -= CurrPosition.x % Board.m_GridRouting; CurrPosition.x -= CurrPosition.x % RoutingMatrix.m_GridRouting;
CurrPosition.y -= CurrPosition.y % Board.m_GridRouting; CurrPosition.y -= CurrPosition.y % RoutingMatrix.m_GridRouting;
g_Offset_Module.x = cx - CurrPosition.x; g_Offset_Module.x = cx - CurrPosition.x;
g_Offset_Module.y = cy - CurrPosition.y; g_Offset_Module.y = cy - CurrPosition.y;
...@@ -680,7 +681,7 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) ...@@ -680,7 +681,7 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
SetStatusText( wxT( "Score ??, pos ??" ) ); SetStatusText( wxT( "Score ??, pos ??" ) );
for( ; CurrPosition.x < bbbox.GetRight() - fx; for( ; CurrPosition.x < bbbox.GetRight() - fx;
CurrPosition.x += Board.m_GridRouting ) CurrPosition.x += RoutingMatrix.m_GridRouting )
{ {
wxYield(); wxYield();
...@@ -702,12 +703,12 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) ...@@ -702,12 +703,12 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
CurrPosition.y = bbbox.GetY() - oy; CurrPosition.y = bbbox.GetY() - oy;
/* Placement on grid. */ /* Placement on grid. */
CurrPosition.y -= CurrPosition.y % Board.m_GridRouting; CurrPosition.y -= CurrPosition.y % RoutingMatrix.m_GridRouting;
DrawModuleOutlines( m_canvas, aDC, aModule ); DrawModuleOutlines( m_canvas, aDC, aModule );
for( ; CurrPosition.y < bbbox.GetBottom() - fy; for( ; CurrPosition.y < bbbox.GetBottom() - fy;
CurrPosition.y += Board.m_GridRouting ) CurrPosition.y += RoutingMatrix.m_GridRouting )
{ {
/* Erase traces. */ /* Erase traces. */
DrawModuleOutlines( m_canvas, aDC, aModule ); DrawModuleOutlines( m_canvas, aDC, aModule );
...@@ -785,16 +786,16 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side ) ...@@ -785,16 +786,16 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
ux1 -= Pcb->GetBoundingBox().GetX(); ux1 -= Pcb->GetBoundingBox().GetX();
uy1 -= Pcb->GetBoundingBox().GetY(); uy1 -= Pcb->GetBoundingBox().GetY();
row_max = uy1 / Board.m_GridRouting; row_max = uy1 / RoutingMatrix.m_GridRouting;
col_max = ux1 / Board.m_GridRouting; col_max = ux1 / RoutingMatrix.m_GridRouting;
row_min = uy0 / Board.m_GridRouting; row_min = uy0 / RoutingMatrix.m_GridRouting;
if( uy0 > row_min * Board.m_GridRouting ) if( uy0 > row_min * RoutingMatrix.m_GridRouting )
row_min++; 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++; col_min++;
if( row_min < 0 ) if( row_min < 0 )
...@@ -842,16 +843,16 @@ unsigned int CalculateKeepOutArea( BOARD* Pcb, int ux0, int uy0, int ux1, int uy ...@@ -842,16 +843,16 @@ unsigned int CalculateKeepOutArea( BOARD* Pcb, int ux0, int uy0, int ux1, int uy
ux1 -= Pcb->GetBoundingBox().GetX(); ux1 -= Pcb->GetBoundingBox().GetX();
uy1 -= Pcb->GetBoundingBox().GetY(); uy1 -= Pcb->GetBoundingBox().GetY();
row_max = uy1 / Board.m_GridRouting; row_max = uy1 / RoutingMatrix.m_GridRouting;
col_max = ux1 / Board.m_GridRouting; col_max = ux1 / RoutingMatrix.m_GridRouting;
row_min = uy0 / Board.m_GridRouting; row_min = uy0 / RoutingMatrix.m_GridRouting;
if( uy0 > row_min * Board.m_GridRouting ) if( uy0 > row_min * RoutingMatrix.m_GridRouting )
row_min++; 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++; col_min++;
if( row_min < 0 ) if( row_min < 0 )
...@@ -914,7 +915,7 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide ) ...@@ -914,7 +915,7 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
return error; 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 ); return CalculateKeepOutArea( Pcb, ox - marge, oy - marge, fx + marge, fy + marge, side );
} }
...@@ -1019,22 +1020,22 @@ static void CreateKeepOutRectangle( BOARD* Pcb, ...@@ -1019,22 +1020,22 @@ static void CreateKeepOutRectangle( BOARD* Pcb,
ux0 -= marge; ux1 += marge; ux0 -= marge; ux1 += marge;
uy0 -= marge; uy1 += marge; uy0 -= marge; uy1 += marge;
pmarge = marge / Board.m_GridRouting; pmarge = marge / RoutingMatrix.m_GridRouting;
if( pmarge < 1 ) if( pmarge < 1 )
pmarge = 1; pmarge = 1;
/* Calculate the coordinate limits of the rectangle. */ /* Calculate the coordinate limits of the rectangle. */
row_max = uy1 / Board.m_GridRouting; row_max = uy1 / RoutingMatrix.m_GridRouting;
col_max = ux1 / Board.m_GridRouting; col_max = ux1 / RoutingMatrix.m_GridRouting;
row_min = uy0 / Board.m_GridRouting; row_min = uy0 / RoutingMatrix.m_GridRouting;
if( uy0 > row_min * Board.m_GridRouting ) if( uy0 > row_min * RoutingMatrix.m_GridRouting )
row_min++; 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++; col_min++;
if( row_min < 0 ) if( row_min < 0 )
......
...@@ -11,14 +11,15 @@ ...@@ -11,14 +11,15 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <cell.h> #include <cell.h>
#include <zones.h> #include <zones.h>
#include <ar_protos.h>
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <class_track.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 Nb_Sides; /* Number of layer for autorouting (0 or 1) */
int Nrows = ILLEGAL; int Nrows = ILLEGAL;
int Ncols = ILLEGAL; int Ncols = ILLEGAL;
...@@ -28,8 +29,7 @@ int ClosNodes; /* total number of nodes closed */ ...@@ -28,8 +29,7 @@ int ClosNodes; /* total number of nodes closed */
int MoveNodes; /* total number of nodes moved */ int MoveNodes; /* total number of nodes moved */
int MaxNodes; /* maximum number of nodes opened at one time */ 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*/ /* init board, route traces*/
void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode ) void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
...@@ -139,18 +139,14 @@ 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 ); start = time( NULL );
/* Calculation of no fixed routing to 5 mils and more. */ /* Calculation of no fixed routing to 5 mils and more. */
Board.m_GridRouting = (int)GetScreen()->GetGridSize().x; RoutingMatrix.m_GridRouting = (int)GetScreen()->GetGridSize().x;
if( Board.m_GridRouting < 50 )
Board.m_GridRouting = 50;
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. */ /* Calculated ncol and nrow, matrix size for routing. */
Board.ComputeMatrixSize( GetBoard() ); RoutingMatrix.ComputeMatrixSize( GetBoard() );
m_messagePanel->EraseMsgBox(); m_messagePanel->EraseMsgBox();
...@@ -160,10 +156,10 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode ) ...@@ -160,10 +156,10 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
if( Route_Layer_TOP != Route_Layer_BOTTOM ) if( Route_Layer_TOP != Route_Layer_BOTTOM )
Nb_Sides = TWO_SIDES; Nb_Sides = TWO_SIDES;
if( Board.InitBoard() < 0 ) if( RoutingMatrix.InitBoard() < 0 )
{ {
wxMessageBox( _( "No memory for autorouting" ) ); wxMessageBox( _( "No memory for autorouting" ) );
Board.UnInitBoard(); /* Free memory. */ RoutingMatrix.UnInitBoard(); /* Free memory. */
return; return;
} }
...@@ -173,7 +169,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode ) ...@@ -173,7 +169,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
/* Construction of the track list for router. */ /* Construction of the track list for router. */
Build_Work( GetBoard() ); Build_Work( GetBoard() );
// DisplayBoard(m_canvas, DC); // DisplayRoutingMatrix( m_canvas, DC );
if( Nb_Sides == TWO_SIDES ) if( Nb_Sides == TWO_SIDES )
Solve( DC, TWO_SIDES ); /* double face */ Solve( DC, TWO_SIDES ); /* double face */
...@@ -183,7 +179,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode ) ...@@ -183,7 +179,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
/* Free memory. */ /* Free memory. */
FreeQueue(); FreeQueue();
InitWork(); /* Free memory for the list of router connections. */ InitWork(); /* Free memory for the list of router connections. */
Board.UnInitBoard(); RoutingMatrix.UnInitBoard();
stop = time( NULL ) - start; stop = time( NULL ) - start;
msg.Printf( wxT( "time = %d second%s" ), stop, ( stop == 1 ) ? wxT( "" ) : wxT( "s" ) ); msg.Printf( wxT( "time = %d second%s" ), stop, ( stop == 1 ) ? wxT( "" ) : wxT( "s" ) );
SetStatusText( msg ); SetStatusText( msg );
...@@ -207,13 +203,11 @@ void PCB_EDIT_FRAME::Reset_Noroutable( wxDC* DC ) ...@@ -207,13 +203,11 @@ void PCB_EDIT_FRAME::Reset_Noroutable( wxDC* DC )
/* DEBUG Function: displays the routing matrix */ /* 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 dcell0, dcell1 = 0, color;
int maxi;
maxi = 600 / Ncols; int maxi = 600 / Ncols;
maxi = ( maxi * 3 ) / 4; maxi = ( maxi * 3 ) / 4;
if( !maxi ) if( !maxi )
...@@ -221,9 +215,9 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC ) ...@@ -221,9 +215,9 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC )
GRSetDrawMode( DC, GR_COPY ); 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; color = 0;
dcell0 = GetCell( row, col, BOTTOM ); dcell0 = GetCell( row, col, BOTTOM );
...@@ -251,8 +245,8 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC ) ...@@ -251,8 +245,8 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC )
#define DRAW_OFFSET_Y 20 #define DRAW_OFFSET_Y 20
// if( color ) // if( color )
{ {
for( i = 0; i < maxi; i++ ) for( int i = 0; i < maxi; i++ )
for( j = 0; j < maxi; j++ ) for( int j = 0; j < maxi; j++ )
GRPutPixel( panel->GetClipBox(), DC, GRPutPixel( panel->GetClipBox(), DC,
( col * maxi ) + i + DRAW_OFFSET_X, ( col * maxi ) + i + DRAW_OFFSET_X,
( row * maxi ) + j + DRAW_OFFSET_Y, color ); ( row * maxi ) + j + DRAW_OFFSET_Y, color );
......
...@@ -57,8 +57,6 @@ enum CommandOpt { ...@@ -57,8 +57,6 @@ enum CommandOpt {
}; };
extern int E_scale; /* Scaling factor of distance tables. */
#define ONE_SIDE 0 #define ONE_SIDE 0
#define TWO_SIDES 1 #define TWO_SIDES 1
...@@ -126,7 +124,7 @@ public: ...@@ -126,7 +124,7 @@ public:
void UnInitBoard(); 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 */ /* Constants used to trace the cells on the BOARD */
...@@ -136,5 +134,78 @@ extern MATRIX_ROUTING_HEAD Board; /* 2-sided board */ ...@@ -136,5 +134,78 @@ extern MATRIX_ROUTING_HEAD Board; /* 2-sided board */
#define WRITE_AND_CELL 3 #define WRITE_AND_CELL 3
#define WRITE_ADD_CELL 4 #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 #endif // AUTOROUT_H
...@@ -3,20 +3,17 @@ ...@@ -3,20 +3,17 @@
* @brief Routines to calculate PCB editor auto routing distances. * @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 <autorout.h>
#include <cell.h> #include <cell.h>
/* The tables of distances and keep out areas are established on the basis of not /* The tables of distances and keep out areas are established on the basis of a
* routing of 50 units (the pitch between the cells is 50 units) The true distance * 50 units grid size (the pitch between the cells is 50 units).
* is computed by a scaling factor * 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 ) int GetApxDist( int r1, int c1, int r2, int c2 )
{ {
...@@ -28,27 +25,13 @@ 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 */ if( ( d2 = c1 - c2 ) < 0 ) /* get absolute column delta */
d2 = -d2; d2 = -d2;
return ( d1+d2 ) * 50 * E_scale; return ( d1+d2 ) * 50;
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 */
} }
/* distance to go thru a cell (en mils) */ /* 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, NE, E, SE, S, SW, W, NW, OT, OR */
/* N */ { 50, 60, 35, 60, 99, 60, 35, 60, 12, 12 }, /* N */ { 50, 60, 35, 60, 99, 60, 35, 60, 12, 12 },
/* NE */ { 60, 71, 60, 71, 60, 99, 60, 71, 23, 23 }, /* 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 */ ...@@ -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 }, /* OT */ { 12, 23, 12, 23, 12, 23, 12, 23, 99, 99 },
/* OR */ { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 } /* OR */ { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }
}; };
/* penalty for extraneous holes and corners, scaled by sharpness of turn */ /* 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, NE, E, SE, S, SW, W, NW, OT, OR */
/* N */ { 0, 5, 10, 15, 20, 15, 10, 5, 50, 0 }, /* N */ { 0, 5, 10, 15, 20, 15, 10, 5, 50, 0 },
/* NE */ { 5, 0, 5, 10, 15, 20, 15, 10, 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 */ ...@@ -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 }, /* OT */ { 50, 50, 50, 50, 50, 50, 50, 50, 100, 0 },
/* OR */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } /* OR */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
}; };
/* penalty pour directions preferencielles */ /* penalty pour directions preferencielles */
#define PN 20 #define PN 20
static int dir_penalty_TOP[10][10] = { static const int dir_penalty_TOP[10][10] =
{
/* OT=Otherside, OR=Origin (source) cell */ /* OT=Otherside, OR=Origin (source) cell */
/*......... N, NE, E, SE, S, SW, W, NW, OT, OR */ /*......... N, NE, E, SE, S, SW, W, NW, OT, OR */
/* N */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, /* N */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 },
...@@ -95,9 +80,10 @@ static int dir_penalty_TOP[10][10] = { ...@@ -95,9 +80,10 @@ static int dir_penalty_TOP[10][10] = {
/* OT */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 }, /* OT */ { PN, 0, 0, 0, PN, 0, 0, 0, 0, 0 },
/* OR */ { 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 */ /* OT=Otherside, OR=Origin (source) cell */
/*......... N, NE, E, SE, S, SW, W, NW, OT, OR */ /*......... N, NE, E, SE, S, SW, W, NW, OT, OR */
/* N */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, /* N */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 },
...@@ -111,7 +97,7 @@ static int dir_penalty_BOTTOM[10][10] = { ...@@ -111,7 +97,7 @@ static int dir_penalty_BOTTOM[10][10] = {
/* OT */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 }, /* OT */ { 0, 0, PN, 0, 0, 0, PN, 0, 0, 0 },
/* OR */ { 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. ** x is the direction to enter the cell of interest.
...@@ -122,11 +108,9 @@ static int dir_penalty_BOTTOM[10][10] = { ...@@ -122,11 +108,9 @@ static int dir_penalty_BOTTOM[10][10] = {
** the calculation is driven by the tables above. ** 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 CalcDist(int x,int y,int z ,int side )
{ {
int adjust, ldist; int adjust, ldist;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <cell.h> #include <cell.h>
#include <ar_protos.h> #include <autorout.h>
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
...@@ -342,7 +342,7 @@ int Build_Work( BOARD* Pcb ) ...@@ -342,7 +342,7 @@ int Build_Work( BOARD* Pcb )
D_PAD* pt_pad; D_PAD* pt_pad;
int r1, r2, c1, c2, current_net_code; int r1, r2, c1, c2, current_net_code;
RATSNEST_ITEM* pt_ch; RATSNEST_ITEM* pt_ch;
int demi_pas = Board.m_GridRouting / 2; int demi_pas = RoutingMatrix.m_GridRouting / 2;
wxString msg; wxString msg;
EDA_RECT bbbox = Pcb->GetBoundingBox(); EDA_RECT bbbox = Pcb->GetBoundingBox();
...@@ -371,7 +371,7 @@ int Build_Work( BOARD* Pcb ) ...@@ -371,7 +371,7 @@ int Build_Work( BOARD* Pcb )
current_net_code = pt_pad->GetNet(); current_net_code = pt_pad->GetNet();
pt_ch = pt_rats; 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 ) if( r1 < 0 || r1 >= Nrows )
{ {
...@@ -381,7 +381,7 @@ int Build_Work( BOARD* Pcb ) ...@@ -381,7 +381,7 @@ int Build_Work( BOARD* Pcb )
return 0; 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 ) if( c1 < 0 || c1 >= Ncols )
{ {
...@@ -394,7 +394,7 @@ int Build_Work( BOARD* Pcb ) ...@@ -394,7 +394,7 @@ int Build_Work( BOARD* Pcb )
pt_pad = pt_rats->m_PadEnd; pt_pad = pt_rats->m_PadEnd;
r2 = ( pt_pad->GetPosition().y - bbbox.GetY() r2 = ( pt_pad->GetPosition().y - bbbox.GetY()
+ demi_pas ) / Board.m_GridRouting; + demi_pas ) / RoutingMatrix.m_GridRouting;
if( r2 < 0 || r2 >= Nrows ) if( r2 < 0 || r2 >= Nrows )
{ {
...@@ -404,7 +404,7 @@ int Build_Work( BOARD* Pcb ) ...@@ -404,7 +404,7 @@ int Build_Work( BOARD* Pcb )
return 0; 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 ) if( c2 < 0 || c2 >= Ncols )
{ {
...@@ -429,7 +429,7 @@ MATRIX_CELL GetCell( int aRow, int aCol, int aSide ) ...@@ -429,7 +429,7 @@ MATRIX_CELL GetCell( int aRow, int aCol, int aSide )
{ {
MATRIX_CELL* p; MATRIX_CELL* p;
p = Board.m_BoardSide[aSide]; p = RoutingMatrix.m_BoardSide[aSide];
return p[aRow * Ncols + aCol]; return p[aRow * Ncols + aCol];
} }
...@@ -440,7 +440,7 @@ void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL x ) ...@@ -440,7 +440,7 @@ void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{ {
MATRIX_CELL* p; MATRIX_CELL* p;
p = Board.m_BoardSide[aSide]; p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] = x; p[aRow * Ncols + aCol] = x;
} }
...@@ -451,7 +451,7 @@ void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL x ) ...@@ -451,7 +451,7 @@ void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{ {
MATRIX_CELL* p; MATRIX_CELL* p;
p = Board.m_BoardSide[aSide]; p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] |= x; p[aRow * Ncols + aCol] |= x;
} }
...@@ -462,7 +462,7 @@ void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL x ) ...@@ -462,7 +462,7 @@ void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{ {
MATRIX_CELL* p; MATRIX_CELL* p;
p = Board.m_BoardSide[aSide]; p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] ^= x; p[aRow * Ncols + aCol] ^= x;
} }
...@@ -473,7 +473,7 @@ void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL x ) ...@@ -473,7 +473,7 @@ void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{ {
MATRIX_CELL* p; MATRIX_CELL* p;
p = Board.m_BoardSide[aSide]; p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] &= x; p[aRow * Ncols + aCol] &= x;
} }
...@@ -484,7 +484,7 @@ void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL x ) ...@@ -484,7 +484,7 @@ void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{ {
MATRIX_CELL* p; MATRIX_CELL* p;
p = Board.m_BoardSide[aSide]; p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] += x; p[aRow * Ncols + aCol] += x;
} }
...@@ -494,7 +494,7 @@ DIST_CELL GetDist( int aRow, int aCol, int aSide ) /* fetch distance cell */ ...@@ -494,7 +494,7 @@ DIST_CELL GetDist( int aRow, int aCol, int aSide ) /* fetch distance cell */
{ {
DIST_CELL* p; DIST_CELL* p;
p = Board.m_DistSide[aSide]; p = RoutingMatrix.m_DistSide[aSide];
return p[aRow * Ncols + aCol]; return p[aRow * Ncols + aCol];
} }
...@@ -504,7 +504,7 @@ void SetDist( int aRow, int aCol, int aSide, DIST_CELL x ) ...@@ -504,7 +504,7 @@ void SetDist( int aRow, int aCol, int aSide, DIST_CELL x )
{ {
DIST_CELL* p; DIST_CELL* p;
p = Board.m_DistSide[aSide]; p = RoutingMatrix.m_DistSide[aSide];
p[aRow * Ncols + aCol] = x; p[aRow * Ncols + aCol] = x;
} }
...@@ -514,7 +514,7 @@ int GetDir( int aRow, int aCol, int aSide ) ...@@ -514,7 +514,7 @@ int GetDir( int aRow, int aCol, int aSide )
{ {
DIR_CELL* p; DIR_CELL* p;
p = Board.m_DirSide[aSide]; p = RoutingMatrix.m_DirSide[aSide];
return (int) (p[aRow * Ncols + aCol]); return (int) (p[aRow * Ncols + aCol]);
} }
...@@ -524,6 +524,6 @@ void SetDir( int aRow, int aCol, int aSide, int x ) ...@@ -524,6 +524,6 @@ void SetDir( int aRow, int aCol, int aSide, int x )
{ {
DIR_CELL* p; DIR_CELL* p;
p = Board.m_DirSide[aSide]; p = RoutingMatrix.m_DirSide[aSide];
p[aRow * Ncols + aCol] = (char) x; p[aRow * Ncols + aCol] = (char) x;
} }
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <protos.h> #include <protos.h>
#include <ar_protos.h> #include <autorout.h>
#include <cell.h> #include <cell.h>
...@@ -104,7 +104,7 @@ static PICKED_ITEMS_LIST s_ItemsListPicker; ...@@ -104,7 +104,7 @@ static PICKED_ITEMS_LIST s_ItemsListPicker;
* [] [0] = row [] (1] = col was added to the coord of the midpoint for * [] [0] = row [] (1] = col was added to the coord of the midpoint for
* Get the coord of the 8 neighboring points. * Get the coord of the 8 neighboring points.
*/ */
static int delta[8][2] = static const int delta[8][2] =
{ {
{ 1, -1 }, /* northwest */ { 1, -1 }, /* northwest */
{ 1, 0 }, /* north */ { 1, 0 }, /* north */
...@@ -116,7 +116,7 @@ static int delta[8][2] = ...@@ -116,7 +116,7 @@ static int delta[8][2] =
{ -1, 1 } /* southeast */ { -1, 1 } /* southeast */
}; };
static int ndir[8] = static const int ndir[8] =
{ {
/* for building paths back to source */ /* for building paths back to source */
FROM_SOUTHEAST, FROM_SOUTH, FROM_SOUTHWEST, FROM_SOUTHEAST, FROM_SOUTH, FROM_SOUTHWEST,
...@@ -316,10 +316,10 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides ) ...@@ -316,10 +316,10 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
} }
pt_cur_ch = pt_cur_ch; pt_cur_ch = pt_cur_ch;
segm_oX = GetBoard()->GetBoundingBox().GetX() + (Board.m_GridRouting * col_source); segm_oX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_source);
segm_oY = GetBoard()->GetBoundingBox().GetY() + (Board.m_GridRouting * row_source); segm_oY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_source);
segm_fX = GetBoard()->GetBoundingBox().GetX() + (Board.m_GridRouting * col_target); segm_fX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_target);
segm_fY = GetBoard()->GetBoundingBox().GetY() + (Board.m_GridRouting * row_target); segm_fY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_target);
/* Draw segment. */ /* Draw segment. */
GRLine( m_canvas->GetClipBox(), GRLine( m_canvas->GetClipBox(),
...@@ -434,8 +434,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -434,8 +434,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
/* clear direction flags */ /* clear direction flags */
i = Nrows * Ncols * sizeof(DIR_CELL); i = Nrows * Ncols * sizeof(DIR_CELL);
memset( Board.m_DirSide[TOP], FROM_NOWHERE, i ); memset( RoutingMatrix.m_DirSide[TOP], FROM_NOWHERE, i );
memset( Board.m_DirSide[BOTTOM], FROM_NOWHERE, i ); memset( RoutingMatrix.m_DirSide[BOTTOM], FROM_NOWHERE, i );
lastopen = lastclos = lastmove = 0; lastopen = lastclos = lastmove = 0;
...@@ -467,9 +467,9 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -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) * 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(); + pcbframe->GetBoard()->GetBoundingBox().GetX();
int cY = ( Board.m_GridRouting * row_source ) int cY = ( RoutingMatrix.m_GridRouting * row_source )
+ pcbframe->GetBoard()->GetBoundingBox().GetY(); + pcbframe->GetBoard()->GetBoundingBox().GetY();
int dx = pt_cur_ch->m_PadStart->GetSize().x / 2; int dx = pt_cur_ch->m_PadStart->GetSize().x / 2;
int dy = pt_cur_ch->m_PadStart->GetSize().y / 2; int dy = pt_cur_ch->m_PadStart->GetSize().y / 2;
...@@ -482,9 +482,9 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -482,9 +482,9 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) ) if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) )
goto end_of_route; goto end_of_route;
cX = ( Board.m_GridRouting * col_target ) cX = ( RoutingMatrix.m_GridRouting * col_target )
+ pcbframe->GetBoard()->GetBoundingBox().GetX(); + pcbframe->GetBoard()->GetBoundingBox().GetX();
cY = ( Board.m_GridRouting * row_target ) cY = ( RoutingMatrix.m_GridRouting * row_target )
+ pcbframe->GetBoard()->GetBoundingBox().GetY(); + pcbframe->GetBoard()->GetBoundingBox().GetY();
dx = pt_cur_ch->m_PadEnd->GetSize().x / 2; dx = pt_cur_ch->m_PadEnd->GetSize().x / 2;
dy = pt_cur_ch->m_PadEnd->GetSize().y / 2; dy = pt_cur_ch->m_PadEnd->GetSize().y / 2;
...@@ -1171,11 +1171,11 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, ...@@ -1171,11 +1171,11 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
g_CurrentTrackSegment->m_Start.x = g_CurrentTrackSegment->m_Start.x =
g_CurrentTrackSegment->m_End.x = pcb->GetBoundingBox().GetX() + g_CurrentTrackSegment->m_End.x = pcb->GetBoundingBox().GetX() +
( Board.m_GridRouting * row ); ( RoutingMatrix.m_GridRouting * row );
g_CurrentTrackSegment->m_Start.y = g_CurrentTrackSegment->m_Start.y =
g_CurrentTrackSegment->m_End.y = pcb->GetBoundingBox().GetY() + 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_Width = pcb->GetCurrentViaSize();
g_CurrentTrackSegment->m_Shape = pcb->GetDesignSettings().m_CurrentViaType; g_CurrentTrackSegment->m_Shape = pcb->GetDesignSettings().m_CurrentViaType;
...@@ -1195,9 +1195,9 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, ...@@ -1195,9 +1195,9 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
g_CurrentTrackSegment->SetState( TRACK_AR, ON ); g_CurrentTrackSegment->SetState( TRACK_AR, ON );
g_CurrentTrackSegment->m_End.x = pcb->GetBoundingBox().GetX() + g_CurrentTrackSegment->m_End.x = pcb->GetBoundingBox().GetX() +
( Board.m_GridRouting * row ); ( RoutingMatrix.m_GridRouting * row );
g_CurrentTrackSegment->m_End.y = pcb->GetBoundingBox().GetY() + g_CurrentTrackSegment->m_End.y = pcb->GetBoundingBox().GetY() +
( Board.m_GridRouting * col ); ( RoutingMatrix.m_GridRouting * col );
g_CurrentTrackSegment->SetNet( current_net_code ); g_CurrentTrackSegment->SetNet( current_net_code );
if( g_CurrentTrackSegment->Back() == NULL ) /* Start trace. */ if( g_CurrentTrackSegment->Back() == NULL ) /* Start trace. */
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
#include <common.h> #include <common.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <autorout.h>
#include <cell.h> #include <cell.h>
#include <ar_protos.h>
struct CWORK /* a unit of work is a hole-pair to connect */ struct CWORK /* a unit of work is a hole-pair to connect */
...@@ -57,12 +57,6 @@ static CWORK* Tail = NULL; ...@@ -57,12 +57,6 @@ static CWORK* Tail = NULL;
static CWORK* Current = 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 */ /* initialize the work list */
void InitWork() void InitWork()
...@@ -220,14 +214,14 @@ void SortWork() ...@@ -220,14 +214,14 @@ void SortWork()
} }
/* Calculate the cost of a net: /* Calculate the cost of a ratsnest:
* cost = (| dx | + | dy |) * disability * cost = (| dx | + | dy |) * disability
* disability = 1 if dx or dy = 0, max if | dx | # | dy | * disability = 1 if dx or dy = 0, max if | dx | # | dy |
*/ */
static int GetCost( int r1, int c1, int r2, int c2 ) static int GetCost( int r1, int c1, int r2, int c2 )
{ {
int dx, dy, mx, my; int dx, dy, mx, my;
float incl; double incl;
dx = abs( c2 - c1 ); dx = abs( c2 - c1 );
dy = abs( r2 - r1 ); dy = abs( r2 - r1 );
...@@ -241,7 +235,7 @@ static int GetCost( int r1, int c1, int r2, int c2 ) ...@@ -241,7 +235,7 @@ static int GetCost( int r1, int c1, int r2, int c2 )
} }
if( mx ) if( mx )
incl += (2 * (float) my / mx); incl += (2 * (double) my / mx);
return (int) ( ( dx + dy ) * incl ); return (int) ( ( dx + dy ) * incl );
} }
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <dialog_exchange_modules_base.h> #include <dialog_exchange_modules_base.h>
#include <ar_protos.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
static char* quiet_gcc_4_4_3; // GCC 4.4.3 and next .. 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