In my day job as a PhD student, I do geological modeling. In my spare time (mainly for fun), I am learning Python and trying to write a simple program to view 3D geocellular models.
geological model http://img710.imageshack.us/img710/6503/sgems.png
The geocellular model is just a 3D grid where every grid cell has some value (as shown in the right figure). So, I would want my viewer to be able to display a 3D grid model like the picture on the right side. As well, I would like it to be able to display cross sections through the model in the x, y and z directions (this is shown in the left figure).
I would also want the models to be able to rotate around all three axes and zoom in and out.
I've done some preliminary investigation (mainly here) and it seems like VisVis and VTK are two potential options. I am trying to use wxPython for the main GUI and it looks like both options will work with wxPython as far as I can tell.
Questions:
Am I right when I say that I think VisVis and VTK would work for what I want? Is one preferable to the other?
Which of these two options would be the easiest to implement?
Is there another option that I also should consider?
Keep in mind that I'm newish to Python and very new to wxPython.
What you are looking for is called voxel visualization, voxel grid or such. I would seriously consider MayaVi (never used it, but I keep eye on it), it seems to have something very close here.
Paraview, built atop VTK just like MayaVi, might be a good option, too.
I think going straight to VTK for visualization is difficult, it is too low-level and will probably make you just frustrated. That said, you will want to save your data in as VTK datasets for opening in MayaVi/Paraview; it is not difficult, you just have to pick the right structure (vtkGrid, vtkUnstructedGrid, ...).
In my case, I chose to use directly the VTK bindings for Python. To be honest I found it simpler to get going with VTK than Mayavi, partly because the documentation is better (many many examples!). It felt like Mayavi was adding another layer of complexity on my way to get the job done. But tom10
is right. After you've started, using Mayavi may be easier.
Apart from that, Mayavi offers a library called TVTK which is a more pythonic version of the VTK bindings but in the end I chose plain VTK in order to minimize the number of dependencies. But you should check it out. Perhaps it will be just what you are searching for.
At the beginning I found very helpful this tutorial. It is not about Python, it is about tcl, but translating the examples is trivial and it helps you understand the way vtk works.
Also, in order to get you started, you can check the examples at the VTK Wiki. If they are not enough, you can always check the C++ examples and translate them to Python. The translation is not difficult as the names of methods and properties are the same. If you do, you are encouraged to add the examples at the wiki. There are even more examples in the source.
While you are learning VTK, you will (re)discover that Ipython is awesome! Having the whole VTK namespace at your fingertips helps enormously.
In case you need more specific help, the vtk-users mailing list is quite active. Lastly there are books about VTK, and some of them are free!They are not about Python though.
I haven't tried wxPython and VTK together, but that is because I prefer PyQt4 over wxPython. AFAIK there are no problems with the integration of VTK with either library. In any case, before spending time writing a GUI, check out thoroughly ParaView. It probably already does what you want, and if it doesn't, it is python scriptable too! (I've never checked it though).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With