I
n this tutorial we introduce basic concepts
behind the Visualization Toolkit (VTK). An
overview of the system, plus some detailed examples,
will assist you in learning this system. The tutorial tar-
gets researchers of any discipline who have 2D or 3D
data and want more control over the visualization
process than a turn-key system can provide. It also
assists developers who would like to incorporate VTK
into an application as a visualization or data process-
ing engine. Although this tutorial can only provide an
introduction to this extensive toolkit, we’ve provided
references to additional material.
What is VTK?
VTK
1
is an open-source (see the sidebar “Open
Source Breakout”), portable (WinTel/Unix), object-ori-
ented software system for 3D computer graphics, visu-
alization, and image processing. Implemented in C++,
VTK also supports Tcl, Python, and Java language bind-
ings, permitting complex applications, rapid applica-
tion prototyping, and simple scripts. Although VTK
doesn’t provide any user interface components, it can be
integrated with existing widget sets such as Tk or
X/Motif.
VTK provides a variety of data representations includ-
ing unorganized point sets, polygonal data, images, vol-
umes, and structured, rectilinear, and unstructured
grids. VTK comes with readers/importers and writ-
ers/exporters to exchange data with other applications.
Hundreds of data processing filters are available to oper-
ate on these data, ranging from image convolution to
Delaunay triangulation. VTK’s rendering model sup-
ports 2D, polygonal, volumetric, and texture-based
approaches that can be used in any combination.
VTK is one of several visualization systems available
today. AVS
2
was one of the first commercial systems
available. IBM’s Data Explorer (DX),
3
originally a com-
mercial product, is now open source and known as
OpenDX. NAG Explorer
4
and Template Graphics Amira
(see http://www.tgs.com/Amira/index.html) are other
well-known commercial systems.
VTK is a general-purpose system used in a variety of
applications, as seen in Figure 1. Because VTK is open
source, faculty at many universities—including Rens-
selaer Polytechnic Institute, State University of New York
at Stony Brook, the Ohio State University, Stanford, and
Brigham and Women’s Hospital use VTK to teach cours-
es and as a research tool. National labs such as Los Alam-
os are adapting VTK to large-scale parallel processing.
Commercial firms are building proprietary applications
on top of the open-source foundation, including med-
ical visualization, volume visualization, oil exploration,
acoustics, fluid mechanics, finite element analysis, and
surface reconstruction from laser-digitized, unorga-
nized point-clouds.
VTK began in December 1993 as companion software
to the text The Visualization Toolkit: An Object-Oriented
Approach to 3D Graphics by Will Schroeder, Ken Martin,
and Bill Lorensen (Prentice Hall). In 1998 the second
edition of the text appeared, with additional authors
Lisa Avila, Rick Avila, and Charles Law. Since that time
a sizable community has grown up around the software,
including dozens of others as developers, often submit-
ting bug fixes or full-blown class implementations.
These community efforts have helped the software
evolve. For example, David Gobbi in the Imaging
Research Laboratories at the John P. Robarts Research
Institute, University of Western Ontario, has reworked
VTK’s transformation classes and is now an active
developer.
Architecture
VTK consists of two major pieces: a compiled core
(implemented in C++) and an automatically generated
interpreted layer. The interpreted layer currently sup-
ports Tcl, Java, and Python.
C++ core
Data structures, algorithms, and time-critical system
functions are implemented in the C++ core. Common
design patterns such as object factories and virtual func-
tions insure portability and extensibility. Since VTK is
independent of any graphical user interface (GUI), it
doesn’t depend on the windowing system. Hooks into
the window ID and event loop let developers plug VTK
into their own applications. An abstract graphics model
(described in the next section) achieves graphics
portability.
0272-1716/00/$10.00 © 2000 IEEE
Tutorial
20 September/October 2000
William J. Schroeder, Lisa S. Avila,
and William Hoffman
Kitware
Visualizing with
VTK: A Tutorial
Interpreted layer
While the compiled core provides speed and efficien-
cy, the interpreted layer offers flexibility and extensi-
bility. For example, using GUI prototyping tools such as
Tcl/Tk, Python/Tk, or Java AWT permits building pro-
fessional applications rapidly. These popular program-
ming languages come with other packages such as
Python’s numerical library NumPy.
We used Tcl in the examples in this article. You can type
in the example code included here and immediately see
the results. Follow the instructions found at http://www.
visualizationtoolkit.org/CGA/Instructions.htm to install
VTK and start a Tcl shell with VTK support.
The graphics model
VTK has two major subsystems—the graphics model
and visualization pipeline. The graphics model forms an
abstract layer above the graphics language (for example,
OpenGL) to insure cross-platform portability. When the
development of VTK began in 1993, each computer plat-
form had its own graphics language—XGL for Sun, Star-
base for Hewlett-Packard, and gl for Silicon Graphics.
Abstracting graphics concepts into a platform and device-
independent layer created the graphics model. Since that
time the industry has standardized on OpenGL. Although
this is now the only low-level graphics language sup-
ported in VTK, the abstract layer has not been abandoned.
In the future, new graphics languages are likely to become
popular and even replace OpenGL as a standard. Keep-
ing this abstract layer lets us update VTK with new tech-
nology without affecting backwards compatibility.
We adapted the names of the classes in the graphics
model from the movie-making industry. Lights, cam-
eras, actors, and props are classes that the user instan-
tiates to create a scene. You’ll find that the model used
for 3D polygonal rendering (lights, cameras, actors) is
analogous to the model used for volume and other types
of rendering (lights, cameras, volumes). In the follow-
ing sections we’ll walk through a simple example
demonstrating these classes for surface polygonal and
volume rendering. You may wish to type these com-
mands into a properly installed Tcl interpreter as
described in the previous section. Figure 2 shows the
resulting image from this example.
IEEE Computer Graphics and Applications 21
Open Source Breakout
A model of software development called open source is gaining
acceptance in the software world. Although the exact definition of
open source remains debatable, the basic premise is that the
source code is freely available to anyone who wants it. This differs
greatly from commercial software, freeware, and shareware, all of
which are normally distributed in a binary format only. The
availability of source code to a wide audience creates many
opportunities and advantages in the software development
process. Recently, several high-profile projects have brought this
model to the attention of the media and general public. Those
projects include the Linux operating system, the Apache Web
server (running 50 percent of the World Wide Web), and sendmail
(the backbone for much of the e-mail sent today). Although people
have shared source code since the beginning of computers, new
business models, software development tools, and the Internet
have allowed the practice to expand greatly in the past five years.
Open-source software has many benefits. Eric Raymond in The
Cathedral and the Bazaar: Musings on Linux and Open Source by an
Accidental Revolutionary (O’Reilly Publishers) argues that open-
source software development (the bazaar model) is inherently
more scalable than closed-team development (the cathedral
model). With more eyes looking at source code, bugs can be
discovered and fixed faster. In addition, new developers join the
development team at no extra cost. This has created more reliable
and portable software with faster development cycles than many
closed commercial offerings. With many developers in diverse
geographical areas, testing becomes even more important.
In the past 10 years business models have emerged to support
open-source development. It may seem impossible for a company
to survive by giving away software. However, companies can thrive
around an open-source project. Some common ways of generating
revenue include consulting, training, adding features, selling
technical support, building proprietary end-user applications on
top of open-source libraries, and selling development tools.
1 VTK can be used in diverse areas including medical
visualization (left) and industrial inspection applica-
tions (right).
2 Two renderers in a rendering window combine
surface, volume, and 2D rendering. The left renderer
contains a simple cube; the right renderer contains a
polygonal isosurface and volume rendering of electron
potential. The scalar bar indicates data range and its
relationship to color.