This is an archival dump of old wiki content --- see scipy.org for current material

This page is outdated, the instructions provided here for grabbing and building will not work. Please see the reference wiki page: https://svn.enthought.com/enthought/wiki/MayaVi and the user guide: http://code.enthought.com/projects/mayavi/docs/development/html/

MayaVi2

MayaVi2 is the successor of MayaVi for 3D visualization.

Get and build

Most authorative instructions are here http://www.enthought.com/enthought/wiki/GrabbingAndBuilding

For the impatient:

svn co http://svn.enthought.com/svn/enthought/trunk enthought
cd enthought/src/lib/
ENTHOME=$PWD

Note that this imports the whole enthought tree - which is pretty big, around 260MB because of all the subversion info.

Optional: Before the build you can do the folllowing to skip some packages:

cd $ENTHOME/enthought/
$EDITOR setup.py &

#  comment out the following
ext_modules = [#"kiva/agg/setup_agg.py",
               #"freetype/setup_freetype.py",
               #"interpolate/setup_interpolate.py",
               "util/setup_util.py",
               "traits/setup_traits.py",
               "tvtk/setup_tvtk.py",
               #"chaco/setup_chaco.py"
              ]

Build with:

cd $ENTHOME/enthought/
python setup.py build_src build_clib build_ext --inplace

which does not take very long.

Running MayaVi2

Extend your python path (assuming bash shell syntax):

export PYTHONPATH=$ENTHOME:$PYTHONPATH

To start:

cd $ENTHOME/enthought/mayavi/scripts/
./mayavi2

Examples are under:

cd $ENTHOME/enthought/mayavi/examples
python nongui.py
python numeric_source.py

tvtk examples

tvtk stands for traited VTK and provides the whole basis for MayaVi2's visualization, see http://www.enthought.com/enthought/wiki/TVTK and the excellent tvtk introduction for more details.

Examples:

cd  $ENTHOME/enthought/tvtk/examples
python simple.py
python array_animation.py
python ivtk_example.py

In particular, have a look at mlab.py:

cd  $ENTHOME/enthought/tvtk/tools
python mlab.py

(note that this example has a large number of polygons, so it might feel sluggish on slower machines).

A simple example to visualize some function

   1 from enthought.tvtk.tools import mlab
   2 from Numeric import arange, cos, sqrt
   3 
   4 gui = mlab.GUI()
   5 fig = mlab.figure()
   6 x = arange(-5.0, 5.0, 0.2)
   7 y = arange(-5.0, 5.0, 0.2)
   8 
   9 def fct(x, y):
  10     return cos( sqrt(x**2+y**2))
  11 
  12 s = mlab.SurfRegular(x, y , fct)
  13 fig.add(s)
  14 gui.start_event_loop()
simple_tvtk_surface.py

(why the heck does this simple_tvtk_surface.py appear after the code block???)

Remarks:

Installation when both wxpython 2.4 and 2.6 are around

This seems obsoleted by now with the recent changes in enthought SVN

(I will keep them for a short while, because not all cases might have been covered yet ...)

If you run (e.g.) debian sarge and have both wxPython 2.4 and 2.6 installed you might need at the beginning of mayavi.py:

try:
    import wxversion
    wxversion.select("2.6")
except:
    print "WxPython version 2.6 not available!"
    import sys
    sys.exit(1)

And in addition:

$EDITOR $ENTHOME/enthought/pyface/__init__.py

# add this at the beginning:
import wxversion
wxversion.ensureMinimal("2.6")

and:

$EDITOR $ENTHOME/enthought/traits/ui/wx/toolkit.py

# add this at the beginning:
try:
    import wxversion
    wxversion.ensureMinimal("2.6")
except:
    pass

Note that the above might have changed - if you find problems, just update this text!

Reducing the number of files

The following subset should be enough (actually, there might be more which could go):

envisage
plugins
mayavi
core
io
logging
logger
naming
persistence
pyface
resource
traits
tvtk
util
naming
help

Surely the following can go:

cd src/lib/enthought
rm -rf chaco kiva wxchaco tkchaco
rm -rf freetype
rm -rf graph

Updating

Just do:

cd <path_to_enthought_directory>
svn update

(note that this will also re-create any deleted directories ...)

Creating patches

cd <path_to_enthought_directory>     # or change to mayavi dir (CHECK)
svn diff > svn_diff.diff

SciPy: ArndBaecker/MayaVi2 (last edited 2015-10-24 17:48:26 by anonymous)