The issue is the ordering of numpy multidimensional arrays, and in particular the use of meshgrid.
Try switching your meshgrid around like this:
Z, Y, X = np.meshgrid(
np.linspace(-0.012, 0.036, 21), # Z space
np.linspace(-0.006, 0.027, 21), # Y space
np.linspace( 0.120, 0.225, 51), # X space
indexing='ij')
If your meshgrid is built correctly, then when you print out the points, you should see the X values changing the most rapidly, followed by Y, and then followed by Z:
# Points:
# 0 1 2 ... 22488 22489 22490
[0.12 0.1221 0.1242 ... 0.2208 0.2229 0.225] # X.ravel()
[-0.006 -0.006 -0.006 ... 0.027 0.027 0.027] # Y.ravel()
[-0.012 -0.012 -0.012 ... 0.036 0.036 0.036] # Z.ravel()
On the other hand, if Point 0 and Point 1 have the same X value, then you know that meshgrid has produced a grid that’s not ordered correctly for VTK.
Also be sure to switch around the numpy array dimensions before you use them in VTK:
z_size, y_size, x_size = X.shape
sg.SetDimensions(x_size, y_size, z_size)
Some people prefer to transpose the numpy arrays before using them with VTK, but I prefer to leave all the arrays in their original ordering, and just re-order the indices instead.