Scientific Visualization Using VTK. Robert Putnam putnam@bu.edu. Scientific Visualization Using VTK – Spring 2012. Outline. Introduction VTK overview VTK data geometry/topology Case study Interactive session. Scientific Visualization Using VTK – Spring 2012. Introduction.
An Image/Link below is provided (as is) to download presentation
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.Content is provided to you AS IS for your information and personal use only.Download presentation by click this link.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.During download, if you can't get a presentation, the file might be deleted by the publisher.
Outline • Introduction • VTK overview • VTK data geometry/topology • Case study • Interactive session Scientific Visualization Using VTK – Spring 2012
Introduction • Visualization: converting raw data to a form that is viewable and understandable to humans. • Scientific visualization: specifically concerned with data that has a well-defined representation in 2D or 3D space (e.g., from simulation mesh or scanner). *Adaptedfrom The ParaView Tutorial, Moreland Scientific Visualization Using VTK – Spring 2012
VTK Visualization Toolkit • Inception at GE in 1993; since 1998 spun off to “Kitware”, supported by Sandia Labs. • Open source • Set of object-oriented class libraries for visualization and data analysis • Several language interfaces • C++ • Tcl • Java • Python • Portable (MS Windows, Linux, OSX) • Active developer community • Good documentation available, free and otherwise • Professional support services available from Kitware Scientific Visualization Using VTK – Spring 2012
C++ v. Tcl • C++ • Tcl vtkStructuredGridReader *reader = vtkStructuredGridReader::New(); reader->SetFileName("density.vtk"); reader->Update(); vtkContourFilter *iso = vtkCountourFilter::New(); iso->SetInputConnection(reader->GetOutputPort()); iso->SetValue(0, .26); vtkStructuredGridReader reader reader SetFileName "density.vtk" reader Update vtkContourFilter iso iso SetInputConnection [reader GetOutputPort] iso SetValue 0 .26 Scientific Visualization Using VTK – Spring 2012
Coding tip of the day! • Google “VTK class list”, or • Go to: http://www.vtk.org/doc/nightly/html/annotated.html Scientific Visualization Using VTK – Spring 2012
VTK – Geometry v. Topology • Geometry of a dataset ~= points 0,1 1,1 2,1 3,1 0,0 1,0 2,0 3,0 • Topology ~= connections among points, which define cells • So, what’s the topology here? Scientific Visualization Using VTK – Spring 2012
VTK – Geometry v. Topology 0,1 1,1 2,1 3,1 0,0 1,0 2,0 3,0 Scientific Visualization Using VTK – Spring 2012
VTK – Geometry v. Topology 0,1 1,1 2,1 3,1 0,0 1,0 2,0 3,0 or 0,1 1,1 2,1 3,1 0,0 1,0 2,0 3,0 Scientific Visualization Using VTK – Spring 2012
VTK – Geometry v. Topology or 0,1 1,1 2,1 3,1 0,1 1,1 2,1 3,1 0,0 1,0 2,0 3,0 0,0 1,0 2,0 3,0 or 0,1 1,1 2,1 3,1 0,0 1,0 2,0 3,0 Scientific Visualization Using VTK – Spring 2012
VTK – Geometry v. Topology or 0,1 1,1 2,1 3,1 0,1 1,1 2,1 3,1 0,0 1,0 2,0 3,0 0,0 1,0 2,0 3,0 or or 0,1 1,1 2,1 3,1 0,1 1,1 2,1 3,1 0,0 1,0 2,0 3,0 0,0 1,0 2,0 3,0 Scientific Visualization Using VTK – Spring 2012
Geometry/Topology Structure • Geometry/topology may be regular or irregular • Regular (structured) • need to store only beginning position, spacing, number of points • smaller memory footprint per cell (topology can be generated on the fly) • examples: image data, rectilinear grid, structured grid • Irregular (unstructured) • information can be represented more densely where it changes quickly • higher memory footprint (topology must be explicitly written) but more freedom • examples: polygonal data, unstructured grid Scientific Visualization Using VTK – Spring 2012
Characteristics of Data • Data is organized into datasets for visualization • Datasets consist of two pieces • organizing structure • points (geometry) • cells (topology) • data attributes associated with the structure • File format derived from organizing structure • Data is discrete • Interpolation functions generate data values in between known points Scientific Visualization Using VTK – Spring 2012
Structured Points (Image Data) • regular in both topology and geometry • examples: lines, pixels, voxels • applications: imaging CT, MRI • Rectilinear Grid • regular topology but geometry only partially regular • examples: pixels, voxels • Structured Grid (Curvilinear) • regular topology and irregular geometry • applications: fluid flow, heat transfer Examples of Dataset Types Scientific Visualization Using VTK – Spring 2012
Examples of Dataset Types (cont) • Polygonal Data • irregular in both topology and geometry • examples: vertices, polyvertices, lines, polylines, polygons, triangle strips • Unstructured Grid • irregular in both topology and geometry • examples: any combination of cells • applications: finite element analysis, structural design, vibration Scientific Visualization Using VTK – Spring 2012
Data Attributes • Data attributes associated with the organizing structure • Scalars • single valued • examples: temperature, pressure, density, elevation • Vectors • magnitude and direction • examples: velocity, momentum • Normals • direction vectors (magnitude of 1) used for shading • Texture Coordinates • used to map a point in Cartesian space into 1, 2, or 3D texture space • used for texture mapping • Tensors • 3x3 only • examples: stress, strain Scientific Visualization Using VTK – Spring 2012
Work flow – Case Study • BU Space Physics simulation • Meteor trails in the ionosphere • Data wrangling: • Consolidate datafiles (from parallel code), create single binary datafile • Add VTK header: # vtk DataFile Version 3.0 output of reassemble.c BINARY DATASET STRUCTURED_POINTS ORIGIN 0.0 0.0 0.0 SPACING 1.0 1.0 1.0 DIMENSIONS 512 64 128 POINT_DATA 4194304 SCALARS plasma float LOOKUP_TABLE default Scientific Visualization Using VTK – Spring 2012
Work flow – Case Study • Use Tcl for fast development/testing: vtkStructuredPointsReader reader reader SetFileName "opp.vtk" reader Update vtkContourFilter iso iso SetInputConnection [reader GetOutputPort] iso SetValue 0 0.1 . . . Scientific Visualization Using VTK – Spring 2012
Work flow – Case Study • Add gaussian filter : vtkImageGaussianSmooth gaussian gaussian SetInputConnection [reader GetOutputPort] gaussian SetDimensionality 3 gaussian SetRadiusFactor 1 vtkContourFilter iso iso SetInputConnection [gaussian GetOutputPort] iso SetValue 0 0.1 . . . Scientific Visualization Using VTK – Spring 2012
Work flow – Case Study • Add more isosurfaces : vtkContourFilter iso iso SetInputConnection [gaussian GetOutputPort] iso SetValue 0 1.0 iso SetValue 1 0.5 iso SetValue 2 0.1 Scientific Visualization Using VTK – Spring 2012
Work flow – Case Study • Port to C++, add cutplane, transparency : vtkPlane *plane = vtkPlane::New(); plane->SetOrigin(256,2,63.5); plane->SetNormal(0,1,0); vtkCutter *planeCut = vtkCutter::New(); planeCut->SetInputConnection(reader>GetOutputPort()); planeCut->SetCutFunction(plane); vtkActor *isoActor = vtkActor::New(); isoActor->SetMapper(isoMapper); isoActor->GetProperty()->SetOpacity(iv_opacity); Scientific Visualization Using VTK – Spring 2012
Work flow – Case Study • Change color map, use script to loop over *.vtk, generate multiple jpegs, read into Adobe Premiere, produce animation: Scientific Visualization Using VTK – Spring 2012
Keyboard shortcuts j – joystick (continuous) mode t – trackball mode c –camera move mode a –actor move mode left mouse – rotate x,y ctrl - left mouse – rotate z middle mouse –pan right mouse –zoom r –reset camera s/w –surface/wireframe e (or q) –exit Scientific Visualization Using VTK – Spring 2012
Exercise Editor: cone3.cxx Add coneActor2, and color it green. (Copy coneActor, and make appropriate changes. Remember to add the new actor to the render window [near the end of the “pipeline”].) Optional: to rotate, scale and set the position away from the origin, use the following: coneActor2->RotateZ(90); coneActor2->SetScale(0.5,0.5,0.5); coneActor2->SetPosition(-1.0,0.0,0.0); Otherwise, use ‘a’ to use mouse to separate the green and red cones. Scientific Visualization Using VTK – Spring 2012
Clipping, Cutting, Subsampling Selection Algorithms - Clipping • can reveal internal details of surface • VTK - vtkClipDataSet - Cutting/Slicing • cutting through a dataset with a surface • VTK - vtkCutter - Subsampling • reduces data size by selecting a subset of the original data • VTK - vtkExtractGrid Scientific Visualization Using VTK – Spring 2012
Color Mapping • Scalar Algorithms • Color Mapping • maps scalar data to colors • implemented by using scalar values as an index into a color lookup table • VTK • vtkLookupTable • vtkDataSetMapper Scientific Visualization Using VTK – Spring 2012