Scientific Visualization using VTK Robert Putnam Scientific Visualization with VTK – Fall 2010.

Slides:



Advertisements
Similar presentations
Dr. Will Schroeder, Kitware
Advertisements

Reconstruction from Voxels (GATE-540)
Yingcai Xiao Chapter 6 Fundamental Algorithms. Types of Visualization Transformation Types 1.Data (Attribute Transformation) 2.Topology (Topological Transformation)
Visualization Data Representation Ray Gasser SCV Visualization Workshop – Fall 2008.
Programming for Image Processing/Analysis and Visualization using The Visualization Toolkit Week 5: Image Manipulation and Display Xenios Papademetris.
Scientific Visualization Using ParaView – Fall 2014
ParaView Tutorial Greg Johnson, Karla Vega. Before we begin… Make sure you have ParaView installed so you can follow along in the lab section –
Hank Childs, University of Oregon November 1 st, 2013 Overview of VTK.
CDS 301 Fall, 2009 Scalar Visualization Chap. 5 September 24, 2009 Jie Zhang Copyright ©
Scientific Visualization with ParaView Robert Putnam IS&T Scientific Visualization Tutorial – Spring 2011.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Information Visualization.
Programming for Image Processing/Analysis and Visualization using The Visualization Toolkit Week 4: Surface and Image Manipulation Xenios Papademetris.
Slide 1 Visualization of scientific data under Linux - Techniques and data wrangling Mike Walterman, Manager of Graphics Programming, Scientific Computing.
VTK & ParaView Ray Gasser SCV Visualization Workshop – Fall 2008.
CPS 533 Scientific Visualization Wensheng Shen Department of Computational Science SUNY Brockport.
Programming for Image Processing/Analysis and Visualization using The Visualization Toolkit Xenios Papademetris BML 325,
IS&T Scientific Visualization Tutorial Erik Brisson Introduction to Scientific Visualization.
Scientific Visualization with ParaView Ray Gasser IS&T Scientific Visualization Tutorial – Spring 2010.
Introduction to Volume Visualization Mengxia Zhu Fall 2007.
Scientific Visualization Using VTK – Fall 2011
IS&T Scientific Visualization Tutorial Erik Brisson Introduction to Scientific Visualization.
Programming for Image Processing/Analysis and Visualization using The Visualization Toolkit Week 3: Simple Visualization Tasks Xenios Papademetris
Tool For Visualization, Annotation, and Exploration of Three Dimensional Datasets Tool For Visualization, Annotation, and Exploration of Three Dimensional.
IS&T Scientific Visualization Tutorial – Spring 2010 Robert Putnam Plotting packages overview.
Scientific Visualization with VisIt Eliot Feibush Bum Shik Kim Zach Kaplan PRINCETON PLASMA PHYSICS LABORATORY PICSciE Princeton Institute for Computational.
IS&T Scientific Visualization Tutorial - Summer 2010 Scientific Visualization Tutorial.
ITUppsala universitet Data representation and fundamental algorithms Filip Malmberg
Introduction to Computer Graphics
Outline Data flow networks 101 (3 slides) VTK (20 slides) Contracts (10 slides) An architecture for big data (3 slides)
Visualization Knowledge (VisKo): Leveraging the Semantic Web to Support VisualizationVisKo Nicholas Del Rio CyberShARE Center University of Texas at El.
Scientific Visualization using VTK Ray Gasser IS&T Scientific Visualization Tutorial – Spring 2010.
Interactive Visualization of Volumetric Data on Consumer PC Hardware: Introduction Daniel Weiskopf Graphics Hardware Trends Faster development than Moore’s.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Leicester, February 24, 2005 VisIVO, a VO-Enabled tool for Scientific Visualization and Data Analysis. VO-TECH Project. Stage01 Ugo Becciani INAF – Astrophysical.
lecture 2 : Visualization Basics
Scalar Visualization Chap. 5 September 23, 2008 Jie Zhang Copyright ©
VTK: Data Shroeder et al. Chapter 5 University of Texas – Pan American CSCI 6361, Spring 2014 After Taku Komura and other lecture sets
Scientific Visualization An Introduction Michel O. R. Eboueya Computer Sciences Department Pôle Sciences et Technologies Université de La Rochelle.
Visualization Services Group Steve Cutchin – Manager Amit Chourasia – Visualization Scientist Alex DeCastro – Visualization.
VTK: The Visualization Toolkit Part I: Overview and object models March 28, 2001.
19/18/ :34 Graphics II Volume Rendering Session 10.
CDS 301 Fall, 2009 Vector Visualization Chap. 6 October 7, 2009 Jie Zhang Copyright ©
Marching Cubes: A High Resolution 3D Surface Construction Algorithm William E. Lorenson Harvey E. Cline General Electric Company Corporate Research and.
AVS/Express and VisIt Training NERSC Users meeting June PPPL Cristina Siegerist NERSC/LBNL Visualization group June 13, 2006.
J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001.
VTK. VTK Online Resources On-line Resources VTK –Manual: –Examples:
NA-MIC, 2008 June Workshop, IHK Akademie Westerham VTK
VTK: The Visualization Toolkit Qaiser Chaudry Georgia Institute of Technology June 28, 2006.
Vector Field Visualization
Visualization Knowledge Query Language (VKQL) Workshop Nicholas Del Rio University of Texas at El Paso Computer Science.
IS&T Scientific Visualization Tutorial – Spring 2010
1 Feature Extraction and Visualization of Flow Fields State-of-the-Art Report Feature Extraction and Visualization of Flow Fields Frits.
Data Visualization Fall 2015.
Visualization with ParaView. Before we begin… Make sure you have ParaView 3.14 installed so you can follow along in the lab section –
SCALAR VISUALIZATION. OUTLINE Visualizing scalar data A number of the most popular scalar visualization techniques Color mapping Contouring Height plots.
1 Perception and VR MONT 104S, Fall 2008 Lecture 20 Computer Graphics and VR.
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
67 x 89 = ? 67 x
3D Object Representations 2009, Fall. Introduction What is CG?  Imaging : Representing 2D images  Modeling : Representing 3D objects  Rendering : Constructing.
1 CW11 Visualizing ACE3P Results in ParaView Greg Schussman Menlo Park, CA October 10, 2011.
High school workshop: Scientific visualization ● Universitat de Barcelona ● January 2007.
VisIt Project Overview
VTK: The Visualization Toolkit
Scientific Visualization Using VTK – Summer 2012
ATCM 6317 Procedural Animation
Domain-Modeling Techniques
Outline Data flow networks 101 (3 slides) VTK (20 slides)
Procedural Animation Lecture 10: Volume simulation
Visualization CSE 694L Roger Crawfis The Ohio State University.
Introduction to Scientific Visualization
Presentation transcript:

Scientific Visualization using VTK Robert Putnam Scientific Visualization with VTK – Fall 2010

Outline Introduction VTK overview VTK data geometry/topology Case study Interactive session Scientific Visualization with VTK – Fall 2010

Introduction * Adapted from The ParaView Tutorial, Moreland 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).

VTK Visualization Toolkit –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 with VTK – Fall 2010

Generic visualization pipeline Scientific Visualization with VTK – Fall 2010 Source(s)Filters(s)Output data/geometry/topologygraphics

VTK terminology/model Scientific Visualization with VTK – Fall 2010 SourceFilterRenderer data/geometry/topologygraphics Mapper

VTK terminology/model Scientific Visualization with VTK – Fall 2010 Source/ Reader FilterRenderer data/geometry/topology graphics Mapper “Scene" Lights, Camera DataObjectProcessObject Actor RenderWindow

Pipeline -> Sample Code vtkStructuredGridReader reader reader SetFileName "density.vtk" reader Update vtkContourFilter iso iso SetInputConnection [reader GetOutputPort] iso SetValue 0.26 vtkPolyDataMapper isoMapper isoMapper SetInputConnection [iso GetOutputPort] vtkActor isoActor isoActor SetMapper isoMapper vtkRenderer ren1 ren1 AddActor isoActor vtkRenderWindow renWin renWin AddRenderer ren1 renWin SetSize renWin Render Scientific Visualization with VTK – Fall 2010 Reader Filter Mapper Actor Renderer RenderWindow

TCL v. C++ TCL C++ Scientific Visualization with VTK – Fall 2010 vtkStructuredGridReader reader reader SetFileName "density.vtk" reader Update vtkContourFilter iso iso SetInputConnection [reader GetOutputPort] iso SetValue 0.26 vtkStructuredGridReader *reader = vtkStructuredGridReader::New(); reader->SetFileName("density.vtk"); reader->Update(); vtkContourFilter *iso = vtkCountourFilter::New(); iso->SetInputConnection(reader->GetOutputPort()); iso->SetValue(0,.26);

Coding tip of the day! Google “VTK class list”, or Go to: Scientific Visualization with VTK – Fall 2010

VTK – Geometry v. Topology Geometry of a dataset ~= points Scientific Visualization with VTK – Fall ,11,12,13,1 0,01,02,03,0 Topology ~= connections among points, which define cells So, what’s the topology here?

VTK – Geometry v. Topology Scientific Visualization with VTK – Fall ,11,12,13,1 0,01,02,03,0

VTK – Geometry v. Topology Scientific Visualization with VTK – Fall ,11,12,13,1 0,01,02,03,0 or 0,11,12,13,1 0,01,02,03,0

VTK – Geometry v. Topology Scientific Visualization with VTK – Fall 2010 or 0,11,12,13,1 0,01,02,03,0 0,11,12,13,1 0,01,02,03,0 or 0,11,12,13,1 0,01,02,03,0

VTK – Geometry v. Topology Scientific Visualization with VTK – Fall 2010 or 0,11,12,13,1 0,01,02,03,0 or 0,11,12,13,1 0,01,02,03,0 0,11,12,13,1 0,01,02,03,0 or 0,11,12,13,1 0,01,02,03,0

Geometry/Topology Structure Structure 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 with VTK – Fall 2010

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 Scientific Visualization with VTK – Fall 2010 Data is discrete –Interpolation functions generate data values in between known points

Examples of Dataset Types 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 –examples: quadrilaterals, hexahedron –applications: fluid flow, heat transfer Scientific Visualization with VTK – Fall 2010

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 with VTK – Fall 2010

Examples of Cell Types Scientific Visualization with VTK – Fall 2010

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 with VTK – Fall 2010

File Format – Structured Points Scientific Visualization with VTK – Fall 2010 Editor structured-points.vtk: # vtk DataFile Version 3.0 first dataset ASCII DATASET STRUCTURED_POINTS DIMENSIONS ORIGIN SPACING POINT_DATA 60 SCALARS temp-point float LOOKUP_TABLE default

File Format – Structured Points Scientific Visualization with VTK – Fall 2010 Editor structured-points.vtk: # vtk DataFile Version 3.0 first dataset ASCII DATASET STRUCTURED_POINTS DIMENSIONS ORIGIN SPACING POINT_DATA 60 SCALARS temp-point float LOOKUP_TABLE default

File Format – Structured Points Scientific Visualization with VTK – Fall 2010 Editor structured-points2.vtk: # vtk DataFile Version 3.0 first dataset ASCII DATASET STRUCTURED_POINTS DIMENSIONS ORIGIN SPACING CELL_DATA 24 SCALARS temp-cell float LOOKUP_TABLE default

File Format – Structured Points Scientific Visualization with VTK – Fall 2010 Editor structured-points2.vtk: # vtk DataFile Version 3.0 first dataset ASCII DATASET STRUCTURED_POINTS DIMENSIONS ORIGIN SPACING CELL_DATA 24 SCALARS temp-cell float LOOKUP_TABLE default

Structured Points – Tcl code Scientific Visualization with VTK – Fall 2010 Editor structured-points.tcl: vtkStructuredPointsReader reader reader SetFileName "structured-points.vtk" reader Update vtkLookupTable lut lut SetNumberOfColors 2 lut SetTableValue lut SetTableValue vtkDataSetMapper mapper mapper SetInputConnection [reader GetOutputPort] mapper SetLookupTable lut vtkActor actor actor SetMapper mapper [actor GetProperty] EdgeVisibilityOn [actor GetProperty] SetLineWidth 2

Structured Points – Tcl code (cont.) Scientific Visualization with VTK – Fall 2010 Editor structured-points.tcl: vtkRenderer ren1 ren1 AddActor actor ren1 SetBackground vtkRenderWindow renWin renWin AddRenderer ren1 renWin SetSize vtkRenderWindowInteractor iren iren SetRenderWindow renWin iren Initialize wm withdraw.

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: Scientific Visualization with VTK – Fall 2010 # vtk DataFile Version 3.0 output of reassemble.c BINARY DATASET STRUCTURED_POINTS ORIGIN SPACING DIMENSIONS POINT_DATA SCALARS plasma float LOOKUP_TABLE default

Work flow – Case Study Use Tcl for fast development/testing: Scientific Visualization with VTK – Fall 2010 vtkStructuredPointsReader reader reader SetFileName "opp.vtk" reader Update vtkContourFilter iso iso SetInputConnection \ [reader GetOutputPort] iso SetValue

Work flow – Case Study Add gaussian filter : Scientific Visualization with VTK – Fall 2010 vtkImageGaussianSmooth gaussian gaussian SetInputConnection [reader GetOutputPort] gaussian SetDimensionality 3 gaussian SetRadiusFactor 1 vtkContourFilter iso iso SetInputConnection \ [gaussian GetOutputPort] iso SetValue

Work flow – Case Study Add more isosurfaces : Scientific Visualization with VTK – Fall 2010 vtkContourFilter iso iso SetInputConnection [gaussian GetOutputPort] iso SetValue iso SetValue iso SetValue 2 0.1

Work flow – Case Study Port to C++, add cutplane, transparency : Scientific Visualization with VTK – Fall 2010 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);

Work flow – Case Study Change color map, use script to loop over *.vtk, generate multiple jpegs, read into Adobe Premiere, produce animation: Scientific Visualization with VTK – Fall 2010

VTK – Getting Started - UI Scientific Visualization with VTK – Fall 2010 Unix Shell: katana:% cd ~/materials katana:% vtk cone2.tcl

Keyboard shortcuts Scientific Visualization with VTK – Fall 2010 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 u –command window e –exit

Code – simple.tcl Scientific Visualization with VTK – Fall 2010 Editor: simple.tcl vtkRenderer ren1 ren1 SetBackground vtkRenderWindow renWin renWin SetSize renWin AddRenderer ren1 renWin Render #Suppress the tk window wm withdraw. Unix Shell: katana:% vtk simple.tcl

Exercise Scientific Visualization with VTK – Fall 2010 Editor: simple2.tcl Change background color to gray (or fuchsia, etc.)

Code – Exercise Scientific Visualization with VTK – Fall 2010 Editor: simple2.tcl vtkRenderer ren1 ren1 SetBackground vtkRenderWindow renWin renWin SetSize renWin AddRenderer ren1 renWin Render #Suppress the tk window wm withdraw.

Code – cone.tcl Scientific Visualization with VTK – Fall 2010 Editor cone.tcl: vtkConeSource cone cone SetResolution 100 vtkPolyDataMapper coneMapper coneMapper SetInput [cone GetOutput] vtkActor coneActor coneActor SetMapper coneMapper [coneActor GetProperty] SetColor vtkRenderer ren1 ren1 SetBackground ren1 AddActor coneActor vtkRenderWindow renWin renWin SetSize renWin AddRenderer ren1 renWin Render

Code – cone2.tcl Scientific Visualization with VTK – Fall 2010 Editor cone2.tcl: vtkConeSource cone cone SetResolution 100 vtkPolyDataMapper coneMapper coneMapper SetInput [cone GetOutput] vtkActor coneActor coneActor SetMapper coneMapper [coneActor GetProperty] SetColor vtkRenderer ren1 ren1 SetBackground ren1 AddActor coneActor vtkRenderWindow renWin renWin SetSize renWin AddRenderer ren1 vtkRenderWindowInteractor iren iren SetRenderWindow renWin iren Initialize

Exercise Scientific Visualization with VTK – Fall 2010 Editor: cone3.tcl 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 coneActor2 SetPosition

Code – Exercise Scientific Visualization with VTK – Fall 2010 Editor: cone3.tcl... vtkActor coneActor2 coneActor2 SetMapper coneMapper [coneActor2 GetProperty] SetColor coneActor2 RotateZ 90 coneActor2 SetScale coneActor2 SetPosition ren1 AddActor coneActor ren1 AddActor coneActor2...

VTK - Readers Image and Volume Readers –vtkStructuredPointsReader - read VTK structured points data files –vtkSLCReader - read SLC structured points files –vtkTIFFReader - read files in TIFF format –vtkVolumeReader - read image (volume) files –vtkVolume16Reader - read 16-bit image (volume) files Structured Grid Readers –vtkStructuredGridReader - read VTK structured grid data files –vtkPLOT3DReader - read structured grid PLOT3D files Rectilinear Grid Readers –vtkRectilinearGridReader - read VTK rectilinear grid data files Unstructured Grid Readers –vtkUnstructuredGridReader - read VTK unstructured grid data files Scientific Visualization with VTK – Fall 2010

VTK - Readers Polygonal Data Readers –vtkPolyDataReader - read VTK polygonal data files –vtkBYUReader - read MOVIE.BYU files –vtkMCubesReader - read binary marching cubes files –vtkOBJReader - read Wavefront (Maya).obj files –vtkPLYReader - read Stanford University PLY polygonal data files –vtkSTLReader - read stereo-lithography files –vtkUGFacetReader - read EDS Unigraphic facet files Image and Volume Readers (add’l) –vtkBMPReader - read PC bitmap files –vtkDEMReader - read digital elevation model files –vtkJPEGReader - read JPEG files –vtkImageReader - read various image files –vtkPNMReader - read PNM (ppm, pgm, pbm) files –vtkPNGRReader - read Portable Network Graphic files Scientific Visualization with VTK – Fall 2010

File Format – Structured Grid Scientific Visualization with VTK – Fall 2010 Editor density.vtk: # vtk DataFile Version 3.0 vtk output ASCII DATASET STRUCTURED_GRID DIMENSIONS POINTS float POINT_DATA SCALARS Density float LOOKUP_TABLE default VECTORS Momentum float

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 with VTK – Fall 2010

Code – Clipping Scientific Visualization with VTK – Fall 2010 Editor: clipping.tcl vtkStructuredGridReader reader reader SetFileName “density.vtk” reader Update vtkPlane plane eval plane SetOrigin [[reader GetOutput] GetCenter] plane SetNormal vtkClipDataSet clip clip SetInputConnection [reader GetOutputPort] clip SetClipFunction plane clip InsideOutOn vtkDataSetMapper clipMapper clipMapper SetInputConnection [clip GetOutputPort] eval clipMapper SetScalarRange [[reader GetOutput] GetScalarRange] vtkActor clipActor clipActor SetMapper clipMapper

Code – Cutplane/Slicing Scientific Visualization with VTK – Fall 2010 Editor: cutplane.tcl vtkStructuredGridReader reader reader SetFileName “density.vtk” reader Update vtkPlane plane eval plane SetOrigin [[reader GetOutput] GetCenter] plane SetNormal vtkCutter planeCut planeCut SetInputConnection [reader GetOutputPort] planeCut SetCutFunction plane vtkPolyDataMapper cutMapper cutMapper SetInputConnection [planeCut GetOutputPort] eval cutMapper SetScalarRange [[reader GetOutput] GetScalarRange] vtkActor cutActor cutActor SetMapper cutMapper

Code – ExtractGrid Scientific Visualization with VTK – Fall 2010 Editor: extract.tcl vtkStructuredGridReader reader reader SetFileName “density.vtk” reader Update vtkExtractGrid extract extract SetInputConnection [reader GetOutputPort] extract SetVOI extract SetSampleRate extract IncludeBoundaryOn vtkDataSetMapper mapper mapper SetInputConnection [extract GetOutputPort] eval mapper SetScalarRange [[reader GetOutput] GetScalarRange] vtkActor extractActor extractActor mapper

Color Mapping Scalar Algorithms –Color Mapping maps scalar data to colors implemented by using scalar values as an index into a color lookup table specify a HSVA (Hue-Saturation-Value-Alpha) ramp and then generate the colors in the table by using linear interpolation into the HSVA space. –VTK vtkLookupTable vtkDataSetMapper Scientific Visualization with VTK – Fall 2010

Code – Color Mapping Scientific Visualization with VTK – Fall 2010 Editor: colormap.numcolors.tcl... vtkLookupTable lut lut SetNumberofColors 16 lut SetHueRange lut Build vtkStructuredGridReader reader reader SetFileName “subset.vtk” reader Update vtkDataSetMapper mapper mapper SetInputConnection [reader GetOutputPort] mapper SetLookupTable lut eval mapper SetScalarRange [[reader GetOutput] GetScalarRange] vtkActor actor actor SetMapper mapper...

Exercise Scientific Visualization with VTK – Fall 2010 * Change the number of colors in colormap * Reverse the Hue Range * Change the Scalar Range mapper SetScalarRange

Contouring Scalar Algorithms (cont) –Contouring construct a boundary between distinct regions, two steps: –explore space to find points near contour –connect points into contour (2D) or surface (3D) 2D contour map (isoline): –applications: elevation contours from topography, pressure contours (weather maps) from meteorology 3D isosurface: 3D isosurface: –applications: tissue surfaces from tomography, constant pressure or temperature in fluid flow, implicit surfaces from math and CAD –VTK vtkContourFilter Scientific Visualization with VTK – Fall 2010

Code – Contour (isoline) Scientific Visualization with VTK – Fall 2010 Editor: contour.single.tcl... vtkStructuredGridReader reader reader SetFileName “subset.vtk” reader Update vtkContourFilter contour contour SetInputConnection [reader GetOutputPort] contour SetValue vtkPolyDataMapper contourMapper contourMapper SetInputConnection [contour GetOutputPort] eval contourMapper SetScalarRange [[reader GetOutput] GetScalarRange] vtkActor contourActor contourActor SetMapper contourMapper...

Code – Contour (isosurface) Scientific Visualization with VTK – Fall 2010 Editor: isosurface.tcl... vtkStructuredGridReader reader reader SetFileName “density.vtk” reader Update vtkContourFilter iso iso SetInputConnection [reader GetOutputPort] iso SetValue vtkPolyDataMapper isoMapper isoMapper SetInputConnection [iso GetOutputPort] eval isoMapper SetScalarRange [[reader GetOutput] GetScalarRange] vtkActor isoActor isoActor SetMapper isoMapper...

Scalar Generation Scalar Algorithms (cont) –Scalar Generation extract scalars from part of data example: extracting z coordinate (elevation) from terrain data to create scalar values –VTK vtkElevationFilter Scientific Visualization with VTK – Fall 2010

Code – Scalar Generation Scientific Visualization with VTK – Fall 2010 Editor: hawaii.color.tcl vtkPolyDataReader hawaii hawaii SetFileName "honolulu.vtk" hawaii Update vtkElevationFilter elevation elevation SetInput [hawaii GetOutput] elevation SetLowPoint elevation SetHighPoint elevation SetScalarRange vtkLookupTable lut lut SetHueRange vtkDataSetMapper hawaiiMapper hawaiiMapper SetInput [elevation GetOutput] hawaiiMapper SetScalarRange hawaiiMapper SetLookupTable lut vtkActor hawaiiActor hawaiiActor SetMapper hawaiiMapper

Scalar generation – Color Map Scientific Visualization with VTK – Fall 2010 Editor: hawaii.color2.tcl vtkLookupTable lut lut SetNumberOfColors 9 lut SetTableValue lut SetTableValue lut SetTableValue lut SetTableValue lut SetTableValue lut SetTableValue lut SetTableValue lut SetTableValue lut SetTableValue

Hedgehogs Vector Algorithms –Hedgehogs oriented scaled line for each vector scale indicates magnitude color indicates magnitude, pressure, temperature, or any variable –VTK vtkHedgeHog Scientific Visualization with VTK – Fall 2010

Code – HedgeHogs Scientific Visualization with VTK – Fall 2010 Editor: hedgehog.tcl vtkStructuredGridReader reader reader SetFileName “density.vtk” reader Update vtkHedgeHog hhog hhog SetInput [reader GetOutput] hhog SetScaleFactor vtkPolyDataMapper hhogMapper hhogMapper SetInput [hhog GetOutput] hhogMapper SetLookupTable lut eval hhogMapper SetScalarRange [[reader GetOutput] GetScalarRange] vtkActor hhogActor hhogActor SetMapper hhogMapper

Oriented Glyphs Vector Algorithms (cont) –Oriented Glyphs orientation indicates direction scale indicates magnitude color indicates magnitude, pressure, temperature, or any variable –VTK vtkGlyph3D Scientific Visualization with VTK – Fall 2010

Code – Oriented Glyphs Scientific Visualization with VTK – Fall 2010 Editor: glyph.tcl vtkArrowSource arrow arrow SetTipResolution 6 arrow SetTipRadius 0.1 arrow SetTipLength 0.35 arrow SetShaftResolution 6 arrow SetShaftRadius 0.03 vtkGlyph3D glyph glyph SetInput [reader GetOutputPort] glyph SetSource [arrow GetOutputPort] glyph SetVectorModeToUseVector glyph SetColorModeToColorByScalar glyph SetScaleModeToDataScalingOff glyph OrientOn glyph SetScaleFactor 0.2 vtkPolyDataMapper glyphMapper glyphMapper SetInput [glyph GetOutput] glyphMapper SetLookupTable lut glyphMapper ScalarVisibilityOn eval glyphMapper SetScalarRange [[reader GetOutput] GetScalarRange]

Field Lines Vector Algorithms (cont) –Field Lines Fluid flow is described by a vector field in three dimensions for steady (fixed time) flows or four dimensions for unsteady (time varying) flows Three techniques for determining flow –Pathline (Trace) tracks particle through unsteady (time-varying) flow shows particle trajectories over time rake releases particles from multiple positions at the same time instant reveals compression, vorticity –Streamline tracks particle through steady (fixed-time) flow holds flow steady at a fixed time snapshot of flow at a given time instant –Streakline particles released from the same position over a time interval (time-varying) snapshot of the variation of flow over time example: dye steadily injected into fluid at a fixed point Scientific Visualization with VTK – Fall 2010

Field Lines Streamlines Lines show particle flow VTK – vtkStreamTracer Streamlets half way between streamlines and glyphs VTK - vtkStreamTracer, vtkGlyph3D Streamribbon rake of two particles to create a ribbon VTK - vtkStreamTracer, vtkRuledSurfaceFilter Streamtube circular rake of particles to create a tube VTK - vtkStreamTracer, vtkTubeFilter Scientific Visualization with VTK – Fall 2010

Code – Streamlines Scientific Visualization with VTK – Fall 2010 Editor: streamLines.tcl vtkPointSource seeds seeds SetRadius 3.0 eval seeds SetCenter [[reader GetOutput] GetCenter] seeds SetNumberOfPoints 100 vtkRungeKutta4 integ vtkStreamTracer streamer streamer SetInputConnection [reader GetOutputPort] streamer SetSourceConnection [seeds GetOutputPort] streamer SetMaximumPropagation 100 streamer SetMaximumPropagationUnitToTimeUnit streamer SetInitialIntegrationStepUnitToCellLengthUnit streamer SetInitialIntegrationStep 0.1 streamer SetIntegrationDirectionToBoth streamer SetIntegrator integ vtkPolyDataMapper mapStreamLines mapStreamLines SetInputConnection [streamer GetOutputPort] eval mapStreamLines SetScalarRange [[reader GetOutput] GetScalarRange] vtkActor streamLineActor streamLineActor SetMapper mapStreamLines

Code – Streamtubes Scientific Visualization with VTK – Fall 2010 Editor: streamTubes.varyRadius.tcl vtkPointSource seeds seeds SetRadius 1.0 seeds SetNumberOfPoints 50 vtkRungeKutta4 integ vtkStreamTracer streamer streamer SetInputConnection [reader GetOutputPort] streamer SetSourceConnection [seeds GetOutputPort]... vtkTubeFilter streamTube streamTube SetInputConnection [streamer GetOutputPort] streamTube SetRadius 0.01 streamTube SetNumberOfSides 6 # streamTube SetVaryRadiusToVaryRadiusOff streamTube SetVaryRadiusToVaryRadiusByScalar vtkPolyDataMapper mapStreamTube mapStreamTube SetInputConnection [streamTube GetOutputPort] mapStreamTube SetLookupTable lut eval mapStreamTube SetScalarRange [[[[reader GetOutput] GetPointData] GetScalars] GetRange] vtkActor streamTubeActor streamTubeActor SetMapper mapStreamTube [streamTubeActor GetProperty] BackfaceCullingOn

Annotation Annotation –used for annotating visualization –VTK vtkScalarBarActor vtkTextMapper vtkScaledTextActor Scientific Visualization with VTK – Fall 2010

Code – colorBar Scientific Visualization with VTK – Fall 2010 Editor: colorBar.tcl vtkStructuredGridReader reader reader SetFileName “density.vtk” reader Update vtkScalarBarActor scalarBar scalarBar SetLookupTable lut scalarBar SetTitle "Combustor Density Magnitude" scalarBar SetNumberOfLabels 2 [scalarBar GetPositionCoordinate] SetValue scalarBar SetOrientationToHorizontal scalarBar SetWidth 0.8 scalarBar SetHeight 0.09 vtkRenderer ren1 vtkRenderWindow renWin renWin AddRenderer ren1 vtkRenderWindowInteractor iren iren SetRenderWindow renWin ren1 AddActor streamTubeActor ren1 AddActor outlineActor ren1 AddActor scalarBar ren1 SetBackground

VTK - Writers Polygonal Data Writers –vtkBYUWriter - write MOVIE.BYU files –vtkCGMWriter - write 2D polygonal data as a CGM file –vtkIVWriter - write Inventor files –vtkMCubesWriter - write triangles in marching cubes format –vtkPolyDataWriter - write VTK polygonal data files –vtkPLYWriter - write Standford University PLY polygonal data files –vtkSTLWriter - write stereo-lithography files Image and Volume writers –vtkBMPwriter - write PC bitmap files –vtkJPEGwriter - write images in JPEG format –vtkPostscriptWriter – write image files in Postscript format –vtkPNMwriter - write PNM (ppm, pgm, pbm) image files –vtkPNGwriter - write image file in Portable Network Graphic format –vtkTIFFWriter – write image files in TIFF format –vtkStructuredPointsWriter – write a vtkStructuredPoints file Scientific Visualization with VTK – Fall 2010

Saving Images –common formats: jpeg (lossy) png (lossless) postscript tiff (lossless) –VTK vtkWindowToImageFilter vtkRenderLargeImage Scientific Visualization with VTK – Fall 2010

Code – Saving Images Scientific Visualization with VTK – Fall 2010 Editor: output.tcl renWin Render vtkWindowToImageFilter w2if w2if SetInput renWin w2if Update vtkRenderLargeImage renderLarge renderLarge SetInput ren1 renderLarge SetMagnification 4 #vtkJPEGWriter writer # writer SetInputConnection [w2if GetOutputPort] # writer SetFileName "image.jpg" # writer SetQuality 100 # writer Write #vtkPNGWriter writer # writer SetInputConnection [w2if GetOutputPort] # writer SetFileName "image.png" # writer Write #vtkPostScriptWriter writer # writer SetInputConnection [w2if GetOutputPort] # writer SetFileName "image.ps" # writer Write #vtkTIFFWriter writer # writer SetInputConnection [w2if GetOutputPort] # writer SetFileName "image.tif" # writer Write vtkTIFFWriter lwriter lwriter SetInputConnection [renderLarge GetOutputPort] lwriter SetFileName "largeimage.tif" lwriter Write

VTK - Resources Scientific Visualization with VTK – Fall 2010 IS&T tutorials –Scientific Visualization with VTK –VTK Examples Texts –The Visualization Toolkit, 4th Edition, Kitware, Inc, –The VTK User’s Guide, 5th Edition, Kitware, Inc, Websites – – – Wiki – Mailing Lists –

Questions? Tutorial survey: - Scientific Visualization with VTK – Fall 2010