[Paraview] Scripting and new VTK objects

pat marion pat.marion at kitware.com
Wed Feb 9 16:55:05 EST 2011


Hi Tim,

Have you looked at the python programmable source?  With the python
programmable source you can specify python code to run on the server side.
You won't be able to use paraview python api though.  Instead of

XDMFReader(FileName=...)

it would look like:

reader = vtkXDMFReader()
reader.SetFileName(...)
reader.Update()
data = reader.GetOutput()

You can find examples of the python programmable source:

http://www.paraview.org/Wiki/Python_Programmable_Filter#Generating_Data_.28Programmable_Source.29
http://www.paraview.org/Wiki/Here_are_some_more_examples_of_simple_ParaView_3_python_filters
.

Pat

On Wed, Feb 9, 2011 at 4:20 PM, Tim Gallagher <tim.gallagher at gatech.edu>wrote:

> Hi,
>
> I've searched online at length for this and couldn't find the answer, so
> hopefully somebody here can help me.
>
> I am trying to create a new VTK object (vtkMultiBlockDataSet) composed of
> portions of manipulated data from some other VTK object (in this case, a
> vtkStructuredGrid). I then want to delete the vtkStructuredGrid object and
> visualize the new vtkMultiBlockDataSet.
>
> So, here's the general outline of what I do in a python script:
>
> newSource = DataGeneratorObject(Program="MB{}")
> newSource.UpdatePipeline()
>
> newData = servermanager.Fetch(newSource)
> newData.SetNumberOfBlocks(64)
>
> for n in range(0,64):
>    myData = XDMFReader(FileName=...)
>    myData.UpdatePipeline()
>
>    localData = servermanager.Fetch(myData)
>
>    <manipulate the data>
>
>    newData.SetBlock(n,vtk.vtkStructuredGrid())
>    newData.GetBlock(n).DeepCopy(localData)
>
>    Delete(localData)
>    Delete(myData)
>
> newData.DataHasBeenGenerated()
> newSource.UpdatePipelineInformation()
> newSource.UpdatePipeline()
>
> With all that done, if I try to apply a filter to newSource, it doesn't
> work. The data is definitely inside newData -- I can print it out and such,
> even after I delete the localData (which is why I used DeepCopy).
>
> But I don't know how to send that data back to the server. Or, maybe I
> don't need the DataObjectGenerator -- if that's the case, how do I create a
> local VTK object and then send it to the server to visualize?
>
> Hopefully that example is clear... I appreciate any help you guys can
> provide. It would be easiest if I could create my own custom reader, but I
> can't do that because we use Paraview on a lot of machines that we can't
> recompile to include the new plugin.
>
> Thanks,
>
> Tim
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20110209/e0279288/attachment-0001.htm>


More information about the ParaView mailing list