ParaViewWeb Visualizer

I Created project with visualizer to show vtk file.
I want show also some points on the screen, I want the round and focus of vtk will be effect also the points.
What the best way to do it?

Is your Visualizer working?

What kind of points, round and focus are you talking about?

Yes, my visualizer working.
The points will be shown on the drawing, but the point data is x,y,z format and the drawing data is vtk file.

Create a vtkPolyData from those x,y,z and use the trivial producer to bring it into the ParaView pipeline.

How to to bring it into the ParaView pipeline?

from vtkmodules.vtkCommonDataModel import vtkPolyData, vtkCellArray
from vtkmodules.vtkCommonCore import vtkPoints, vtkFloatArray

from paraview import simple

polyData = vtkPolyData()


points = polyData.GetPoints()
lines = polyData.GetLines()

points.InsertNextPoint(0, 1, 0) # id: 0
points.InsertNextPoint(0, 2, 0) # id: 1
points.InsertNextPoint(0, 3, 0) # id: 2
points.InsertNextPoint(0, 4, 0) # id: 3
points.InsertNextPoint(0, 5, 0) # id: 4


trivialProducer = simple.TrivialProducer()



Thank you very much for this example. It’s very usefull.
Do you may to provide similar example, but with spheres. (With radius 1)
Thank you very much and best regards, Igor.

from paraview import simple

sphere = simple.Sphere()
sphere.Radius = 1


Thank you very much!

Hello Sebastien,

Thank you very much about your previous answer.
I’m newest in ParaView/Web applications.
Provided examples demonstrate how to create models in python.
But not understandable how(or where) I load to Visualizer this code.
In my task I need:

  1. Load vtk file
  2. Load txt file with spheres position information
  3. Add spheres (by code) to loaded vtk model
  4. Display to user result scene

Is possible to provide more detailed information (step by step) for this task?
Positions of new files. How to attach and call these files to html page?
Thank you Very much.

I’m not sure it is a Visualizer question. It seems that you are trying to build a custom application based on the ParaViewWeb framework. ParaView Visualizer, ParaView Lite, ParaView Divvy are good examples on how to use such framework to do different things.

For custom development or guidance, Kitware offer support contract which allow us to take the time to explain or develop custom code for you.

Hi @jourdain,
I success to show a sphere with your code,
But when I add it, the sphere fills the whole screen.
How can I fire ResetCamera() function from my .py file?

Thanks in advance.


It does not work.

And also -
How can I define a color to each sphere?
I think it called DiffuseColor.

Thanks in advance.

It does work for everyone else. So maybe it is something that you are telling us?

To have unique color per sphere, assuming you have one representation per sphere you can set the representation.DiffuseColor = [0.5, 1, 0.2] on their representations.

This is my code:

for item in array:
sphere = simple.Sphere()
sphere.Radius = 1
sphere.Center = [float(item[0]), float(item[1]), float(item[2])]

How can I add one representation per sphere?

This is a bad idea and you should use Glyph filter or better the Glyph mapper.

But since you ask, here is an answer.

spheres = []
reps = []
for item in array:
  sphere = simple.Sphere(Radius=1, Center=[float(item[0]), float(item[1]), float(item[2])])
  rep = simple.Show(sphere)

1 Like

Seconded. You will be outraged at how slow this will be. Objects in ParaView are heavy weight, and creating more than a couple dozen will result in unhappy results.

Now it works, thanks!
I have another question - it seems that some of the points are displayed below the vtk object.
Can I give the sphere a ‘Z-Index’ property?

I don’t understand what you mean.