# Examples from pyvista.ImageDataFilters.points_to_cells
# ======================================================

# Load an image with point data.
from pyvista import examples
image = examples.load_uniform()

# Show the current properties and point arrays of the image.
image

image.point_data.keys()

# Re-mesh the points and point data as cells and cell data.
cells_image = image.points_to_cells()

# Show the properties and cell arrays of the re-meshed image.
cells_image

cells_image.cell_data.keys()

# Observe that:

# - The input point array is now a cell array
# - The output has one less array (the input cell data is ignored)
# - The dimensions have increased by one
# - The bounds have increased by half the spacing
# - The output `N Cells` equals the input `N Points`

# Since the input points are 3D (that is, there are no singleton dimensions), the
# output cells are 3D `VOXEL` cells.
cells_image.get_cell(0).type

# If the input points are 2D (that is, one dimension is singleton), the
# output cells are 2D `PIXEL` cells when `dimensions` is
# set to `'preserve'`.
image2D = examples.download_beach()
image2D.dimensions

pixel_cells_image = image2D.points_to_cells(dimensionality='preserve')
pixel_cells_image.dimensions
pixel_cells_image.get_cell(0).type

# This is equivalent as requesting a 2D output.
pixel_cells_image = image2D.points_to_cells(dimensionality='2D')
pixel_cells_image.dimensions
pixel_cells_image.get_cell(0).type

# Use `(True, True, True)` to re-mesh 2D points as 3D cells.
voxel_cells_image = image2D.points_to_cells(
    dimensionality=(True, True, True)
)
voxel_cells_image.dimensions
voxel_cells_image.get_cell(0).type

# Or request a 3D output.
voxel_cells_image = image2D.points_to_cells(dimensionality='3D')
voxel_cells_image.dimensions
voxel_cells_image.get_cell(0).type

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