The Visualization Toolkit (VTK) is a library that provides tools for 3D computer graphics, image processing and visualization. It abstracts away hardware and OS-specific details like OpenGL vs Mesa and X Windows vs DirectX. VTK uses a two stage process - a visualization model converts data into graphical elements, and a graphics model converts those elements into a displayed picture. It implements common visualization algorithms like contouring and surface reconstruction. VTK is useful for visualizing scientific data and provides wrappers for languages like Python, Java and Tcl.
2. Why VTK?
• More control than regular application
• You don’t need to care about hardware-
and OS-specific details, e.g.
– OpenGL vs. Mesa
– X Windows vs. DirectX
3. VTK abstracts away details
does,
visualize data (Your Program Here)
e.g.
talks to
does, example of
Application Library
calc. contour VTK
e.g.
talks to
example of
does,
Graphics Library
draw a triangle OpenGL
e.g.
talks to
does,
OS, hardware etc.
add numbers e.g.
4. How VTK works
• Stage 1: Visualization Model
– What data to show?
– How to visualize?
– Converts data into 3D graphical elements
• Stage 2: Graphics Model
– What needs to be drawn?
– Where to draw it?
– Converts abstract graphical elements into a
displayed picture
5. Stage 1: Visualization Model
• Abstract objects handle data flow
Source Mapper
Filter
raw data data processing how to draw things
makes actors
e.g. to draw an orbital,
Point cloud Construct isosurface Triangle strips
6. Stage 2: Graphics Model
Trans- Mapper
form
• Rendering pipeline
• Data flow between Scene
Actor
objects
viewpoint
• Implemented as C++
objects Camera
Light
• Wrappers for Java,
Python and Tcl Props
where to
Renderer
draw things
“canvas”
Render Window
end user
7. Execution Control
End user
• Visualization model is
5. User
demand driven
happy
– Data processed from
4. draws
1. “Show me
graphics
the money!” source only when
needed to
Graphics Model
• Graphics model is
3. creates
2. “ok,
event driven
graphics
now what?”
– Draws only when user
Visualization Model wants it
8. VisTraj
• Want to see how if trajectories from FMS
dynamics ever come close to model (ideal)
cone computed from CI point parameters
• Want to visualize spawning events
• Example data: 12 trajectories around an
ethylidene intersection in ethylene
9. VisTraj.py data flow
FMSTrajectory simulation parameters
ModelCone
instance ConicalIntersection used to calculate
h vector
of
numpy.array ModelCone
ProjectedMomenta
g vector Trajectory Population
vtkDoubleArray[3]
numpy.array numpy.array vtkDoubleArray
Configuration Energies Coupling ProjectedTrajectory
Molecule numpy.array vtkDoubleArray vtkPoints
ConeActor attribute InputData
GlyphActor
vtkQuadric
data in vtkPolyData
vtkConeSource
vtkSampleFunction
vtkGlyph3D
vtkContourFilter
vtkPolyData
SparkActor
vtkPolyDataMapper
vtkPolyDataMapper
vtkActor vtkSphereSource
vtkActor
vtkPolyDataMapper
Molecule vtkActor
Axes
Structure instance
Main Display vtkAxesActor
Outline
numpy.array
of vtkRenderer
vtkOutlineSource
Energy vtkRenderWindow
props in vtkPolyDataMapper
vtkRenderWindowInteractor
float vtkActor
vtkPNGWriter
10. Plot: 1 parent and 1 child
no attribute data
child
Spawn
X
point
ProjectedTrajectory
vtkPoints
GlyphActor
vtkSphereSource
vtkGlyph3D
vtkPolyData
vtkPolyDataMapper
vtkActor
InputData
TubeActor
vtkPolyData
vtkPolyData
vtkTubeFilter
vtkPolyDataMapper
vtkActor
parent
Origin = 2CI