VTK Visualization Toolkit - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

VTK Visualization Toolkit

Description:

none – PowerPoint PPT presentation

Number of Views:808
Avg rating:3.0/5.0
Slides: 20
Provided by: ChrisB9
Category:

less

Transcript and Presenter's Notes

Title: VTK Visualization Toolkit


1
VTK (Visualization Toolkit) Beginners Overview
and Tutorial
Chris BoehnenComputer Vision Research
LabUniversity of Notre Dame
2
What can VTK do?
  • 2 Dimensional Visualizations (vtkImageData)
  • commonly used for medical devices like CT, or
    MRI scans to assemble and manipulate multiple 2D
    scans such as visual human project
  • Data normally converted to 3D data from the
    manipulated 2D data

3
What can VTK do?
  • 3 dimensional visualizations
  • Animation, lighting, interacting, rotating and
    rendering of 3D data built in
  • Built in filters to manipulate and save the data
  • NSF runs virtual creatureanimations and
    modelsto allow students to see,touch, and
    interact with biology in ways not normally
    possible

4
What is VTK?
  • Open Source Software Kit used for two and three
    dimensional Visualizations
  • Cross Platform, runs on Windows, Unix, and Linux
  • Accessible through multiple programming languages
    (Tcl, Java, Python, and C)
  • C Object Oriented Core

5
How does VTK work?
  • Uses a pipeline execution to pass the data
    through various objects.
  • Implements a lazy processing scheme (waits for
    data to be needed to process)

Source
Filter
Mapper
Actor
Renderer
Information Flow
6
VTK Objects, Abstractions, Inheritence
  • Abstract VTK objects are used in order to make
    the subsequent inherited objects more uniform.
    Some inherited objects include
  • vtkProp3D
  • vtkData
  • vtkMapper
  • vtkCamera
  • vtkLight
  • vtkRenderer
  • vtkRenderWindow
  • vtkRenderWindowInteractor

7
Cone VTK Pipeline Example
Cone PolyData Mapper
Cone Source
RenderWindow
Cone Actor
Renderer
Some form of source data is required, in this
case it is generated by a formula in the shape of
a cone
The source data is then mapped into 2D info and
passed on
The actor is a global information storage unit
for global manipulation and reference
The Rendered takes the mapped 3D data and adds in
light, motion sound and camera position
The Render Window takes the current image and
puts it into your moniter within a given frame
8
VTK By Example
Python Cone Example
renWin vtkRenderWindow() renWin.AddRenderer(
ren1 ) renWin.SetSize( 300, 300 ) for i in
range(0,360) renWin.Render()
ren1.GetActiveCamera().Azimuth( 1 ) Free Up
Unneeded objects cone None coneMapper
None coneActor None ren1 None renWin None
!/usr/bin/env python from vtkpython import
cone vtkConeSource() cone.SetHeight( 3.0
) cone.SetRadius( 1.0 ) cone.SetResolution( 10 )
coneMapper vtkPolyDataMapper() coneMapper.SetIn
put( cone.GetOutput() ) coneActor
vtkActor() coneActor.SetMapper( coneMapper
) ren1 vtkRenderer() ren1.AddActor( coneActor
) ren1.SetBackground( 0.1, 0.2, 0.4 )
9
VTK By Example
C Cone Example
include "vtkConeSource.h" include
"vtkPolyDataMapper.h" include "vtkRenderWindow.h"
int main( int argc, char argv )
vtkConeSource cone vtkConeSourceNew()
cone-gtSetHeight( 3.0 ) cone-gtSetRadius( 1.0
) cone-gtSetResolution( 10 )
vtkPolyDataMapper coneMapper
vtkPolyDataMapperNew() coneMapper-gtSetInput(
cone-gtGetOutput() ) vtkActor coneActor
vtkActorNew() coneActor-gtSetMapper(
coneMapper ) vtkRenderer ren1
vtkRendererNew() ren1-gtAddActor( coneActor
) ren1-gtSetBackground( 0.1, 0.2, 0.4 )
vtkRenderWindow renWin vtkRenderWindowNew()
renWin-gtAddRenderer( ren1 )
renWin-gtSetSize( 300, 300 ) for (int i 0 i
lt 360 i) // render the image
renWin-gtRender() // rotate the active camera
by one degree ren1-gtGetActiveCamera()-gtAzimuth
( 1 ) cone-gtDelete()
coneMapper-gtDelete() coneActor-gtDelete()
ren1-gtDelete() renWin-gtDelete() return
0
10
VTK By Example
Java Cone Example
vtkActor coneActor new vtkActor()
coneActor.SetMapper( coneMapper )
vtkRenderer ren1 new vtkRenderer()
ren1.AddActor( coneActor )
ren1.SetBackground( 0.1, 0.2, 0.4 )
vtkRenderWindow renWin new vtkRenderWindow()
renWin.AddRenderer( ren1 ) renWin.SetSize(
300, 300 ) int i for (i 0 i lt 360
i) // render the image
renWin.Render() // rotate the active
camera by one degree ren1.GetActiveCamera().
Azimuth( 1 )
// we import the vtk wrapped classes first import
vtk. // then we define our class public class
Cone static System.loadLibrary("vtkComm
onJava") System.loadLibrary("vtkFilteringJav
a") System.loadLibrary("vtkIOJava")
System.loadLibrary("vtkImagingJava")
System.loadLibrary("vtkGraphicsJava")
System.loadLibrary("vtkRenderingJava")
public static void main (String args)
vtkConeSource cone new vtkConeSource()
cone.SetHeight( 3.0 ) cone.SetRadius( 1.0
) cone.SetResolution( 10 )
vtkPolyDataMapper coneMapper new
vtkPolyDataMapper() coneMapper.SetInput(
cone.GetOutput() )
11
VTK By Example
TCL Cone Example
vtkRenderWindow renWin renWin AddRenderer
ren1 renWin SetSize 300 300 for set i 0 i lt
360 incr i render the image renWin
Render rotate the active camera by one
degree ren1 GetActiveCamera Azimuth
1 vtkCommand DeleteAllObjects exit
package require vtk vtkConeSource cone cone
SetHeight 3.0 cone SetRadius 1.0 cone
SetResolution 10 vtkPolyDataMapper
coneMapper coneMapper SetInput cone
GetOutput vtkActor coneActor coneActor
SetMapper coneMapper vtkRenderer ren1 ren1
AddActor coneActor ren1 SetBackground 0.1 0.2 0.4
12
Additions to Cone VTK Pipeline
vtkCamera
vtkLight
vtkRenderWindowInteractor
Cone PolyData Mapper
Cone Source
RenderWindow
Cone vtkActor
Renderer
Point vtkActor
OutPutFiles
vtkStlReader
STL File
Point vtkpolydataMapper
ReverseSense Filter
SurfaceReconstruction Filter
Contour Filter
Point Source
13
Basic VTK Pipeline Components
  • Source Data
  • Filters
  • Mappers
  • Props (includes actors, lights and cameras)
  • Renderers
  • Output of Source (RenderWindow)
  • Interactions (RenderWindowInteractor)

14
Nuts and Bolts,Getting VTK Up and Running
  • Download Source File, or use CD
  • Install and Run CMake
  • CMake is cross platform, multiple OS vers.
  • CMake generates a makefile for different C
    Compilers (I used MSVS .NET)
  • Not Specifically for VTK, uses makefile makefiles
    to specify how the makefile should be made
  • Compile the Software
  • In MSVS .NET, just open it and compile

15
Nuts and Bolts,Getting VTK Up and Running
  • Must import .H files and source files into your
    C (or other language) program
  • Multiple methods for this, no right answer
  • In .NET easiest way is to modify the property
    pages for your program.
  • Under C ? General tab include the source for
    your header files
  • Under Linker ? General tab include the additional
    library directories
  • Under Linker ? Input ? Additional Dependencies
    include the necessary .LIB files

16
Comments on getting VTK up and running
  • Dont get frustrated! It has a high learning
    curve when youve never used VTK before. I spent
    all summer learning it and Im still nowhere near
    an expert.
  • Pay careful attention to Sample code, or sample
    projects given to you, getting them to work can
    be VERY complicated since you may have different
    source directories and there are many ways to
    include all of the files.

17
Comments on getting VTK up and running
  • If youve never learned the programming
    environment youre using before (MSVS .NET for
    example) make sure you are very familiar with
    that environment before you try and start using
    VTK in it. Otherwise you are trying to learn two
    complex things at the same time and trying to
    figure out whether problems lie in the VTK code,
    or in the environment itself can take a LONG
    while to figure out.

18
Comments on getting VTK up and running
  • Use outside resources, you will NOT be able to
    figure out all it just from the source code (not
    in this millennium anyways).
  • Recommended book Visualization Toolkit Users
    Guide
  • Several Listservs available through VTKs website
    (www.kitware.com) are not as responsive to low
    level questions but if you phrase the question
    well you may get some good help on your problem.

19
Demo Time!
Write a Comment
User Comments (0)
About PowerShow.com