# Examples from pyvista.PolyData.save
# ===================================

# Save a mesh as a STL.
import pyvista as pv
sphere = pv.Sphere()
sphere.save('my_mesh.stl')

# Save a mesh as a PLY.
sphere = pv.Sphere()
sphere.save('my_mesh.ply')

# Save a mesh as a PLY with a texture array.  Here we also
# create a simple RGB array representing the texture.
import numpy as np
sphere = pv.Sphere()
texture = np.zeros((sphere.n_points, 3), np.uint8)
# Just the green channel is set as a repeatedly
# decreasing value
texture[:, 1] = np.arange(sphere.n_points)[::-1]
sphere.point_data['my_texture'] = texture
sphere.save('my_mesh.ply', texture='my_texture')

# Alternatively, provide just the texture array.  This will be
# written to the file as `'RGB'` since it does not contain an
# alpha channel.
sphere.save('my_mesh.ply', texture=texture)

# Save a mesh as a VTK file.
sphere = pv.Sphere()
sphere.save('my_mesh.vtk')

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

