# state file generated using paraview version 5.13.3
import paraview
paraview.compatibility.major = 5
paraview.compatibility.minor = 13

#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

# ----------------------------------------------------------------
# setup views used in the visualization
# ----------------------------------------------------------------

# get the material library
materialLibrary1 = GetMaterialLibrary()

# Create a new 'Render View'
renderView1 = CreateView('RenderView')
renderView1.ViewSize = [1377, 1206]
renderView1.AxesGrid = 'Grid Axes 3D Actor'
renderView1.CenterOfRotation = [0.0, 0.0, 235.75049591064453]
renderView1.StereoType = 'Crystal Eyes'
renderView1.CameraPosition = [0.0, 0.0, 1129.2927473799534]
renderView1.CameraFocalPoint = [0.0, 0.0, 235.75049591064453]
renderView1.CameraFocalDisk = 1.0
renderView1.CameraParallelScale = 231.26575228404297
renderView1.LegendGrid = 'Legend Grid Actor'
renderView1.PolarGrid = 'Polar Grid Actor'
renderView1.BackEnd = 'OSPRay raycaster'
renderView1.OSPRayMaterialLibrary = materialLibrary1

SetActiveView(None)

# ----------------------------------------------------------------
# setup view layouts
# ----------------------------------------------------------------

# create new layout object 'Layout #1'
layout1 = CreateLayout(name='Layout #1')
layout1.AssignView(0, renderView1)
layout1.SetSize(1377, 1206)

# ----------------------------------------------------------------
# restore active view
SetActiveView(renderView1)
# ----------------------------------------------------------------

# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------

# create a new 'STL Reader'
topstl = STLReader(registrationName='top.stl', FileNames=['/home/glow/data/tmp/top.stl'])

# create a new 'Texture Map to Plane'
textureMaptoPlane1 = TextureMaptoPlane(registrationName='TextureMaptoPlane1', Input=topstl)

# ----------------------------------------------------------------
# setup the visualization in view 'renderView1'
# ----------------------------------------------------------------

# show data from textureMaptoPlane1
textureMaptoPlane1Display = Show(textureMaptoPlane1, renderView1, 'GeometryRepresentation')

# a texture
images = FindTextureOrCreate(registrationName='images', filename='/home/glow/data/tmp/images.png')

# trace defaults for the display properties.
textureMaptoPlane1Display.Representation = 'Surface'
textureMaptoPlane1Display.ColorArrayName = [None, '']
textureMaptoPlane1Display.SelectNormalArray = 'None'
textureMaptoPlane1Display.SelectTangentArray = 'None'
textureMaptoPlane1Display.SelectTCoordArray = 'Texture Coordinates'
textureMaptoPlane1Display.Texture = images
textureMaptoPlane1Display.TextureTransform = 'Transform2'
textureMaptoPlane1Display.OSPRayScaleArray = 'Texture Coordinates'
textureMaptoPlane1Display.OSPRayScaleFunction = 'Piecewise Function'
textureMaptoPlane1Display.Assembly = ''
textureMaptoPlane1Display.SelectedBlockSelectors = ['']
textureMaptoPlane1Display.SelectOrientationVectors = 'None'
textureMaptoPlane1Display.ScaleFactor = 37.5
textureMaptoPlane1Display.SelectScaleArray = 'None'
textureMaptoPlane1Display.GlyphType = 'Arrow'
textureMaptoPlane1Display.GlyphTableIndexArray = 'None'
textureMaptoPlane1Display.GaussianRadius = 1.875
textureMaptoPlane1Display.SetScaleArray = ['POINTS', 'Texture Coordinates']
textureMaptoPlane1Display.ScaleTransferFunction = 'Piecewise Function'
textureMaptoPlane1Display.OpacityArray = ['POINTS', 'Texture Coordinates']
textureMaptoPlane1Display.OpacityTransferFunction = 'Piecewise Function'
textureMaptoPlane1Display.DataAxesGrid = 'Grid Axes Representation'
textureMaptoPlane1Display.PolarAxes = 'Polar Axes Representation'
textureMaptoPlane1Display.SelectInputVectors = [None, '']
textureMaptoPlane1Display.WriteLog = ''

# init the 'Piecewise Function' selected for 'ScaleTransferFunction'
textureMaptoPlane1Display.ScaleTransferFunction.Points = [-0.00900737103074789, 0.0, 0.5, 0.0, 1.0078002214431763, 1.0, 0.5, 0.0]

# init the 'Piecewise Function' selected for 'OpacityTransferFunction'
textureMaptoPlane1Display.OpacityTransferFunction.Points = [-0.00900737103074789, 0.0, 0.5, 0.0, 1.0078002214431763, 1.0, 0.5, 0.0]

# ----------------------------------------------------------------
# setup animation scene, tracks and keyframes
# note: the Get..() functions create a new object, if needed
# ----------------------------------------------------------------

# get time animation track
timeAnimationCue1 = GetTimeTrack()

# initialize the animation scene

# get the time-keeper
timeKeeper1 = GetTimeKeeper()

# initialize the timekeeper

# initialize the animation track

# get animation scene
animationScene1 = GetAnimationScene()

# initialize the animation scene
animationScene1.ViewModules = renderView1
animationScene1.Cues = timeAnimationCue1
animationScene1.AnimationTime = 0.0

# ----------------------------------------------------------------
# restore active source
SetActiveSource(textureMaptoPlane1)
# ----------------------------------------------------------------


##--------------------------------------------
## You may need to add some code at the end of this python script depending on your usage, eg:
#
## Render all views to see them appears
# RenderAllViews()
#
## Interact with the view, usefull when running from pvpython
# Interact()
#
## Save a screenshot of the active view
SaveScreenshot("/home/glow/data/tmp/screenshot.png")
#
## Save a screenshot of a layout (multiple splitted view)
# SaveScreenshot("path/to/screenshot.png", GetLayout())
#
## Save all "Extractors" from the pipeline browser
# SaveExtracts()
#
## Save a animation of the current active view
# SaveAnimation()
#
## Please refer to the documentation of paraview.simple
## https://www.paraview.org/paraview-docs/latest/python/paraview.simple.html
##--------------------------------------------
