Practical tutorial 1
Introduction to VTK
What is vtk?
To quote from the VTK Overview page: "The Visualization ToolKit (VTK) is an open source, freely available software system for 3D computer graphics, image processing, and visualization used by thousands of researchers and developers around the world." The people in charge of this system are Kitware; they also provide other services based on their software, and they sell a User's Guide for vtk. A short introduction to VTK can be found here.
The graphics model in VTK is at a higher level of abstraction than rendering libraries like OpenGL. This means it is much easier to create useful graphics and visualization applications. In VTK applications can be written directly in C++, Tcl, Java, or Python. You have a choice: if you hate C++, then use Tcl, Python, or Java. In fact, using the interpreted languages Tcl or Python with Tk, and even Java with its GUI class libraries, it is possible to build useful applications really, really fast. During this course we will be using VTK primarily using Tcl/Tk.
The difference between Tcl/Tk and vtk is that vtk is providing the functions, data structures, and computational framework which we use to write visualization software, while Tcl is just the computer language we use to access all this functionality. Because Tcl also provides functionality to Tk, putting GUIs on your visualization programs is made very easy.
Where to find (or get) vtk
VTK is installed on the linux machines in the CSG labs. To use VTK you need to add the following lines to the .cshrc file in your home directory:
# Add VTK setenv LD_LIBRARY_PATH /vol/vtk/vtk-5.4.2/lib/vtk-5.4:${LD_LIBRARY_PATH} setenv PATH /vol/vtk/vtk-5.4.2/bin:${PATH} setenv VTK_DATA_ROOT /vol/vtk/vtk-5.4.2/data setenv TCLLIBPATH /vol/vtk/lib/vtk-5.4.2
To get started
Start with the practical part of the tutorial using TCL. The tutorial consists of 6 steps which demonstrate some basic VTK concepts. They are organized in increasing order of complexity.
- Step 1 - A "Hello World" style example of a simple visualization pipeline (Cone1.tcl)
- Step 2 - Adding observers (Cone2.tcl)
- Step 3 - Rendering with multiple renderers (Cone3.tcl)
- Step 4 - Modifying properties and transformations (Cone4.tcl)
- Step 5 - Specifying a particular interaction style (Cone5.tcl)
- Step 6 - Adding a 3D widget (Cone6.tcl)
To run any of these example programs download and save the TCL script and then run: vtk Cone1.tcl
.
Try to modify these scripts (by editing them using your favourite editor) and re-run the scripts.
Other examples and useful links
More examples can be found in /vol/vtk/vtk-5.4.2/src/Examples
. Here is some other useful information: