VTK/Examples/Instructions/ForUsers

From KitwarePublic

Jump to: navigation, search

If you want to use VTK Examples you have several options. If you are a Wiki Example Developer, go here or a Wiki Example Administrator go here.

Contents

Build an example

  1. Create a source directory (mkdir ExampleName)
  2. Copy and paste the source code under the heading ExampleName.cxx into an editor and save the file as ExampleName.cxx in the source directory you have just created.
  3. Copy and paste the text under the heading CMakeLists.txt into an editor and save the file as CMakeLists.txt in the same directory.
  4. Create a build directory (mkdir bin). This can be inside of your source directory, but it doesn't have to be.

From here, the instructions are operating system specific:

Linux

From your build directory, run

ccmake YourSourceDirectory (to create a Unix Makefile)

or

ccmake YourSourceDirectory -G YourIDE (e.g. KDevelop3)
  1. Press 'c' to configure.
  2. If CMake finds the correct location of you VTK binary build (the VTK_DIR cmake variable), great! If not, use the arrow keys to scroll down to VTK_DIR, press enter, type the location of your VTK binary build (likely something like /home/yourname/bin/VTK), and press enter.
  3. Press 'c' again to reconfigure
  4. Press 'g' to generate
  5. If you generated a Unix Makefile, type 'make' in your build directory
  6. If you generated a project for an IDE, open the project file with your IDE

Windows

  1. Open CMake
  2. Select your CMakeLists.txt file
  3. Select your build system
  4. Click "Generate"
  5. A "project file" for your IDE will be produced. Open your IDE and open the project file.

Build all of the examples

If you are really getting excited about learning VTK and are tried of "copy and pasting" examples over and over, you can download them all at the same time and build them all together.

  • Download a tar file containing all examples. NOTE: If you get a message to try again later, hit the refresh button on your browser.
Extract the tarball to WikiExamples.
or
  • Keep an active connection to the examples.
  1. Install git
  2. Clone the examples repository
git clone git://gitorious.org/vtkwikiexamples/wikiexamples.git WikiExamples
  • Make a directory to hold the binaries
mkdir WikiExamples-build
  • From this build directory, run 'cmake'. You will be prompted for the location of your VTK binary build.
cd WikiExamples-build
ccmake ../WikiExamples
make

Find a class or method using google

Type the following into the google search bar

site:vtk.org/Wiki/VTK/Examples vtkImageViewer2
or
site:vtk.org/Wiki/VTK/Examples SetThetaResolution

Update the examples repository

If you cloned the examples repository, you can get the latest updates:

cd WikiExamples
git pull git@gitorious.org:vtkwikiexamples/wikiexamples.git
cd ../WikiExamples-build
cmake ../WikiExamples
make

Run all of the examples

ctest
Personal tools