Rendering custom C++ objects

I am looking for recommandations about your several web technologies.

I have C++ objets with their own data structures (polygonal surfaces and unstructured grids) that I would like to display in a web or electron application using Vue.js. From what I understood, I have two possibilities:

  • Copy the data to VTK.js PolyData and render directly in JS

  • Use vtkMappedUnstructuredGrid (assuming both surfaces and grid can be mapped) and render using a ParaViewWeb like app

The first option is similar to ParaviewGlance and I managed to make it works.
However for large dataset, the second option seems better to avoir the data copy but I am not sure where to start and if such workflow is possible. In this case, rendering could be local for electron app and remote for web app.

Thanks for your help

Hi Arnaud,

All your assumptions are correct. For the ParaViewWeb app, did you look at “ParaView Visualizer”? It might be too complex for tuning its UI but it could provide an out-of-the-box type of application that might work with what you are looking for (at least as a first step).

We even provide an Electron app that expect a version of ParaView to be installed as the Electron app is actually only an empty shell with just the proper command line to start the ParaViewWeb app and open the embedded browser.

Since you are posting on the VTK discourse, you are probably more interested in the VTK backend than the ParaView one. In either case, you might want to look at the following set of examples I’ve made a while back.

Adding this link as it also provide some good background on our web technologies.

Some image streaming examples:

Hi Sebastien,

Thanks a lot for all your links. I will look deeply into them. From what I read, I will go to a Paraviewweb data processing + rendering.

If you would like to add a custom vtkMappedUnstructuredGrid to Paraview, I am guessing I need to first develop a Paraview plugin with my data structure and then run Paraview + the plugin on the server? Is there an example of that?

Moreover, how to run a specific data processing that I would have implemented in the plugin from the front-end?

In any case, you don’t really need a ParaView on the server side, you can stick to VTK if you prefer. Otherwise, with PV, you will indeed need to create a plugin if you want to have some custom C++ code.

And for calling some specific processing pipeline, you can look at the pvw template example as it illustrate how the client make a network call to the python which then call the c++ to adjust the cone resolution.

Ok, to sum up my initial question of rendering a custom C++ object: I will use a VTK server that can be called from the front-end using the wslink. To use my custom data structure, I will need to implement a vtkMappedUnstructuredGrid in C++ and then generate a python wrapper to be able to use it from the wslink to define its protocols.

If it is correct, do you have a recommandation on the python wrapper to use? pybind11 appears to be often used by C++ peoples but VTK seems to use a custom wrapping project.

VTK should provide you the wrapping code you need as long as your c++ code integrate with VTK.

I looked in more detail at VTK python wrapper and according the documentation:

A method is not wrapped if:

  1. its parameter list contains a pointer to anything other than a vtkObjectBase-derived object or a fundamental C++ type (void, char, int, unsigned short, double, etc.)
  2. it returns a pointer to anything other than a vtkObjectBase-derived object, unless the method returns a pointer to a fundamental C++ type and has an entry in the wrapping hints file, or the method is a vtkDataArray Get() method, or the returned type is ‘char *’ or ‘void *’
  3. it is an operator method (though many exceptions exist)

However, from the example of vtkMappedUnstructuredGrid in the documentation:

class MyGridImplementation : public vtkObject
… (vtkObject required API) …
… (vtkMappedUnstructuredGrid Implementation required API) …
void SetImplementationDetails(…raw data from external source…);

vtkMakeMappedUnstructuredGrid(MyGrid, MyGridImplementation)

So, according the point 1. from the wrapper documentation, the method MyGridImplementation::SetImplementationDetails(...) cannot be wrapped using VTK wrapper because the raw data from external source is not derived from vtkObjectBase.
Then, how do you use an external storage and a remote rendering?

I’m not sure to see what you mean by external storage or remote rendering.

The remote rendering will be part of ParaView/VTK Web, I guess?

The idea is to have a VTKWeb application and to render a custom C++ object on the server side using a vtkMappedUnstructuredGrid.

The question is how to set the custom C++ object on the server, how to call SetImplementationDetails?

Create a C++ implementation of the code that call SetImplementationDetails internally and make sure that vtkObject is wrappable.