So, I want to render a density isosurface of my realtime sph code. Paul Bourke has some marching cubes code available, but it states that it is not optimised. To run the code here you need GLUT, which can be set up on OSX with these instructions.
An attractive alternative is to use VTK’s python bindings. I found
http://www.macresearch.org/installing_vtk_on_mac_os_x quite helpful. Also see
VTK itself looks a bit involved. Mayavi promises to be easier to use. But possibly not efficient enough..
VTK was a moderate amount of work to build. CMake.Cache.txt needed the following changes (rerun cmake after the changes to propagate them to the build scripts):
VTK_USE_RPATH=ON (This ensures the mayavi and tvtk installers find the libraries)
Actually all the documentation says to have carbon on and cocoa off, but I want to try some of the tutorials drew mccormack has written for using vtk with cocoa.
The Mayavi install didn’t like this, so I am trying the carbon build (rebuilding everything…). I will need to do a couple of builds in the event I decide to try my hand at cocoa, but I doubt it.
The last crucial step in setting up vtk is to go into Wrapping/Python and run setup.py install to get in in the right spot.
rom the mayvi svn wiki:
make install. By default, everything will go into /usr/local even the Python libraries. They won’t be found there, so I then go to the build/Wrapping/Python/ directory and do a standard python setup.py install to put the Python package in the right place.
Mayavi was too hard to install alone, so I am now trying to install the whole enthought toolkit. I get a sandbox violation every second or third attempt. Turns out this is because Pyrex needs to save a lexicon the first time it is run, and it can’t do this in the easy_install sandbox. (thanks to Robert Kern at https://svn.enthought.com/enthought/ticket/1449). Giving up. Can’t get Kiva to recognise the wx library.
Back to using VTK directly, which is probably the fastest solution at any rate, and doesn’t trap me under a mountain of dependencies.
So it’s proving hard to find a simple example of how to take a numpy array, feed it to vtk and get a 3d isosurface plot. I don’t know if this is because most people use the c++ interface directly, or work from file data, or what. This page seems helpful http://www.imaging.robarts.ca/~dgobbi/vtk/vtkpython.html
Time to pick an approach and implement. A full day’s work compiling stuff and not much concrete to show for it. Well, a working vtk is concrete, except that I don’t know how to use it yet. And it’s not even clear that marching cubes is the best implementation.