Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON with polydata #928

Closed
yh3ds opened this issue Oct 25, 2018 · 2 comments
Closed

JSON with polydata #928

yh3ds opened this issue Oct 25, 2018 · 2 comments

Comments

@yh3ds
Copy link

yh3ds commented Oct 25, 2018

Hello,
would it be possible to create a JSON containing a Polydata on backend server (running vtk through a Python script) and send it to vtk-js directly (using a json.dumps on server side) ?

When trying ot use it, I get this response : Object of type 'vtkPolyData' is not JSON serializable

Thanks a lot

@jourdain
Copy link
Collaborator

They are several way to do that. JSON is obviously one but not necessary the best one.

A better one could be using the vtp format to send a single binary blob over the network and use the XMLPolyDataReader on the vtk.js side.

If you use VTK and Python, you can use a synchronization mechanism that we rely on inside ParaView Visualizer to do local rendering. In that set up we inspect a RenderWindow and extract each actor geometry. We provide a scene descriptor in a JSON format and then the client request the various bits of arrays (coordinates, cells, fields) as binary blob. But this imply a more complex and connected relationship between the server and the client.

If JSON is your way to go, you can create a JSON format in Python that can be understand by vtk.js like described here.
Just provide a normal JSON array in the values field. When used with the vtk() function on the client side, such JSON will be converted to a vtkPolyData instance.

@yh3ds
Copy link
Author

yh3ds commented Oct 29, 2018

Thank you very much.

Have a nice day

@yh3ds yh3ds closed this as completed Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants