

Add the actor to the renderer and set the camera based on itĬonst renderWindow = .newInstance() Ĭonst renderer = .newInstance() tInputConnection(writerReader.getOutputPort()) Ĭonst actor = .newInstance() WriterReader.parseAsArrayBuffer(textEncoder.encode(data))Ĭonst mapper = .newInstance()

This is the javascript function invoked when the xml is returned: // Callback function for when request completes The_cell = np.insert(the_cell, 0, len(points)) The_cell = np.arange(0, len(points), dtype=np.int_) The blue entire polyline is blue and not as the example I am trying to render, I am not sure if it is an error in the encoding of the xml or the mapping of the scalar values to colors? # Example python server side info using pyvista to generate the vtk file and color scalars The java script side loads the geometry information correctly, however does not display the scalar color information as expected. Great - many thanks for this… I had a go and managed to send the xml and render the image… I created a super simple polyline file with some scalar colors to send as the “polydata_xml” file. If you have any advice on this as a route would greatly appreciate it. I had a look at panel, however it didn’t allow me to readily customise callbacks such as point or cell picker functions which would be required for my web app. Perhaps the best solution is to send the calculated geometry and color scalar data (i.e xyz coords, cell connectivity and color scalar values for the nodes) from the server side back as JSON to the JavaScript on the client side which loops through the raw data generating the plot?


The plot I am trying to achieve is a mesh, however the color scalar values are calculated based on the input on the client web side. I also want to use vtk.js because it has useful cell and point picker which I want to integrate as a feature in my plots. Ultimately I’m try to generate a web app that takes a user input runs a calculation on the server side, and then plots the vtk render of the results in my website. Thanks Sebastien… realised I may be attempting the impossible / hitting my head against a brick wall.
Python write json to file synchronization how to#
Then update the actor in my website with Javascript, however not completely sure how to achieve this.Īny help on this would be much appreciated - struggling to find any examples of the server side needed to send to the client. tInputConnection(reader.getOutputPort()) not pass the json_object to the readerĬonst reader = vtkHttpDataSetReader.newInstance(json_object)
Python write json to file synchronization code#
On the Client side the following pseudo code # Receive JSON object from server side. # Return the JSON object to the javascript VtkDcmWriter = vtk.vtkJSONDataSetWriter() # Not sure how to use the function below to write to a JSON object # Add scalar array with range (0, 100) that correlates with elevation Mesh = examples.download_st_helens().warp_by_scalar() in this simple example I just include a stock example # Request comes from the client website via AJAX request, then new geometry is calculated. A pseudo example below: # Pseudo code on the python web server On the python side I generate some geometry using Pyvista as this is convenient wrapper for generating the coloured mesh, however I am not sure how to translate this into a JSON object to send back to website. I would like to send the updated geometry using JSON via the following process “vtkJSONDataSetWriter”. I am running a python web-server which is calculating the new geometry of a model to then send back to the website visualiser using vtk.js to visualise the information.
