Commit 9fea98dd authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: Fix compil issues with wxWidgets 2.8.12

Some code cleaning in autoroute functions.
parent d3f95548
Loading
Loading
Loading
Loading
+52 −51
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@
 * graduated from 0 (rotation allowed) to 10 (rotation count null)
 * the count is increased.
 */
static const float OrientPenality[11] =
static const double OrientPenality[11] =
{
    2.0f,       /* CntRot = 0 rotation prohibited */
    1.9f,       /* CntRot = 1 */
@@ -82,7 +82,7 @@ static const float OrientPenality[11] =
static wxPoint CurrPosition; // Current position of the current module placement
static bool    AutoPlaceShowAll = true;

float          MinCout;
double          MinCout;

static int  TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide );

@@ -251,7 +251,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
        DrawInfoPlace( DC );

        error     = GetOptimalModulePlacement( Module, DC );
        float BestScore = MinCout;
        double BestScore = MinCout;
        PosOK     = CurrPosition;

        if( error == ESC )
@@ -388,8 +388,8 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
            ox = RoutingMatrix.m_BrdBox.GetX() + (jj * RoutingMatrix.m_GridRouting);
            color = BLACK;

            top_state    = GetCell( ii, jj, TOP );
            bottom_state = GetCell( ii, jj, BOTTOM );
            top_state    = RoutingMatrix.GetCell( ii, jj, TOP );
            bottom_state = RoutingMatrix.GetCell( ii, jj, BOTTOM );

            if( top_state & CELL_is_ZONE )
                color = BLUE;
@@ -403,7 +403,8 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
                color = LIGHTGREEN;
            else /* Display the filling and keep out regions. */
            {
                if( GetDist( ii, jj, TOP ) || GetDist( ii, jj, BOTTOM ) )
                if( RoutingMatrix.GetDist( ii, jj, TOP ) ||
                    RoutingMatrix.GetDist( ii, jj, BOTTOM ) )
                    color = DARKGRAY;
            }

@@ -415,7 +416,6 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )

int PCB_EDIT_FRAME::GenPlaceBoard()
{
    int       NbCells;
    wxString  msg;

    RoutingMatrix.UnInitRoutingMatrix();
@@ -429,14 +429,14 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
    }

    RoutingMatrix.ComputeMatrixSize( GetBoard(), true );
    NbCells = Ncols * Nrows;
    int nbCells = RoutingMatrix.m_Ncols * RoutingMatrix.m_Nrows;

    m_messagePanel->EraseMsgBox();
    msg.Printf( wxT( "%d" ), Ncols );
    msg.Printf( wxT( "%d" ), RoutingMatrix.m_Ncols );
    m_messagePanel->SetMessage( 1, _( "Cols" ), msg, GREEN );
    msg.Printf( wxT( "%d" ), Nrows );
    msg.Printf( wxT( "%d" ), RoutingMatrix.m_Nrows );
    m_messagePanel->SetMessage( 7, _( "Lines" ), msg, GREEN );
    msg.Printf( wxT( "%d" ), NbCells );
    msg.Printf( wxT( "%d" ), nbCells );
    m_messagePanel->SetMessage( 14, _( "Cells." ), msg, YELLOW );

    /* Choose the number of board sides. */
@@ -494,7 +494,8 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
    // Mark cells of the routing matrix to CELL_is_ZONE
    // (i.e. availlable cell to place a module )
    // Init a starting point of attachment to the area.
    OrCell( Nrows / 2, Ncols / 2, BOTTOM, CELL_is_ZONE );
    RoutingMatrix.OrCell( RoutingMatrix.m_Nrows / 2, RoutingMatrix.m_Ncols / 2,
                          BOTTOM, CELL_is_ZONE );

    // find and mark all other availlable cells:
    for( int ii = 1; ii != 0; )
@@ -503,7 +504,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
    // Initialize top layer. to the same value as the bottom layer
    if( RoutingMatrix.m_BoardSide[TOP] )
        memcpy( RoutingMatrix.m_BoardSide[TOP], RoutingMatrix.m_BoardSide[BOTTOM],
                NbCells * sizeof(MATRIX_CELL) );
                nbCells * sizeof(MATRIX_CELL) );

    return 1;
}
@@ -697,10 +698,10 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
                    LastPosOK = CurrPosition;
                    mincout   = Score;
                    wxString msg;
                    msg.Printf( wxT( "Score %g, pos %3.4f, %3.4f" ),
                    msg.Printf( wxT( "Score %g, pos %3.4g, %3.4g" ),
                                mincout,
                                (float) LastPosOK.x / 10000,
                                (float) LastPosOK.y / 10000 );
                                (double) LastPosOK.x / 10000,
                                (double) LastPosOK.y / 10000 );
                    SetStatusText( msg );
                }
            }
@@ -763,20 +764,20 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
    if( row_min < 0 )
        row_min = 0;

    if( row_max >= ( Nrows - 1 ) )
        row_max = Nrows - 1;
    if( row_max >= ( RoutingMatrix.m_Nrows - 1 ) )
        row_max = RoutingMatrix.m_Nrows - 1;

    if( col_min < 0 )
        col_min = 0;

    if( col_max >= ( Ncols - 1 ) )
        col_max = Ncols - 1;
    if( col_max >= ( RoutingMatrix.m_Ncols - 1 ) )
        col_max = RoutingMatrix.m_Ncols - 1;

    for( row = row_min; row <= row_max; row++ )
    {
        for( col = col_min; col <= col_max; col++ )
        {
            data = GetCell( row, col, side );
            data = RoutingMatrix.GetCell( row, col, side );

            if( ( data & CELL_is_ZONE ) == 0 )
                return OUT_OF_BOARD;
@@ -820,14 +821,14 @@ unsigned int CalculateKeepOutArea( int ux0, int uy0, int ux1, int uy1, int side
    if( row_min < 0 )
        row_min = 0;

    if( row_max >= ( Nrows - 1 ) )
        row_max = Nrows - 1;
    if( row_max >= ( RoutingMatrix.m_Nrows - 1 ) )
        row_max = RoutingMatrix.m_Nrows - 1;

    if( col_min < 0 )
        col_min = 0;

    if( col_max >= ( Ncols - 1 ) )
        col_max = Ncols - 1;
    if( col_max >= ( RoutingMatrix.m_Ncols - 1 ) )
        col_max = RoutingMatrix.m_Ncols - 1;

    keepOut = 0;

@@ -835,7 +836,7 @@ unsigned int CalculateKeepOutArea( int ux0, int uy0, int ux1, int uy1, int side
    {
        for( col = col_min; col <= col_max; col++ )
        {
            keepOut += (int) GetDist( row, col, side );
            keepOut += RoutingMatrix.GetDist( row, col, side );
        }
    }

@@ -1001,14 +1002,14 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
    if( row_min < 0 )
        row_min = 0;

    if( row_max >= (Nrows - 1) )
        row_max = Nrows - 1;
    if( row_max >= (RoutingMatrix.m_Nrows - 1) )
        row_max = RoutingMatrix.m_Nrows - 1;

    if( col_min < 0 )
        col_min = 0;

    if( col_max >= (Ncols - 1) )
        col_max = Ncols - 1;
    if( col_max >= (RoutingMatrix.m_Ncols - 1) )
        col_max = RoutingMatrix.m_Ncols - 1;

    for( row = row_min; row <= row_max; row++ )
    {
@@ -1036,15 +1037,15 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,

            if( trace & 1 )
            {
                data = GetDist( row, col, BOTTOM ) + LocalKeepOut;
                SetDist( row, col, BOTTOM, data );
                data = RoutingMatrix.GetDist( row, col, BOTTOM ) + LocalKeepOut;
                RoutingMatrix.SetDist( row, col, BOTTOM, data );
            }

            if( trace & 2 )
            {
                data = GetDist( row, col, TOP );
                data = RoutingMatrix.GetDist( row, col, TOP );
                data = MAX( data, LocalKeepOut );
                SetDist( row, col, TOP, data );
                RoutingMatrix.SetDist( row, col, TOP, data );
            }
        }
    }
@@ -1180,23 +1181,23 @@ int propagate()

#define NO_CELL_ZONE (HOLE | CELL_is_EDGE | CELL_is_ZONE)

    pt_cell_V.reserve( MAX( Nrows, Ncols ) );
    pt_cell_V.reserve( MAX( RoutingMatrix.m_Nrows, RoutingMatrix.m_Ncols ) );
    fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );

    // Search from left to right and top to bottom.
    for( row = 0; row < Nrows; row++ )
    for( row = 0; row < RoutingMatrix.m_Nrows; row++ )
    {
        old_cell_H = 0;

        for( col = 0; col < Ncols; col++ )
        for( col = 0; col < RoutingMatrix.m_Ncols; col++ )
        {
            current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
            current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;

            if( current_cell == 0 )  /* a free cell is found */
            {
                if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[col] & CELL_is_ZONE) )
                {
                    OrCell( row, col, BOTTOM, CELL_is_ZONE );
                    RoutingMatrix.OrCell( row, col, BOTTOM, CELL_is_ZONE );
                    current_cell = CELL_is_ZONE;
                    nbpoints++;
                }
@@ -1209,19 +1210,19 @@ int propagate()
    // Search from right to left and top to bottom/
    fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );

    for( row = 0; row < Nrows; row++ )
    for( row = 0; row < RoutingMatrix.m_Nrows; row++ )
    {
        old_cell_H = 0;

        for( col = Ncols - 1; col >= 0; col-- )
        for( col = RoutingMatrix.m_Ncols - 1; col >= 0; col-- )
        {
            current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
            current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;

            if( current_cell == 0 )  /* a free cell is found */
            {
                if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[col] & CELL_is_ZONE) )
                {
                    OrCell( row, col, BOTTOM, CELL_is_ZONE );
                    RoutingMatrix.OrCell( row, col, BOTTOM, CELL_is_ZONE );
                    current_cell = CELL_is_ZONE;
                    nbpoints++;
                }
@@ -1234,19 +1235,19 @@ int propagate()
    // Search from bottom to top and right to left.
    fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );

    for( col = Ncols - 1; col >= 0; col-- )
    for( col = RoutingMatrix.m_Ncols - 1; col >= 0; col-- )
    {
        old_cell_H = 0;

        for( row = Nrows - 1; row >= 0; row-- )
        for( row = RoutingMatrix.m_Nrows - 1; row >= 0; row-- )
        {
            current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
            current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;

            if( current_cell == 0 )  /* a free cell is found */
            {
                if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[row] & CELL_is_ZONE) )
                {
                    OrCell( row, col, BOTTOM, CELL_is_ZONE );
                    RoutingMatrix.OrCell( row, col, BOTTOM, CELL_is_ZONE );
                    current_cell = CELL_is_ZONE;
                    nbpoints++;
                }
@@ -1259,19 +1260,19 @@ int propagate()
    // Search from bottom to top and left to right.
    fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );

    for( col = 0; col < Ncols; col++ )
    for( col = 0; col < RoutingMatrix.m_Ncols; col++ )
    {
        old_cell_H = 0;

        for( row = Nrows - 1; row >= 0; row-- )
        for( row = RoutingMatrix.m_Nrows - 1; row >= 0; row-- )
        {
            current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
            current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;

            if( current_cell == 0 )  /* a free cell is found */
            {
                if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[row] & CELL_is_ZONE) )
                {
                    OrCell( row, col, BOTTOM, CELL_is_ZONE );
                    RoutingMatrix.OrCell( row, col, BOTTOM, CELL_is_ZONE );
                    current_cell = CELL_is_ZONE;
                    nbpoints++;
                }
+5 −8
Original line number Diff line number Diff line
@@ -48,9 +48,6 @@


int Nb_Sides;        /* Number of layer for autorouting (0 or 1) */
int Nrows = ILLEGAL;
int Ncols = ILLEGAL;
int Ntotal;
int OpenNodes;       /* total number of nodes opened */
int ClosNodes;       /* total number of nodes closed */
int MoveNodes;       /* total number of nodes moved */
@@ -194,7 +191,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
    PlaceCells( GetBoard(), -1, FORCE_PADS );

    /* Construction of the track list for router. */
    Build_Work( GetBoard() );
    RoutingMatrix.m_RouteCount = Build_Work( GetBoard() );

    // DisplayRoutingMatrix( m_canvas, DC );

@@ -234,7 +231,7 @@ void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC )
{
    int dcell0, dcell1 = 0, color;

    int maxi = 600 / Ncols;
    int maxi = 600 / RoutingMatrix.m_Ncols;
    maxi = ( maxi * 3 ) / 4;

    if( !maxi )
@@ -242,12 +239,12 @@ void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC )

    GRSetDrawMode( DC, GR_COPY );

    for( int col = 0; col < Ncols; col++ )
    for( int col = 0; col < RoutingMatrix.m_Ncols; col++ )
    {
        for( int row = 0; row < Nrows; row++ )
        for( int row = 0; row < RoutingMatrix.m_Nrows; row++ )
        {
            color  = 0;
            dcell0 = GetCell( row, col, BOTTOM );
            dcell0 = RoutingMatrix.GetCell( row, col, BOTTOM );

            if( dcell0 & HOLE )
                color = GREEN;
+34 −26
Original line number Diff line number Diff line
@@ -68,11 +68,6 @@ extern int Nb_Sides; /* Number of layers for autorouting (0 or 1) */

#define FORCE_PADS 1  /* Force placement of pads for any Netcode */

/* board dimensions */
extern int Nrows;
extern int Ncols;
extern int Ntotal;

/* search statistics */
extern int OpenNodes;   /* total number of nodes opened */
extern int ClosNodes;   /* total number of nodes closed */
@@ -88,26 +83,35 @@ typedef char DIR_CELL;

/**
 * class MATRIX_ROUTING_HEAD
 * handle the matrix routing that describes the actual board
 */
class MATRIX_ROUTING_HEAD  /* header of blocks of MATRIX_CELL */
class MATRIX_ROUTING_HEAD
{
public:
    MATRIX_CELL* m_BoardSide[MAX_SIDES_COUNT];  /* ptr to block of memory: 2-sided board */
    DIST_CELL*   m_DistSide[MAX_SIDES_COUNT];   /* ptr to block of memory: path distance to
                                                 * cells */
    DIR_CELL*    m_DirSide[MAX_SIDES_COUNT];    /* header of blocks of chars:pointers back to
                                                 * source */
    MATRIX_CELL* m_BoardSide[MAX_SIDES_COUNT];  // the image map of 2 board sides
    DIST_CELL*   m_DistSide[MAX_SIDES_COUNT];   // the image map of 2 board sides: distance to
                                                // cells
    DIR_CELL*    m_DirSide[MAX_SIDES_COUNT];    // the image map of 2 board sides: pointers back to
                                                // source
    bool         m_InitMatrixDone;
    int          m_Layers;
    int          m_Layers;                      // Layer count (1 2 )
    int          m_GridRouting;                 // Size of grid for autoplace/autoroute
    EDA_RECT     m_BrdBox;                      // Actual board bounding box
    int          m_Nrows, m_Ncols;
    int          m_MemSize;
    int          m_Nrows, m_Ncols;              // Matrix size
    int          m_MemSize;                     // Memory requirement, just for statistics
    int          m_RouteCount;                  // Number of routes
private:
    void        (MATRIX_ROUTING_HEAD::* m_opWriteCell)( int aRow, int aCol, int aSide, MATRIX_CELL aCell);  // a pointeur to the current selected cell op

public:
    MATRIX_ROUTING_HEAD();
    ~MATRIX_ROUTING_HEAD();

    void WriteCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell)
    {
        (*this.*m_opWriteCell)( aRow, aCol, aSide, aCell );
    }

    /**
     * Function ComputeMatrixSize
     * calculates the number of rows and columns of dimensions of \a aPcb for routing and
@@ -127,6 +131,21 @@ public:
    int InitRoutingMatrix();

    void UnInitRoutingMatrix();

    // Initialize WriteCell to make the aLogicOp
    void SetCellOperation( int aLogicOp );

    // functions to read/write one cell ( point on grid routing matrix:
    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);
};

extern MATRIX_ROUTING_HEAD RoutingMatrix;        /* 2-sided board */
@@ -195,20 +214,9 @@ void SortWork(); /* order the work items; shortest first */
int GetApxDist( int r1, int c1, int r2, int c2 );
int CalcDist(int x,int y,int z ,int side );

/* BOARD.CPP */
/* routing_matrix.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
+43 −157

File changed.

Preview size limit exceeded, changes collapsed.

+62 −38
Original line number Diff line number Diff line
@@ -69,14 +69,12 @@ bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb, bool aUseBoardEdgesOnl

    aPcb->SetBoundingBox( m_BrdBox );

    m_Nrows = Nrows = m_BrdBox.GetHeight() / m_GridRouting;
    m_Ncols = Ncols = m_BrdBox.GetWidth() / m_GridRouting;
    m_Nrows = m_BrdBox.GetHeight() / m_GridRouting;
    m_Ncols = m_BrdBox.GetWidth() / m_GridRouting;

    /* get a small margin for memory allocation: */
    Ncols += 1;
    m_Nrows = Nrows;
    Nrows += 1;
    m_Ncols = Ncols;
    // gives a small margin
    m_Ncols += 1;
    m_Nrows += 1;

    return true;
}
@@ -103,15 +101,13 @@ int MATRIX_ROUTING_HEAD::InitRoutingMatrix()
{
    int ii, kk;

    if( Nrows <= 0 || Ncols <= 0 )
    if( m_Nrows <= 0 || m_Ncols <= 0 )
        return 0;
    m_Nrows = Nrows;
    m_Ncols = Ncols;

    m_InitMatrixDone = true;     // we have been called

    // give a small margin for memory allocation:
   ii = (Nrows + 1) * (Ncols + 1);
   ii = (RoutingMatrix.m_Nrows + 1) * (RoutingMatrix.m_Ncols + 1);

    for( kk = 0; kk < m_Layers; kk++ )
    {
@@ -354,7 +350,7 @@ int Build_Work( BOARD* Pcb )
    EDA_RECT        bbbox = Pcb->GetBoundingBox();

    InitWork(); /* clear work list */
    Ntotal = 0;
    int cellCount = 0;

    for( unsigned ii = 0; ii < Pcb->GetRatsnestsCount(); ii++ )
    {
@@ -379,7 +375,7 @@ int Build_Work( BOARD* Pcb )

        r1 = ( pt_pad->GetPosition().y - bbbox.GetY() + demi_pas ) / RoutingMatrix.m_GridRouting;

        if( r1 < 0 || r1 >= Nrows )
        if( r1 < 0 || r1 >= RoutingMatrix.m_Nrows )
        {
            msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r1,
                        pt_pad->GetPosition().y, bbbox.GetY() );
@@ -389,7 +385,7 @@ int Build_Work( BOARD* Pcb )

        c1 = ( pt_pad->GetPosition().x - bbbox.GetX() + demi_pas ) / RoutingMatrix.m_GridRouting;

        if( c1 < 0 || c1 >= Ncols )
        if( c1 < 0 || c1 >= RoutingMatrix.m_Ncols )
        {
            msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c1,
                        pt_pad->GetPosition().x, bbbox.GetX() );
@@ -402,7 +398,7 @@ int Build_Work( BOARD* Pcb )
        r2 = ( pt_pad->GetPosition().y - bbbox.GetY()
               + demi_pas ) / RoutingMatrix.m_GridRouting;

        if( r2 < 0 || r2 >= Nrows )
        if( r2 < 0 || r2 >= RoutingMatrix.m_Nrows )
        {
            msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r2,
                        pt_pad->GetPosition().y, bbbox.GetY() );
@@ -412,7 +408,7 @@ int Build_Work( BOARD* Pcb )

        c2 = ( pt_pad->GetPosition().x - bbbox.GetX() + demi_pas ) / RoutingMatrix.m_GridRouting;

        if( c2 < 0 || c2 >= Ncols )
        if( c2 < 0 || c2 >= RoutingMatrix.m_Ncols )
        {
            msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c2,
                        pt_pad->GetPosition().x, bbbox.GetX() );
@@ -421,115 +417,143 @@ int Build_Work( BOARD* Pcb )
        }

        SetWork( r1, c1, current_net_code, r2, c2, pt_ch, 0 );
        Ntotal++;
        cellCount++;
    }

    SortWork();
    return Ntotal;
    return cellCount;
}

// Initialize WriteCell to make the aLogicOp
void MATRIX_ROUTING_HEAD::SetCellOperation( int aLogicOp )
{
    switch( aLogicOp )
    {
    default:
    case WRITE_CELL:
        m_opWriteCell = &MATRIX_ROUTING_HEAD::SetCell;
        break;

    case WRITE_OR_CELL:
        m_opWriteCell = &MATRIX_ROUTING_HEAD::OrCell;
        break;

    case WRITE_XOR_CELL:
        m_opWriteCell = &MATRIX_ROUTING_HEAD::XorCell;
        break;

    case WRITE_AND_CELL:
        m_opWriteCell = &MATRIX_ROUTING_HEAD::AndCell;
        break;

    case WRITE_ADD_CELL:
        m_opWriteCell = &MATRIX_ROUTING_HEAD::AddCell;
        break;
    }
}


/* return the value stored in a cell
 */
MATRIX_CELL GetCell( int aRow, int aCol, int aSide )
MATRIX_CELL MATRIX_ROUTING_HEAD::GetCell( int aRow, int aCol, int aSide )
{
    MATRIX_CELL* p;

    p = RoutingMatrix.m_BoardSide[aSide];
    return p[aRow * Ncols + aCol];
    return p[aRow * m_Ncols + aCol];
}


/* basic cell operation : WRITE operation
 */
void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
void MATRIX_ROUTING_HEAD::SetCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
    MATRIX_CELL* p;

    p = RoutingMatrix.m_BoardSide[aSide];
    p[aRow * Ncols + aCol] = x;
    p[aRow * m_Ncols + aCol] = x;
}


/* basic cell operation : OR operation
 */
void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
void MATRIX_ROUTING_HEAD::OrCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
    MATRIX_CELL* p;

    p = RoutingMatrix.m_BoardSide[aSide];
    p[aRow * Ncols + aCol] |= x;
    p[aRow * m_Ncols + aCol] |= x;
}


/* basic cell operation : XOR operation
 */
void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
void MATRIX_ROUTING_HEAD::XorCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
    MATRIX_CELL* p;

    p = RoutingMatrix.m_BoardSide[aSide];
    p[aRow * Ncols + aCol] ^= x;
    p[aRow * m_Ncols + aCol] ^= x;
}


/* basic cell operation : AND operation
 */
void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
void MATRIX_ROUTING_HEAD::AndCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
    MATRIX_CELL* p;

    p = RoutingMatrix.m_BoardSide[aSide];
    p[aRow * Ncols + aCol] &= x;
    p[aRow * m_Ncols + aCol] &= x;
}


/* basic cell operation : ADD operation
 */
void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
void MATRIX_ROUTING_HEAD::AddCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
    MATRIX_CELL* p;

    p = RoutingMatrix.m_BoardSide[aSide];
    p[aRow * Ncols + aCol] += x;
    p[aRow * m_Ncols + aCol] += x;
}


/* fetch distance cell */
DIST_CELL GetDist( int aRow, int aCol, int aSide ) /* fetch distance cell */
DIST_CELL MATRIX_ROUTING_HEAD::GetDist( int aRow, int aCol, int aSide ) /* fetch distance cell */
{
    DIST_CELL* p;

    p = RoutingMatrix.m_DistSide[aSide];
    return p[aRow * Ncols + aCol];
    return p[aRow * m_Ncols + aCol];
}


/* store distance cell */
void SetDist( int aRow, int aCol, int aSide, DIST_CELL x )
void MATRIX_ROUTING_HEAD::SetDist( int aRow, int aCol, int aSide, DIST_CELL x )
{
    DIST_CELL* p;

    p = RoutingMatrix.m_DistSide[aSide];
    p[aRow * Ncols + aCol] = x;
    p[aRow * m_Ncols + aCol] = x;
}


/* fetch direction cell */
int GetDir( int aRow, int aCol, int aSide )
int MATRIX_ROUTING_HEAD::GetDir( int aRow, int aCol, int aSide )
{
    DIR_CELL* p;

    p = RoutingMatrix.m_DirSide[aSide];
    return (int) (p[aRow * Ncols + aCol]);
    return (int) (p[aRow * m_Ncols + aCol]);
}


/* store direction cell */
void SetDir( int aRow, int aCol, int aSide, int x )
void MATRIX_ROUTING_HEAD::SetDir( int aRow, int aCol, int aSide, int x )
{
    DIR_CELL* p;

    p = RoutingMatrix.m_DirSide[aSide];
    p[aRow * Ncols + aCol] = (char) x;
    p[aRow * m_Ncols + aCol] = (char) x;
}
Loading