# Examples from pyvista.PolyData.vert_offsets
# ===========================================

import pyvista as pv
mesh = pv.PolyData([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
mesh.vert_offsets

# The offsets and connectivity together describe each vertex cell.
mesh.vert_connectivity[mesh.vert_offsets[0] : mesh.vert_offsets[1]]

# The array is read-only and writing to it raises a `ValueError`.
mesh.vert_offsets.flags['WRITEABLE']

# Assign a new array instead. Here the three point ids are re-partitioned into a
# single polyvertex cell.
mesh.vert_offsets = [0, 3]
mesh.n_verts

# To replace the offsets and connectivity together, assign a
# `pyvista.CellArray` to `verts`.
mesh.verts = pv.CellArray.from_arrays([0, 1, 2], [0, 1])
mesh.n_verts

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