Commit 1f9c298e authored by Radek Galabov's avatar Radek Galabov
Browse files

Replace pv_pipeline_10.py

parent 43e8c98f
Loading
Loading
Loading
Loading
+51 −22
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@
# To ensure correct image size when batch processing, please search 
# for and uncomment the line `# renderView*.ViewSize = [*,*]`

ResetSession()
print(100*'\n')

def updateFlow():
    extractSelection1 = FindSource('ExtractSelection1')
@@ -42,9 +44,10 @@ selectFlag = 1;
automFlag  =  1;

# paths and filenames
base = r'C:\\Users\\galr\\Desktop\\pacienti_rozpracovani\\G318_patient18_bodyPart1_visit1_manual_autom'  +  os.sep
base  =  r'C:\\Users\\galr\\Desktop\\pacienti_rozpracovani\\G318_patient62_bodyPart2_visit0_autom_manual'  +  os.sep

##base = r'C:\\Users\\galr\\Desktop\\pacienti_rozpracovani\\G318_patient18_bodyPart1_visit1_manual_autom'.replace('\\','\\\\')  +  2*os.sep
base  =  r'C:\Users\galr\Desktop\pacienti_rozpracovani\G318_patient62_bodyPart2_visit0_autom_manual'.replace('\\','\\\\')  +  2*os.sep
##base  =  (os.sep.join(os.path.normpath(base).split(os.path.sep)  +  list(os.sep))).decoce(unicode-escape)
##base  = os.path.normpath(r'C:\Users\galr\Desktop\pacienti_rozpracovani\G318_patient62_bodyPart2_visit0_autom_manual')  +  os.sep 
meas_info_filename = "measurement_info" # series numbers and VENCs
sampling_percent = 100 # sometimes probably due to memory reasons only low values (e.g. 17) are possible 
beginning_only = 0
@@ -283,7 +286,7 @@ if beginning_only == 0:
                            slice1.UpdatePipeline()
                            calculator3.UpdatePipeline()
                            #calculator4.UpdatePipeline() #may be omitted, same result
                            if  automFlag  ==  1:
                            
                            flux_var = paraview.servermanager.Fetch(integrateVariables1)
                            #print(type(flux_var.GetCellData().GetArray('projected_vectors')))
                            #print(points[i])
@@ -295,7 +298,7 @@ if beginning_only == 0:
                                next_flux = (np.array(flux_var.GetCellData().GetArray('projected_vectors')))
                                flux[i] = next_flux    

                    if  automFlag  ==  1:
                    
                    np.save(os.sep.join([base,'flux_sampPerc' + str(sampling_percent),'flux' + str(tt) + '.npy']),flux)   

    if  automFlag  ==  0:
@@ -425,7 +428,7 @@ output.PointData.append(vtk_arrc, "Coords")

        # load the correct time step data
        from vtk.numpy_interface import dataset_adapter as da
        base_inner = '""" + base + """' #with r'' it doubles every backslash
        base_inner = '""" + base + """'  +  os.sep #with r'' it doubles every backslash
        base_mesh = base_inner #+ r'mesh'
        input0 = inputs[0]
        ##dataArray = input0.Points[:,0:3]
@@ -481,9 +484,28 @@ output.PointData.append(vtk_arrc, "Coords")
    fluxPWF.RescaleTransferFunction(-globMax, globMax)
    # change representation type
    programmableFilter2Display.SetRepresentationType('Points')

    # Properties modified on progFilterLoadFluxDisplay  
    programmableFilter2Display.PointSize = 1.0
    programmableFilter2Display.PointSize = 8.0

    ##########
    # set scalar coloring  for  Section ID
    ColorBy(programmableFilter2Display, ('POINTS', 'SectionID'))
    # Hide the scalar bar for this color map if no visible data is colored by it.
    HideScalarBarIfNotNeeded(fluxLUT, renderView1)
    # rescale color and/or opacity maps used to include current data range
    programmableFilter2Display.RescaleTransferFunctionToDataRange(True, False)
    # show color bar/color legend
    programmableFilter2Display.SetScalarBarVisibility(renderView1, True)
    # get color transfer function/color map for 'SectionID'
    sectionIDLUT = GetColorTransferFunction('SectionID')
    # get opacity transfer function/opacity map for 'SectionID'
    sectionIDPWF = GetOpacityTransferFunction('SectionID')
    # Properties modified on progFilterLoadFluxDisplay
    programmableFilter2Display.Opacity = 0.05
    # Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
    sectionIDLUT.ApplyPreset('Viridis (matplotlib)', True)
    # Properties modified on progFilterLoadFluxDisplay
    programmableFilter2Display.PointSize = 10.0

    # split cell to create Python View 
    layout1 = GetLayout(view = renderView1)
@@ -609,12 +631,15 @@ def render(view, width, height):


    # create a new 'Stream Tracer'
    try:
        streamTracer1 = StreamTracer(Input=calculator2,        
            SeedType='High Resolution Line Source')
    except:
        streamTracer1 = StreamTracer(Input=calculator2,
            SeedType='Line')
    streamTracer1.Vectors = ['POINTS', 'masked_velocity']
    streamTracer1.MaximumStreamlineLength = 500.0
    streamTracer1.SeedType.Point2 = points[indices[split_index]]
    streamTracer1.SeedType = 'Point Source'
    try:
            streamTracer1.SeedType = 'Point Cloud'
    except Exception:
@@ -671,6 +696,10 @@ def render(view, width, height):

    



    
   
RenameSource('4DFlowData1', xMLImageDataReader1)
RenameSource('4DFlowData2', xMLImageDataReader2)
RenameSource('4DFlowData3', xMLImageDataReader3)
@@ -694,7 +723,7 @@ renderView1.ResetCamera()
## uncomment the following to render all views
RenderAllViews()
## alternatively, if you want to write images, you can use SaveScreenshot(...).
print('Select points on the centerline (hit the "Select Points On" button or the "d" key) and type "updateFlow()" to Python Shell in order to plot flow rate in time.')
print('Select points on the centerline (hit the "Select Points On" button or the "d" key) and hit "FlowInTime" button in order to plot flow rate in time.')