Repository: pyvista/pyvista

Issue:
ImageData.x, returns unexpected value when non-zero extent is set.
### Describe the bug, what's wrong, and what you expected.

1) Build `ImageData` with a certain spacing other than 1.0
2) Modify the `extent` of the `ImageData`
3) `ImageData.x` returns a wrong array from what is expected from `ImageData.bounds`

Please see the following code.

Possible cause:
I suppose  `ox, oy, oz = np.array(self.origin) + np.array(self.extent[::2])  # type: ignore` in line 670 of 
https://github.com/pyvista/pyvista/blob/main/pyvista/core/grid.py should be 

`ox, oy, oz = np.array(self.origin) + np.array(self.extent[0] * dx, self.extent[1] * dy, self.extent[2] * dz])`

### Steps to reproduce the bug.

```python
import pyvista as pv

img_grid = pv.ImageData(dimensions=(10, 10, 10), origin=(-0.5, -0.3, -0.1), spacing=(0.1, 0.05, 0.01))
print(img_grid.x[:10])  # "[-0.5 -0.4 -0.3 -0.2 -0.1  0.   0.1  0.2  0.3  0.4]"
img_grid.extent = (5, 9, 0, 9, 0, 9)
print(img_grid.x[:5])   # "[4.5 4.6 4.7 4.8 4.9]"
# I expect "[0.   0.1  0.2  0.3  0.4]"
print(img_grid.bounds)  # (0.0, 0.4, -0.3, 0.15000000000000002, -0.1, -0.010000000000000009)
```

### System Information

```shell
--------------------------------------------------------------------------------
  Date: Thu Feb 01 22:21:26 2024 東京 (標準時)

                OS : Windows
            CPU(s) : 16
           Machine : AMD64
      Architecture : 64bit
               RAM : 30.8 GiB
       Environment : IPython
        GPU Vendor : ATI Technologies Inc.
      GPU Renderer : AMD Radeon(TM) Graphics
       GPU Version : 4.6.0 Compatibility Profile Context 23.10.24.05.230830
  MathText Support : False

  Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64
  bit (AMD64)]

           pyvista : 0.43.2
               vtk : 9.3.0
             numpy : 1.26.3
        matplotlib : 3.8.2
            scooby : 0.9.2
             pooch : 1.8.0
            pillow : 10.2.0
           IPython : 8.21.0
      nest_asyncio : 1.6.0
--------------------------------------------------------------------------------
```


### Screenshots

_No response_

Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/pyvista/pyvista/pull/5569?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyvista) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`71efc2f`)](https://app.codecov.io/gh/pyvista/pyvista/commit/71efc2fa5b4f3fc664752b7bcd55372b4b228c61?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyvista) 96.45% compared to head [(`c5864ee`)](https://app.codecov.io/gh/pyvista/pyvista/pull/5569?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyvista) 89.91%.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main    #5569      +/-   ##
==========================================
- Coverage   96.45%   89.91%   -6.55%     
==========================================
  Files         136      136              
  Lines       23118    23118              
==========================================
- Hits        22299    20787    -1512     
- Misses        819     2331    +1512     
```

</details>
tkoyama010: @pyvista-bot LGTM

Patch:
diff --git a/pyvista/core/grid.py b/pyvista/core/grid.py
index c22d3855..71daf034 100644
--- a/pyvista/core/grid.py
+++ b/pyvista/core/grid.py
@@ -667,7 +667,7 @@ class ImageData(_vtk.vtkImageData, Grid, ImageDataFilters):
         # get the points and convert to spacings
         dx, dy, dz = self.spacing
         # Now make the cell arrays
-        ox, oy, oz = np.array(self.origin) + np.array(self.extent[::2])  # type: ignore
+        ox, oy, oz = np.array(self.origin) + self.extent[::2] * np.array([dx, dy, dz])
         x = np.insert(np.cumsum(np.full(nx, dx)), 0, 0.0) + ox
         y = np.insert(np.cumsum(np.full(ny, dy)), 0, 0.0) + oy
         z = np.insert(np.cumsum(np.full(nz, dz)), 0, 0.0) + oz


Test patch:
diff --git a/tests/core/test_grid.py b/tests/core/test_grid.py
index c75e2167..5918b89e 100644
--- a/tests/core/test_grid.py
+++ b/tests/core/test_grid.py
@@ -1184,6 +1184,14 @@ def test_set_extent():
     assert np.array_equal(uni_grid.extent, extent)
 
 
+def test_set_extent_width_spacing():
+    grid = pv.ImageData(
+        dimensions=(10, 10, 10), origin=(-0.5, -0.3, -0.1), spacing=(0.1, 0.05, 0.01)
+    )
+    grid.extent = (5, 9, 0, 9, 0, 9)
+    assert np.allclose(grid.x[:5], [0.0, 0.1, 0.2, 0.3, 0.4])
+
+
 def test_UnstructuredGrid_cast_to_explicit_structured_grid():
     grid = examples.load_explicit_structured()
     grid = grid.hide_cells(range(80, 120))