Kitware / paraviewweb

Web framework for building interactive visualization relying on VTK or ParaView to produce visualization data
http://kitware.github.io/paraviewweb/
BSD 3-Clause "New" or "Revised" License
163 stars 51 forks source link

VTK vs. PV rendering for web? #317

Closed clavicule closed 7 years ago

clavicule commented 7 years ago

Hello and Happy New Year!

I just started to tour ParaviewWeb, VTK, Visualizer and Light-Viz as well as its documentation so I apologize in advance if my question sounds stupid.

Here is a bit of background for you to understand where my question is coming from

(feel free to skip to here is the real question section below) I got to a point where I can render a display in the web browser Visualizer from a PV server (which happen to be both on my local machine for now). I followed the documented steps on Apache Front End + Python Launcher and everything seems to work just fine:

In the meantime, I was successfully playing with the VTK remote rendering example (e.g. the Webcone one), so I figured, well I just need to add an app to my launcher.config and plug it to Visualizer. Of course that didn't work for many good reasons and I'll probably need to get my head around between the client connection and the server (the example hardcodes that connection). But one thing stroke me:

here is now the real question :)

Should we be using VTK or PV server? From what I understood and figured out on my own (please correct me if I am wrong):

I am going to start developing a small custom web viewer app that will deal with custom data format, so I am preparing and welcoming any recommendations/opinions before I do.

Thanks a lot and apologies for this long block of text. cheers claude

jourdain commented 7 years ago

Hello Claude,

I'm glad you managed to do quite a lot on your own.

Let me try to answer you questions:

PV allows for parallelization (using mpirun on pvserver): how would that fit in this launcher example? Could we do it with VTK too?

The command line for ParaView with be something along those lines:

"cmd": [
     "mpirun",  [...],  "${pvbatch_exec}", "./server/pvw-visualizer.py",
      "--port", "${port}", "-f", "--authKey", "${secret}"
      "--data", "/path/to/data/dir", "--load-file", "${data}"
]

But you will need an extra environment variable (PV_ALLOW_BATCH_INTERACTION=1) and ParaView/master or 5.3 which is not out yet.

For VTK, that's another story you will be missing all the MPI controller infrastructure initialization which is given with ParaView. So it is still possible but much more cumbersome.

To my understanding there is no out-of-the-box equivalent of Visualizer for VTK, is this correct?

Correct, that will mean rewriting ParaView without the MPI capability since ParaView is based on VTK.

VTK Python devkit seems more flexible and give more capabilities on graphic manipulation than PV python devkit (I also have hard time reading python doc in general and no problem with C++ so this opinion could be biased on the fact I didn't find what I was looking for)

Maybe, but you will have to write a lot of code while in ParaView it is more likely that piece already exist and the deal is to figure out how to do it.

For example, if you look at the server side of the cone example for VTKWeb here would be the ParaView side of it.

simple.Cone()
simple.Show()
simple.Render()

vs

        if not _WebCone.view:
            # VTK specific code
            renderer = vtk.vtkRenderer()
            renderWindow = vtk.vtkRenderWindow()
            renderWindow.AddRenderer(renderer)
            renderWindowInteractor = vtk.vtkRenderWindowInteractor()
            renderWindowInteractor.SetRenderWindow(renderWindow)
            renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()
            cone = vtk.vtkConeSource()
            mapper = vtk.vtkPolyDataMapper()
            actor = vtk.vtkActor()
            mapper.SetInputConnection(cone.GetOutputPort())
            actor.SetMapper(mapper)
            renderer.AddActor(actor)
            renderer.ResetCamera()
            renderWindow.Render()
            # VTK Web application specific
            _WebCone.view = renderWindow
            self.Application.GetObjectIdMap().SetActiveObject("VIEW", renderWindow)

Much much smaller...

On the other hand, PV seems more rich in terms of Protocols than VTK which allows more interactions/capabilities on the client side.

Yes we base all our code on ParaView hence that's the one that get all the work...

It looks like VTK and PV offer lots of things in common: are there any plan to discontinue one or the other? If so, are the strengths of one ported to the other one?

Not really, ParaView rely on VTK for everything and add the distribution and parallelism infrastructure. It is even possible to write pure VTK python code within a ParaViewWeb application.

The hard part is to understand the proxy abstraction that ParaView brings. Otherwise, everything is VTK.

Moreover, VTK is a library while ParaView is an application+framework+library.

I hope that give you some ideas on what to do. But I would definitely use ParaView and maybe create some programmable source to load your custom data. And if you want to do some C++, just create a plugin for ParaView (pure VTK code) to load your data and then you will be all set.

And thanks for your kind words...

jourdain commented 7 years ago

BTW, for the example you followed for vtkWeb to work with the launcher you just need to edit the line

const config = { sessionURL: 'ws://localhost:1234/ws' };

And replace it by:

const config = { application: 'NameOfYourAppInYourLauncherConfig' };

clavicule commented 7 years ago

Hello Sebastien!

Thank you very much for your quick reply and the detailed explanations, it makes things a lot clearer (my brain is starting to make the right connection now)!

For some reasons I was picturing VTK and ParaView as 2 "parallel branches", I was definitely wrong on that one. Based on the invaluable information you provided it indeed looks like I should stick with ParaView framework (and optionally write a plugin for I/O), especially if future plans include using mpi for rendering big datasets. I will also need to get a closer look at paraview.simple I must have missed a lot to think it didn't give as much capabilities as lower level VTK code.

It's true the proxy abstraction is not easy to grasp, I am not fully sure I understood everything but it will come with playing more with it for sure.

Well, the kind words are the least I can tell you, your work is just brilliant and the results are incredible. Thank you a lot!

jourdain commented 7 years ago

Glad to help... ;-)

clavicule commented 7 years ago

FYI - it is indeed as simple as const config = { application: 'my_app' }; it makes so much sense, I can't believed I missed that. Still learning :)

As for the VTK webcone code in Paraview (somehow I missed the VTK code snippet the first time I read your answer), it's hard to beat 3 lines of code. For some reason the VTK code is still more clear to me and I want to dig into Cone() and Show(), something is wrong with me for sure :)

Thanks a lot! cheers