paraview.simple vs vtk when writing web backend

Hi,

I’m trying to teach myself combining paraview server + browser frontend. I’m following the example in

and I don’t understand what paraview.simple provides over raw vtk methods. I see that simple functions are indeed simple, but it’s largely undocumented, and I’m especially having trouble how to map vtk concepts to simple.* functions. For example:

As I understand, simple.Cone() creates a vtkConeSource internally and wraps it in a python object, what kind of wrapping is happening? E.g., what’s the equivalent of GetOutputPort()? If you can point me to either python or c++ source code that does wrapping, I’d really appreciate it.

How can we chain filters, like we do in vtk SetInputConnection. I see that simple exposes many filters (clip, slice, …) but I can’t find examples of using them.

Is it possible to mix vtk.* functions and simple* methods in a server? For example, can I use vtk.vtkConeSource() and show it with simple.Show() (it didn’t work, but I wonder if I’m missing some wrapping).

Cone()
Clip()
Show()
Render()

This is all you need to do to show a clipped cone with paraview.simple.

The documentation is here : https://kitware.github.io/paraview-docs/latest/python/paraview.simple.html

Thanks. I’m aware of the documentation page. But it’s missing the dynamically generated classes, including Cone and Clip. help(simple.Clip()) gives me good information, but I still have difficulty telling which C++ code simple.Clip wraps, and which python method invokes which C++ method. For Clip, I’m guessing VTKExtensions/FiltersGeneral/Resources/general_filters.xml defines that mapping, but I’m stuck trying to parse the file. Is there any documentation for the format & the meaning of the XML definitions?

https://kitware.github.io/paraview-docs/latest/python/paraview.simple.Cone.html#paraview.simple.Cone
https://kitware.github.io/paraview-docs/latest/python/paraview.simple.Clip.html
https://kitware.github.io/paraview-docs/latest/python/paraview.servermanager_proxies.html

The big picture is that ParaView can be used in distributed which means that the actual vtkConeSource may not be local to the machine where you execute that code (simple.Cone()). Hence the proxy abstraction that hides that part to the user.

If you know that you are only working locally, you can indeed perform some VTK task on top of some Proxy object but that require a good knowledge of how things work internally.

To be more explicit on how the Pipeline get constructed you can do the following. This also allow you to rewire the pipeline dynamically.

view = Render()
cone = Cone()
clip = Clip(Input=cone)
clipRepresentation = Show(clip, view)
Render()
sphere = Sphere()
clip.Input = sphere
Render()
coneRep = Show(cone, view)
cone.Resolution = 12
Render()

conePolydata = cone.GetClientSideObject().GetOutput()
print(conePolydata)