# Welcome To The Visualization Toolkit

- Introduction
- Copyright Notice
- Organization
- Documentation
- Installation
  - Unix Installation
  - Cygwin Installation
  - PC Installation
- Common Problems
- Getting Data
- Running VTK
- Adding A New Class
- Getting Help / Mailing List

# Introduction

VTK is an open-source software system for image processing, 3D graphics, and visualization. VTK includes many advanced algorithms (e.g., surface reconstruction, implicit modelling, decimation) and rendering techniques (e.g., volume rendering, LOD control).

VTK is used by academicians for teaching and research; by government research institutions such as Los Alamos National Lab in the US or CINECA in Italy; and by many commercial firms who use VTK to build or extend products.

The origin of VTK is with the textbook "The Visualization Toolkit, an Object-Oriented Approach to 3D Graphics" originally published by Prentice Hall and now published by Kitware, Inc. (Third Edition ISBN 1-930934-07-6). VTK has grown (since its initial release in 1994) to a world-wide user base in the commercial, academic, and research communities.

This README is written for VTK version 4.4 and greater. For more information, additional resources, and the FAQ see the web page at http://www.vtk.org

# Copyright Notice

VTK has a generous open-source copyright modelled after the BSD license. Yes, you can use VTK in commercial products. The complete text of the copyright follows.

    Copyright (c) 1993-2004 Ken Martin, Will Schroeder, Bill Lorensen
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:

     * Redistributions of source code must retain the above copyright notice,
       this list of conditions and the following disclaimer.

     * Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.

     * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
       of any contributors may be used to endorse or promote products derived
       from this software without specific prior written permission.

     * Modified source versions must be plainly marked as such, and must not be
       misrepresented as being the original software.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
    ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Organization

The VTK 4.2 source code repository is organized into four major sections.

- The source code is found in the directories Common, Rendering, Filtering, Graphics, Imaging, Hybrid, Parallel, VolumeRendering and GenericFiltering. In some cases additional README.html files are found in the named directories. Please see these for more information.

  - Common- Core classes
  - Rendering- Classes used to render
  - Filtering- Abstract superclasses for filtering data
  - Graphics- Filters that process 3D data
  - Imaging- Specialized image processing filters
  - IO- Classes for reading abd writing data
  - Hybrid- Complex classes that depend on imaging and graphics
  - Parallel- Parallel processing support such as MPI
  - GenericFiltering- Part of an adaptor framework supporting integration of VTK with external systems

- Examples that are reasonably well documented are found in the VTK/Examples directory. You may wish to start with the examples found in the Tutorial directory.

- The Utilities directory includes things like jpeg, png, and zlib source code. This code is used by VTK in various ways (reading/writing data, etc.)

- The Wrapping directory contains code related to VTK's automated wrapping process. The wrapping process automatically generates Tcl, Python, and/or Java bindings depending on how the build process is configured.

There are hundreds of testing examples located in the Testing/ directory under each source code directory (e.g., Graphics/Testing). These are undocumented tests but can be helpful in some cases.

# Documentation

The ideal way to learn about the software is from two books: The Visualization Toolkit, An Object-Oriented Approach to 3D Graphics and The VTK User's Guide both published by Kitware, Inc. (Note: The Visualization Toolkit was originally published by Prentice-Hall, the third edition is published by Kitware.) You may order the books from the following locations (Amazon.com also carries the books.)

      The Visualization Toolkit, An Object-Oriented Approach to 3D Graphics (Third Edition)
      by Will Schroeder, Ken Martin and Bill Lorensen.
      Kitware, Inc.,
      ISBN 1-930934-07-6
      http://www.kitware.com/products/vtktextbook.html

      The VTK User's Guide (VTK 4.2 Edition)
      Kitware, Inc.,
      ISBN 1-930934-08-4
      http://www.kitware.com/products/vtkguide.html

On-line Doxygen man pages are also available at http://www.vtk.org/doc/nightly/html/

# Installation

The Visualization Toolkit can be built on Unix, PC (Windows 95/98/NT/2000/XP) and Mac OSX Jaguar (or greater) systems. VTK uses CMake for its build process. To build VTK for UNIX or Windows, you will first have to install CMake. You can download CMake from: http://www.cmake.org The following instructions assume that CMake is already installed.

### Unix Installation

The following instructions only apply to UNIX systems. First we will give you the quick and dirty way to build VTK. Begin by telling CMake what C and C++ compilers you will be using. This can avoid many build problems. On most systems you can pass this information to CMake in the following way:

      env CXX=/your/C++/compiler CC=/your/c/compiler cmake

otherwise you must set the CXX and CC environment variables and then run ccmake (or cmake -i).

If you will be using C++ as your development language (no Tcl/Tk, Python or Java support):

      1) untar the src files
      2) untar the data files
      3) cd VTK
      4) cmake -i (run cmake in wizard mode, where you have to answer
         questions about the build)
    or
      4) ccmake (run the terminal based interface to cmake where you interactively
         change build options)
      5) if necessary change build options
      6) make

Note that this will create the binaries (i.e., object code, libraries, and executables) in the same directory as the source code. You can also build VTK out of source in a separate directory (this is particularly convenient when building VTK on multiple architectures). Instead of running CMake from the VTK directory, create a new directory with enough disk space (not in the VTK tree) such as vtk-solaris. cd into this directory and then run CMake similar to the following example:

      ls /home/joe_user
          vtk vtk-solaris vtk-sgi

      cd vtk-solaris
      ccmake /home/joe_user/VTK
    or
      cmake -i /home/joe_user/VTK

This will create makefiles in the vtk-solaris directory. Then you can run make in vtk-solaris to compile VTK. Repeate this process for each architecture you wish to build.

If you want to build the Tcl-based VTK interpreter then you will need to have Tcl and Tk (8.2 or newer). Look to http://www.scriptics.com for information about getting Tcl and Tk. To turn on Tcl wrapping, set VTK_WRAP_TCL to ON during the configuration process (as a post-build step, you might want to check the Wrapping/Tcl/README file). You will then have to set the values for Tcl/Tk include directories and libraries.

If you want to use VTK from Python you will need to have Python installed. To turn on Python wrapping, set VTK_WRAP_PYTHON to ON during the configuration process and then set the values for the Python related directories and libraries. If you want to use Tkinter with VTK-Python then you should also turn on Tcl wrapping by setting VTK_WRAP_TCL to ON. Make sure that the Tcl/Tk libraries that you set correspond to the same version used by Tkinter. Note that the VTK-Python modules are not installed by default via 'make install'. The Wrapping/Python/README.txt file documents the installation procedure and the VTK-Python modules.

### Cygwin Installation

The build process for Cygwin is almost exactly the same as the UNIX build process (see previous section)

If you will be using C++ as your development language (no Tcl/Tk, Python or Java support):

      1) untar the src files
      2) untar the data files
      3) cd VTK
      4) cmake -i (run cmake in wizard mode, where you have to answer questions
         about the build)
    or
      4) ccmake (run the terminal based interface to cmake where you interactively
         change build options)
      5) if necessary change build options
      6) make

For Tcl/Tk support, you have to install the cygwin sources for Tcl/Tk, then set the TK_*_PATH variables to apropriate locations. For example if the TCL/TK cygwin version you have is 20030214-1, then set the following options:

    TK_INCLUDE_PATH /usr/src/tcltk-20030214-1/tk/generic/;/usr/src/tcltk-20030214-1/tcl/generic/
    TK_INTERNAL_PATH /usr/src/tcltk-20030214-1/tk/win/
    TK_XLIB_PATH /usr/src/tcltk-20030214-1/tk/xlib

Also, if you have several versions of TCL installed on the computer, where some of them are regular Windows binaries, and some are Cygwin, make sure to set the TCL_TCLSH to point to the right one.

### PC Installation

The PC build process uses the CMake GUI CMakeSetup. Then you use the compiler make utility to compile as follows.

      1) Install the VTK 4.2 distribution by unzipping into the
         appropriate directory.

      2) Execute CMakeSetup. This will pop-up a little
         GUI that allows you to tailor the build. It then starts
         building .dsw and .dsp files for Microsoft, or makefiles for Borland.
         You'll have to tell CMakeSetup where you've placed your VTK source
         code, and where to build the object code and dll's
         (we'll call it "vtkbin").

      3) When CMakeSetup completes, start up msdev and load VTK.dsw.
         Select ALL_BUILD project, and build it.

We recommend a 300MByte minimum swap size or you'll have trouble during the link phase.

# Common Problems

- Strange compile errors on Unix. Make sure that you specify the environment variables CXX and CC prior to running CMake. (If you have already run CMake, do a "make clean" to remove the cached CMake information.)
- Errors on Tcl or Tk include files. Make sure that you edit CMakeCache.txt to point to the correct location.
- Errors on Tcl or Tk libraries. Make sure that you edit CMakeCache.txt to point to the correct location.
- Link errors on Windows platforms. Make sure that the swap space is at least 300 MByte.
- Link error with borland: TCL82.LIB contains invalid OMF record, type 0x21 (possibly COFF). You have to convert Tcl libraires from coff to omf with the Borland utilitiy coff2omf. Once you have created OMF versions, re-run cmake to tell it where the Borland versions of Tcl and Tk are located. Also, make sure that you are using Tcl/Tk 8.3.2.

# Getting Data and Test Images

Many of the examples require data. There are two ways to get data. The first is to download the file VTKData.tgz. The second is to access the data via CVS checkout. The CVS checkout also includes many test images used by the testing process (see http://public.kitware.com/dashboard.php). These can be used if you wish to test VTK or submit testing dashboards. The VTKData.tgz contains only data in compressed form is therefore can be obtained much faster.

      1) Download the data at ftp://public.kitware.com/pub/vtk/VTKData.tgz

      2) Checkout the data from CVS using the folling commands:
         cvs -d :pserver:anonymous@public.kitware.com:/vtk/cvsroot login
            (respond with password vtk)
         cvs -d :pserver:anonymous@public.kitware.com:/vtk/cvsroot checkout VTKData

# Running VTK

Many C++ examples will be compiled if BUILD_TESTING and/or BUILD_EXAMPLES are enabled in CMake. To run these C++ examples just type their name. (They will be found in the binary build directory.) If you have built shared libraries, make sure the PATH environment variable (Windows) or the LD_LIBRARY_PATH (Unix) point to the shared libraries. If you have enabled Tcl wrapping, you will want to set TCLLIBPATH to point to the VTK/Wrapping/Tcl directory and check the instructions located in the Wrapping/Tcl/README file. You will then run the VTK executable found in the bin directory where the code was compiled. Assuming that the executable VTK is in your path, or has been aliased, you would type:

      vtk mace.tcl

Note that most Tcl scripts allow you to type "u" in the render window to obtain an interpreter. You can use the interpreter to modify the application at run-time.

If you have enabled Python Wrapping you should read the instructions located in the Wrapping/Python/README.txt file.

# Writing Your Own Class

There are several ways to extend VTK. The simplest way is, in your own code, create classes that inherit from the appropriate VTK classes. Please see the `vtkLocal` example for instructions to build your classes outside VTK.

# Getting Help / Mailing List

For general information go to the VTK web site http://www.vtk.org

If you run into problems, your best bet is to join the VTK mailing list. Visit http://public.kitware.com/mailman/listinfo/vtkusers to join the list.

Commercial support contracts are available from Kitware at http://www.kitware.com/products/vtksupport.html.

Kitware also provides consulting services. Read more at http://www.kitware.com/products/consult.html.

Training is also available from Kitware. See http://www.kitware.com/products/vtktrain.html.