 
                 gridSpinEnergy = externalField;
 
-                for (int x = (int) i - radiusX; x <= (int) i + radiusX; x++)
-                {
-                    for (int y = (int) j - radiusY; y <= (int) j + radiusY; y++)
+                for (int x = i - radiusX; x <= i + radiusX; x++)
+                {
+                    for (int y = j - radiusY; y <= j + radiusY; y++)
                     {
-                        for (int z = (int) k - radiusZ; z <= (int) k + radiusZ; z++)
+                        for (int z = k - radiusZ; z <= k + radiusZ; z++)
                         {
                             xx = (xSize + x) % xSize;
                             yy = (ySize + y) % ySize;

                uint ipos = index * 24;

                // Перед
                indices[ipos++] = vpos + 0;
                indices[ipos++] = vpos + 4;
                indices[ipos++] = vpos + 5;
                indices[ipos++] = vpos + 1;

                // Зад
                indices[ipos++] = vpos + 2;
                indices[ipos++] = vpos + 3;
                indices[ipos++] = vpos + 7;
                indices[ipos++] = vpos + 6;

                // Верх
                indices[ipos++] = vpos + 1;
                indices[ipos++] = vpos + 5;
                indices[ipos++] = vpos + 7;
                indices[ipos++] = vpos + 3;

                // Низ
                indices[ipos++] = vpos + 0;
                indices[ipos++] = vpos + 2;
                indices[ipos++] = vpos + 6;
                indices[ipos++] = vpos + 4;

                // Лево
                indices[ipos++] = vpos + 0;
                indices[ipos++] = vpos + 1;
                indices[ipos++] = vpos + 3;
                indices[ipos++] = vpos + 2;

                // Право
                indices[ipos++] = vpos + 4;
                indices[ipos++] = vpos + 6;
                indices[ipos++] = vpos + 7;
                indices[ipos++] = vpos + 5;
            }
        }
    }

        case DIM_2: radiusZ = 0; break;
    }

    for (int i = idx + idx * interactionRadius + iterx; i < xSize; i += gridOffsetx)
    {
        for (int j = idy + idy * interactionRadius + itery; j < ySize; j += gridOffsety)
        {
            for (int k = idz + idz * interactionRadius + iterz; k < zSize; k += gridOffsetz)
            {
                index = gridIndex(i, j, k);
                spinValue = data[index] - 1;
