public int PosToInt(ushort x, ushort y, ushort z)
{
if (x < 0) { return -1; }
if (x >= width) { return -1; }
if (y < 0) { return -1; }
if (y >= depth) { return -1; }
if (z < 0) { return -1; }
if (z >= height) { return -1; }
return x + z * width + y * width * height;
//alternate method: (h * widthY + y) * widthX + x;
}