Navigation

Mayavi uses VTK for all its visualization needs.
A pipeline concept underlies all the visualization in VTK. However,
it is important to note that the pipeline used by Mayavi does not
correspond to the VTK pipeline creating the visualization: the layout
is different, the objects are not the same, and there are more nodes
in a VTK pipeline. The two pipelines share some similarities, but in
this section, we are only concerned by the Mayavi pipeline.

Each object in the pipeline has a parent attribute that points to its
parent in the pipeline, as well as a children attribute, giving the
list of its children. The name attribute of the objects gives the name
of the node as it appears in the pipeline view. The edition dialog to
modify graphicaly the properties of an object can be displayed by calling
the edit_traits() method of this object.

In addition, Mayavi pipeline objects can only be in one scene, and their
.scene attribute point to this scene (see the
Volume slicer example for an example of how the data can be shared
between scenes).

Every visualization created in Mayavi is constructed with a pipeline,
although the construction of the pipeline may be hidden from the user:

The easiest way to make a Mayavi visualization is to create a pipeline
via the user interface, as, for instance, exposed in the
Parametric surfaces examples.

The mlab 3d plotting functions,
create full piplelines, comprising sources, modules, and possibly
filters, to visualize numpy arrays. Displaying the
pipeline view is the
easiest way to understand what pipeline was built.

Pipelines can also be built node-by-node with mlab, using the
mlab.pipeline functions.
The name of the functions to call can simply be deduced
from the names of the pipeline nodes as they appear in the pipeline
view.

The objects composing a pipeline can be instantiated and added to the
pipeline manually, as exposed
further below.

The mlab.plot3d function first creates a source made of points
connected by lines. Then it applies the Stripper filter, which
transforms this succession of lines in a ‘strip’. Second, a Tube
filter is applied: from the ‘strip’ it creates tubes with a given radius.
Finally, the Surface module is applied to display the surface of the
tubes. The surface object returned by the mlab.plot3d function is
that final Surface module.

Let us have a look at the data in the pipeline before the tube filter was
applied. First we retrive the Stripper filter:

stripper = surface.parent.parent.parent

Then we apply on it a Surface module to represent the strip:

lines = mlab.pipeline.surface(stripper, color=(0, 0, 0))

All the properties of the different steps can be adjusted in the pipeline
view. In addition, they correspond to attributes on the various objects:

The names in the dialogs of the various properties gives hints to which
attributes in the objects they correspond to. However, it can be fairly
challenging to find this correspondance. We suggest to use the
record feature for this purpose.