# Examples from pyvista.StructuredGrid
# ====================================

import pyvista as pv
import vtk
import numpy as np

# Create an empty structured grid.
grid = pv.StructuredGrid()

# Initialize from a vtkStructuredGrid object
vtkgrid = vtk.vtkStructuredGrid()
grid = pv.StructuredGrid(vtkgrid)

# Create from NumPy arrays using `numpy.meshgrid()`.
xrng = np.linspace(-5, 5, 10)
yrng = np.linspace(-8, 8, 4)
zrng = np.linspace(-7, 4, 20)
x, y, z = np.meshgrid(xrng, yrng, zrng, indexing='ij')
grid = pv.StructuredGrid(x, y, z)
grid

# Note how the grid dimensions match the shape of the input arrays.
(xrng.size, yrng.size, zrng.size)

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code

