Commit bb2cb747 authored by Luís de Sousa's avatar Luís de Sousa
Browse files

Switched odd/even neighbourhood calculations to accomodate CADDIES (0,0) cell shift.

parent c98af9cf
......@@ -1091,6 +1091,10 @@ inline void caActivateAlarmMask(CA_GRID grid, CA_ALARMS_O alarms, CA_STATE mask,
// ---- CELL BUFFERS ----
//! Note that the odd/even neighbourhood selection methods are actually backwards.
//! CADDIES is shifting the internal (0,0) index to the (-1,-1) cell in the original
//! grid coordinates. Therefore column 0 in original falls into an odd column in
//! the structures created by CADDIES.
//! Read the real value of the cell from the given buffer at the given cell number.
inline _caReal caReadCellBuffReal(CA_GRID grid, CA_CELLBUFF_REAL_I src, int cell_number)
......@@ -1106,26 +1110,26 @@ inline _caReal caReadCellBuffReal(CA_GRID grid, CA_CELLBUFF_REAL_I src, int cel
{
switch(cell_number)
{
case 0: return src[i]; break;
case 1: return src[i-x_size+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-x_size-1]; break;
case 4: return src[i-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+1]; break;
case 0: return src[i]; break;
case 1: return src[i+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-1]; break;
case 4: return src[i+x_size-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+x_size+1]; break;
}
}
else //even
{
switch(cell_number)
{
case 0: return src[i]; break;
case 1: return src[i+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-1]; break;
case 4: return src[i+x_size-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+x_size+1]; break;
case 0: return src[i]; break;
case 1: return src[i-x_size+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-x_size-1]; break;
case 4: return src[i-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+1]; break;
}
}
......@@ -1147,19 +1151,19 @@ inline void caReadCellBuffRealCellArray(CA_GRID grid, CA_CELLBUFF_REAL_I src, _
if(grid.main_x % 2) //odd
{
values[1] = src[i-x_size+1];
values[3] = src[i-x_size-1];
values[4] = src[i-1];
values[6] = src[i+1];
}
else //even
{
values[1] = src[i+1];
values[3] = src[i-1];
values[4] = src[i+x_size-1];
values[6] = src[i+x_size+1];
}
else //even
{
values[1] = src[i-x_size+1];
values[3] = src[i-x_size-1];
values[4] = src[i-1];
values[6] = src[i+1];
}
}
......@@ -1182,26 +1186,26 @@ inline _caState caReadCellBuffState(CA_GRID grid, CA_CELLBUFF_STATE_I src, int
{
switch(cell_number)
{
case 0: return src[i]; break;
case 1: return src[i-x_size+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-x_size-1]; break;
case 4: return src[i-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+1]; break;
case 0: return src[i]; break;
case 1: return src[i+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-1]; break;
case 4: return src[i+x_size-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+x_size+1]; break;
}
}
else //even
{
switch(cell_number)
{
case 0: return src[i]; break;
case 1: return src[i+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-1]; break;
case 4: return src[i+x_size-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+x_size+1]; break;
case 0: return src[i]; break;
case 1: return src[i-x_size+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-x_size-1]; break;
case 4: return src[i-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+1]; break;
}
}
......@@ -1223,17 +1227,17 @@ inline void caReadCellBuffStateCellArray(CA_GRID grid, CA_CELLBUFF_STATE_I src,
if(grid.main_x % 2) //odd
{
values[1] = src[i-x_size+1];
values[3] = src[i-x_size-1];
values[4] = src[i-1];
values[6] = src[i+1];
values[1] = src[i+1];
values[3] = src[i-1];
values[4] = src[i+x_size-1];
values[6] = src[i+x_size+1];
}
else //even
{
values[1] = src[i+1];
values[3] = src[i-1];
values[4] = src[i+x_size-1];
values[6] = src[i+x_size+1];
values[1] = src[i-x_size+1];
values[3] = src[i-x_size-1];
values[4] = src[i-1];
values[6] = src[i+1];
}
}
......@@ -1260,12 +1264,12 @@ inline void getXY(int cell_number, _caUnsigned main_x, _caUnsigned main_y,
switch(cell_number)
{
case 0: break;
case 1: x += 1; y -= 1; break;
case 1: x += 1; break;
case 2: y -= 1; break;
case 3: x -= 1; y -= 1; break;
case 4: x -= 1; break;
case 3: x -= 1; break;
case 4: x -= 1; y += 1; break;
case 5: y += 1; break;
case 6: x -= 1; break;
case 6: x += 1; y += 1; break;
}
}
else //even
......@@ -1273,12 +1277,12 @@ inline void getXY(int cell_number, _caUnsigned main_x, _caUnsigned main_y,
switch(cell_number)
{
case 0: break;
case 1: x += 1; break;
case 1: x += 1; y -= 1; break;
case 2: y -= 1; break;
case 3: x -= 1; break;
case 4: x -= 1; y += 1; break;
case 3: x -= 1; y -= 1; break;
case 4: x -= 1; break;
case 5: y += 1; break;
case 6: x += 1; y += 1; break;
case 6: x -= 1; break;
}
}
}
......
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