# state file generated using paraview version 5.10.0

# uncomment the following three lines to ensure this script works in future versions
#import paraview
#paraview.compatibility.major = 5
#paraview.compatibility.minor = 10

#### 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 = [568, 788]
renderView1.AxesGrid = 'GridAxes3DActor'
renderView1.CenterOfRotation = [160.73953247070312, 39.0, 0.0]
renderView1.StereoType = 'Crystal Eyes'
renderView1.CameraPosition = [985.7877577083393, -2.466490206588091, -32.19984521645697]
renderView1.CameraFocalPoint = [160.73953247070312, 39.0, 0.0]
renderView1.CameraViewUp = [0.054487604006856566, 0.9913391691593761, 0.11948955058912007]
renderView1.CameraFocalDisk = 1.0
renderView1.CameraParallelScale = 213.97008505606624
renderView1.BackEnd = 'OSPRay raycaster'
renderView1.OSPRayMaterialLibrary = materialLibrary1

# Create a new 'SpreadSheet View'
spreadSheetView1 = CreateView('SpreadSheetView')
spreadSheetView1.ColumnToSort = ''
spreadSheetView1.BlockSize = 1024

SetActiveView(None)

# ----------------------------------------------------------------
# setup view layouts
# ----------------------------------------------------------------

# create new layout object 'Layout #1'
layout1 = CreateLayout(name='Layout #1')
layout1.SplitHorizontal(0, 0.500000)
layout1.AssignView(1, renderView1)
layout1.AssignView(2, spreadSheetView1)
layout1.SetSize(969, 788)

# ----------------------------------------------------------------
# restore active view
SetActiveView(renderView1)
# ----------------------------------------------------------------

# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------

# create a new 'CGNS Series Reader'
CombustorResults = CGNSSeriesReader(registrationName='CombustorResults.cgns', FileNames=['C:\\Users\\lucat\\Desktop\\Combustor\\Input files\\Hot-flow\\CombustorResults.cgns'])
CombustorResults.Bases = ['Base_Volume_Elements']
CombustorResults.PointArrayStatus = ['Mach_number']

# create a new 'CSV Reader'
polylinecsv = CSVReader(registrationName='polyline.csv', FileName=['C:\\Users\\lucat\\Desktop\\Combustor\\polyline.csv'])
polylinecsv.HaveHeaders = 0
polylinecsv.FieldDelimiterCharacters = ' '

# create a new 'Table To Points'
tableToPoints1 = TableToPoints(registrationName='TableToPoints1', Input=polylinecsv)
tableToPoints1.XColumn = 'Field 0'
tableToPoints1.YColumn = 'Field 1'
tableToPoints1.ZColumn = 'Field 2'


#Trying the slicing
slices = {}
for i in range (len( tableToPoints1.XColumn )):
	slices["Slice{0}".format( i + 1 )] = Slice(registrationName='Slice'+str(i+1), Input=CombustorResults)
	slices["Slice{0}".format( i + 1 )].SliceType.Origin = [tableToPoints1.XColumn[i] , 0, 0]
	slices["Slice{0}".format( i + 1 )].SliceType.Normal = [1, 0, 0]
	slices["Slice{0}".format( i + 1 )].SliceType = 'Plane'
	slices["Slice{0}".format( i + 1 )].HyperTreeGridSlicer = 'Plane'
	slices["Slice{0}".format( i + 1 )].SliceOffsetValues = [0.0]
	
# # init the 'Plane' selected for 'HyperTreeGridSlicer'
# slices["Slice{0}".format( i + 1 )].HyperTreeGridSlicer.Origin = [160.73953247070312, 39.0, 0.0]


# ----------------------------------------------------------------
# setup the visualization in view 'renderView1'
# ----------------------------------------------------------------

# show data from CombustorResults
CombustorResultsDisplay = Show(CombustorResults, renderView1, 'UnstructuredGridRepresentation')

# get color transfer function/color map for 'Mach_number'
mach_numberLUT = GetColorTransferFunction('Mach_number')
mach_numberLUT.RGBPoints = [0.0, 0.231373, 0.298039, 0.752941, 1.3283933401107788, 0.865003, 0.865003, 0.865003, 2.6567866802215576, 0.705882, 0.0156863, 0.14902]
mach_numberLUT.ScalarRangeInitialized = 1.0

# get opacity transfer function/opacity map for 'Mach_number'
mach_numberPWF = GetOpacityTransferFunction('Mach_number')
mach_numberPWF.Points = [0.0, 0.0, 0.5, 0.0, 2.6567866802215576, 1.0, 0.5, 0.0]
mach_numberPWF.ScalarRangeInitialized = 1

# trace defaults for the display properties.
CombustorResultsDisplay.Representation = 'Surface'
CombustorResultsDisplay.ColorArrayName = ['POINTS', 'Mach_number']
CombustorResultsDisplay.LookupTable = mach_numberLUT
CombustorResultsDisplay.SelectTCoordArray = 'None'
CombustorResultsDisplay.SelectNormalArray = 'None'
CombustorResultsDisplay.SelectTangentArray = 'None'
CombustorResultsDisplay.OSPRayScaleArray = 'Mach_number'
CombustorResultsDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
CombustorResultsDisplay.SelectOrientationVectors = 'None'
CombustorResultsDisplay.ScaleFactor = 32.14790649414063
CombustorResultsDisplay.SelectScaleArray = 'Mach_number'
CombustorResultsDisplay.GlyphType = 'Arrow'
CombustorResultsDisplay.GlyphTableIndexArray = 'Mach_number'
CombustorResultsDisplay.GaussianRadius = 1.6073953247070314
CombustorResultsDisplay.SetScaleArray = ['POINTS', 'Mach_number']
CombustorResultsDisplay.ScaleTransferFunction = 'PiecewiseFunction'
CombustorResultsDisplay.OpacityArray = ['POINTS', 'Mach_number']
CombustorResultsDisplay.OpacityTransferFunction = 'PiecewiseFunction'
CombustorResultsDisplay.DataAxesGrid = 'GridAxesRepresentation'
CombustorResultsDisplay.PolarAxes = 'PolarAxesRepresentation'
CombustorResultsDisplay.ScalarOpacityFunction = mach_numberPWF
CombustorResultsDisplay.ScalarOpacityUnitDistance = 1.1627063012326124
CombustorResultsDisplay.OpacityArrayName = ['POINTS', 'Mach_number']
CombustorResultsDisplay.custom_kernel = ''

# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
CombustorResultsDisplay.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 2.6567866802215576, 1.0, 0.5, 0.0]

# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
CombustorResultsDisplay.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 2.6567866802215576, 1.0, 0.5, 0.0]

# show data from tableToPoints1
tableToPoints1Display = Show(tableToPoints1, renderView1, 'GeometryRepresentation')

# trace defaults for the display properties.
tableToPoints1Display.Representation = 'Surface'
tableToPoints1Display.ColorArrayName = [None, '']
tableToPoints1Display.SelectTCoordArray = 'None'
tableToPoints1Display.SelectNormalArray = 'None'
tableToPoints1Display.SelectTangentArray = 'None'
tableToPoints1Display.OSPRayScaleFunction = 'PiecewiseFunction'
tableToPoints1Display.SelectOrientationVectors = 'None'
tableToPoints1Display.ScaleFactor = 32.147999999999996
tableToPoints1Display.SelectScaleArray = 'None'
tableToPoints1Display.GlyphType = 'Arrow'
tableToPoints1Display.GlyphTableIndexArray = 'None'
tableToPoints1Display.GaussianRadius = 1.6074
tableToPoints1Display.SetScaleArray = [None, '']
tableToPoints1Display.ScaleTransferFunction = 'PiecewiseFunction'
tableToPoints1Display.OpacityArray = [None, '']
tableToPoints1Display.OpacityTransferFunction = 'PiecewiseFunction'
tableToPoints1Display.DataAxesGrid = 'GridAxesRepresentation'
tableToPoints1Display.PolarAxes = 'PolarAxesRepresentation'

# setup the color legend parameters for each legend in this view

# get color legend/bar for mach_numberLUT in view renderView1
mach_numberLUTColorBar = GetScalarBar(mach_numberLUT, renderView1)
mach_numberLUTColorBar.Title = 'Mach_number'
mach_numberLUTColorBar.ComponentTitle = ''

# set color bar visibility
mach_numberLUTColorBar.Visibility = 1

# show color legend
CombustorResultsDisplay.SetScalarBarVisibility(renderView1, True)

# ----------------------------------------------------------------
# setup the visualization in view 'spreadSheetView1'
# ----------------------------------------------------------------

# show data from tableToPoints1
tableToPoints1Display_1 = Show(tableToPoints1, spreadSheetView1, 'SpreadSheetRepresentation')

# trace defaults for the display properties.
tableToPoints1Display_1.Assembly = ''

# ----------------------------------------------------------------
# setup color maps and opacity mapes used in the visualization
# note: the Get..() functions create a new object, if needed
# ----------------------------------------------------------------

# ----------------------------------------------------------------
# restore active source
SetActiveSource(tableToPoints1)
# ----------------------------------------------------------------


if __name__ == '__main__':
    # generate extracts
    SaveExtracts(ExtractsOutputDirectory='extracts')