[Paraview] Generating and displaying vtk data directly from the GUI shell tool

Berk Geveci berk.geveci at kitware.com
Fri Dec 5 17:32:09 EST 2008


Hi Louis,

Why not move the data generation inside a programmable source? That
would make things much easier and also work in client-server
environment.

-berk

On Thu, Nov 27, 2008 at 4:12 AM, Louis Le Grange
<llg at mtechindustrial.com> wrote:
> Hi
>
> I want to generate and display data in the paraview GUI, all from the python
> shell tool. The vtk data is not generated from a reader or from inside a
> programmable source, but directly inside the paraview GUI shell environment.
> I now want to connect the input of a filter to this polyData. Are there any
> interfacing functions to do this: Here is my example script in which the
> comments describe what I am trying to do.
>
> Thanks in advance,
> Louis
>
>
> # Here is the vtk data generated directly in the GUI python shell:
>
> import vtk
>
> pts=vtk.vtkPoints()
>
> pts.Initialize()
>
> pts.InsertNextPoint(0,0,0)
>
> pts.InsertNextPoint(1,0,.0)
>
> pts.InsertNextPoint(2,1,0)
>
> pts.InsertNextPoint(3,3,0.)
>
>
>
> cel=vtk.vtkCellArray()
>
> cel.Initialize()
>
> cel.InsertNextCell(4) # number of points
>
> cel.InsertCellPoint(0)
>
> cel.InsertCellPoint(1)
>
> cel.InsertCellPoint(2)
>
> cel.InsertCellPoint(3)
>
>
>
> pdata=vtk.vtkPolyData()
>
> pdata.SetPoints(pts)
>
> pdata.SetPolys(cel)
>
>
>
> # Here I am setting up a pipline and registering the proxies
>
> pxm=servermanager.ProxyManager()
>
>
>
> # Create our programmable filter and set its program ...
>
> #========================================================
>
> filter = servermanager.filters.ProgrammableFilter()
>
> filter.GetProperty("Script").SetElement(0, """
>
> input = self.GetInputDataObject(0, 0)
>
> output = self.GetOutputDataObject(0)
>
> output.DeepCopy(input)
>
> """)
>
>
>
> # Connect the polyData output to
>
> # the programmable filter input ...
>
>
>
> # Here is where I need a link between the filter and my polyData
>
> # The following obviously does not work...
>
>
>
> filter.Input = pData
>
> #filter.Input.SetData(polyData)
>
>
>
> pxm.RegisterProxy("sources", "my programmable filter", filter)
>
>
>
> view = pxm.GetProxy("views", "RenderView1")
>
> rep = servermanager.CreateRepresentation(filter, view)
>
> pxm.RegisterProxy("representations", "myrep1", rep)
>
>
>
>
>
>
>
>
>
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview
>
>


More information about the ParaView mailing list