# trace generated using paraview version 5.13.1
#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()

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

# get active view
renderView1 = GetActiveViewOrCreate('RenderView')

# show data in view
topstlDisplay = Show(topstl, renderView1, 'GeometryRepresentation')

# trace defaults for the display properties.
topstlDisplay.Representation = 'Surface'

# reset view to fit data
renderView1.ResetCamera(False, 0.9)

# get the material library
materialLibrary1 = GetMaterialLibrary()

# show color bar/color legend
topstlDisplay.SetScalarBarVisibility(renderView1, True)

# update the view to ensure updated data information
renderView1.Update()

# get color transfer function/color map for 'STLSolidLabeling'
sTLSolidLabelingLUT = GetColorTransferFunction('STLSolidLabeling')

# get opacity transfer function/opacity map for 'STLSolidLabeling'
sTLSolidLabelingPWF = GetOpacityTransferFunction('STLSolidLabeling')

# get 2D transfer function for 'STLSolidLabeling'
sTLSolidLabelingTF2D = GetTransferFunction2D('STLSolidLabeling')

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

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

# trace defaults for the display properties.
textureMaptoPlane1Display.Representation = 'Surface'

# hide data in view
Hide(topstl, renderView1)

# show color bar/color legend
textureMaptoPlane1Display.SetScalarBarVisibility(renderView1, True)

# update the view to ensure updated data information
renderView1.Update()

# turn off scalar coloring
ColorBy(textureMaptoPlane1Display, None)

# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(sTLSolidLabelingLUT, renderView1)

# Properties modified on textureMaptoPlane1
textureMaptoPlane1.Origin = [-424.5, -331.5, 0.0]
textureMaptoPlane1.Point1 = [424.5, -331.5, 0.0]
textureMaptoPlane1.Point2 = [-424.5, 331.5, 0.0]

# update the view to ensure updated data information
renderView1.Update()

# a texture
satellite_clipped = FindTextureOrCreate(registrationName='satellite_clipped', filename='/home/...../shallow_fluid/satellite_clipped.png')

# change texture
textureMaptoPlane1Display.Texture = satellite_clipped

#================================================================
# addendum: following script captures some of the application
# state to faithfully reproduce the visualization during playback
#================================================================

# get layout
layout1 = GetLayout()

#--------------------------------
# saving layout sizes for layouts

# layout/tab size in pixels
layout1.SetSize(1298, 718)

#-----------------------------------
# saving camera placements for views

# current camera placement for renderView1
renderView1.CameraPosition = [0.0, 0.0, 2335.994390244287]
renderView1.CameraFocalPoint = [0.0, 0.0, 248.8249969482422]
renderView1.CameraParallelScale = 540.1991893400899


##--------------------------------------------
## 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("path/to/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
##--------------------------------------------
