|
[Sponsors] |
[General] “Upload” vtk data from client to server in paraview script |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 8, 2018, 08:27 |
“Upload” vtk data from client to server in paraview script
|
#1 |
Member
Jack
Join Date: May 2015
Posts: 98
Rep Power: 11 |
I am relatively new to scripting in paraview using vtk wrappers. However one situation I always find myself in is writing a python script to be executed with pvpython and then having to include a miniature python script as an input to programmableFilters. As far as I understand, this allows the manipulation of pipeline data on the server side (so you don't have to retrieve data to the client) inside a tailored script. What I don't understand is why the process has to be so convoluted. At the very least it makes debugging very annoying as you don't know exactly where in the script that you input into the programmable filter a potential error might be. I have an example to illustrate.
Below are two pieces of code within an if/else switch where I add some temperature data to a vtkSphereSource. The first uses the programmableFilter approach and the second attempts to do the manipulation on the client side and then "upload/update" the server side. However the second approach does not result in any temperature data when I view it in paraview. What am I missing? Code:
from paraview.simple import * paraview.simple._DisableFirstRenderCameraReset() import math import vtk use_prog_filt = False # What I dont want to be doing: if use_prog_filt: sphereSourceProxy = Sphere() renderView1 = GetActiveViewOrCreate('RenderView') sphereDisplay = Show(sphereSourceProxy, renderView1) sphereDisplay.ColorArrayName = [None, ''] renderView1.ResetCamera() my_script= [ 'pdi = self.GetPolyDataInput()', 'pdo = self.GetPolyDataOutput()', '', 'temperature= vtk.vtkDoubleArray()', 'npoints = pdi.GetNumberOfPoints() ', 'for i in range(npoints):', ' x, y, z = pdi.GetPoint(i)', ' temperature.InsertNextValue(x)', 'temperature.SetName("Temperature")', 'pdo.GetPointData().AddArray(temperature)'] programmableFilter = ProgrammableFilter(Input=sphereSourceProxy) programmableFilter.Script = str("\n".join(my_script)) programmableFilter.RequestInformationScript = '' programmableFilter.RequestUpdateExtentScript = '' programmableFilter.PythonPath = '' programmableFilterDisplay = Show(programmableFilter, renderView1) # What I want to be doing: else: #sphereSource = vtk.vtkSphereSource() #print dir(sphereSource) sphereSourceProxy = Sphere() renderView1 = GetActiveViewOrCreate('RenderView') sphereDisplay = Show(sphereSourceProxy, renderView1) sphereDisplay.ColorArrayName = [None, ''] renderView1.ResetCamera() pdi = servermanager.Fetch(input=sphereSourceProxy) npoints = pdi.GetNumberOfPoints() temperature = vtk.vtkDoubleArray() temperature.SetName("Temperature") for i in range(npoints): x, y, z = pdi.GetPoint(i) temperature.InsertNextValue(x) pdi.GetPointData().AddArray(temperature) new_SphereSource = TrivialProducer() filt = new_SphereSource.GetClientSideObject() # filter is a vtkTrivialProducer filt.SetOutput(pdi) new_SphereSource.UpdatePipeline() # The temperature data is available, but not in the paraview renderview... print servermanager.Fetch(input=new_SphereSource) |
|
Tags |
paraview, servermanager variables, vtk |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[General] How to relate tensor data in vtk file to Paraview | awa5114 | ParaView | 0 | March 7, 2017 05:56 |
[General] How can I use python script to generate animation from 2000 frames of vtk datasets | LieyuShi | ParaView | 3 | March 10, 2016 14:37 |
[OpenFOAM] saving data in paraview | aylalisa | ParaView | 3 | May 31, 2014 12:38 |
studying a valve case | mina.basta | OpenFOAM | 33 | August 30, 2013 05:46 |
[General] paraview ignores SPACING in STRUCTURED_POINTS vtk data? | jaffar | ParaView | 0 | November 27, 2012 10:36 |