The Visualization Toolkit (VTK) Overview. The Visualization Toolkit An Overview William J. Schroeder...
-
Upload
darcy-cole -
Category
Documents
-
view
291 -
download
6
Transcript of The Visualization Toolkit (VTK) Overview. The Visualization Toolkit An Overview William J. Schroeder...
The Visualization Toolkit (VTK)The Visualization Toolkit (VTK)
Overview
The Visualization ToolkitThe Visualization ToolkitAn OverviewAn Overview
William J. SchroederWilliam J. Schroeder
Kitware, Inc.Kitware, Inc.
AgendaAgenda
• VTK TechnologyVTK Technology– BackgroundBackground– The Graphics ModelThe Graphics Model– The Visualization ModelThe Visualization Model– Volume RenderingVolume Rendering
• VTK ProcessVTK Process– Open SourceOpen Source– Development ProcessDevelopment Process
AgendaAgenda
• VTK TechnologyVTK Technology– BackgroundBackground– The Graphics ModelThe Graphics Model– The Visualization ModelThe Visualization Model– Volume RenderingVolume Rendering
• VTK ProcessVTK Process– Open SourceOpen Source– Development ProcessDevelopment Process
VisualizationVisualization
A definition for visualizationA definition for visualization– Map data or information into images or other Map data or information into images or other
sensory input (touch, sound, smell, taste)sensory input (touch, sound, smell, taste)– Engages human perception systemEngages human perception system– Simple, effective powerfulSimple, effective powerful
• Complex data• Voluminous data
Related FieldsRelated Fields
– MappingMapping
– 3D Graphics3D Graphics
– Volume RenderingVolume Rendering
– Haptics (touch)Haptics (touch)
– Gaming / Gaming / EntertainmentEntertainment
– 3D GUI’s3D GUI’s
– Virtual RealityVirtual Reality
– MappingMapping
– 3D Graphics3D Graphics
– Volume RenderingVolume Rendering
– Haptics (touch)Haptics (touch)
– Gaming / Gaming / EntertainmentEntertainment
– 3D GUI’s3D GUI’s
– Virtual RealityVirtual Reality
• VisualizationVisualization- Scientific- Scientific- Information- Information- Financial- Financial- Data- Data- Multivariate- Multivariate
• Image ProcessingImage Processing
• 2D Graphics2D Graphics
• Statistical GraphicsStatistical Graphics
• VisualizationVisualization- Scientific- Scientific- Information- Information- Financial- Financial- Data- Data- Multivariate- Multivariate
• Image ProcessingImage Processing
• 2D Graphics2D Graphics
• Statistical GraphicsStatistical Graphics
Example ApplicationsExample Applications
Scientific, medical, financial, information, ...Scientific, medical, financial, information, ...Scientific, medical, financial, information, ...Scientific, medical, financial, information, ...
Simulation
MedicalCT / MRI / Ultrasound
Business
Modeling
Example ApplicationsExample Applications
Geophysical / MappingGeophysical / MappingGeophysical / MappingGeophysical / Mapping
TrendsTrends
• The 3D Graphics Market is ExplodingThe 3D Graphics Market is Exploding– Gaming driving the hardwareGaming driving the hardware– VRML, Web applicationsVRML, Web applications– Virtual RealityVirtual Reality– Graphics standards (OpenGL, Direct3D)Graphics standards (OpenGL, Direct3D)– Digital / 3D DataDigital / 3D Data
• Data is overwhelming usersData is overwhelming users– Visualization is a proven solutionVisualization is a proven solution
• Open Source systems are credibleOpen Source systems are credible– Even respectableEven respectable
TextbookTextbook
Now in Second EditionNow in Second EditionNow in Second EditionNow in Second Edition
The Visualization ToolkitAn Object-Oriented Approach To 3D GraphicsWill Schroeder, Ken Martin, Bill LorensenISBN 0-13-954694-4Prentice Hall
Work on first edition began in 1994
What Is VTK?What Is VTK?
A visualization A visualization toolkittoolkit
– Designed and implemented using object-oriented Designed and implemented using object-oriented principlesprinciples
– C++ class library (250,000 LOC, <100,000 C++ class library (250,000 LOC, <100,000 executable lines)executable lines)
– AutomatedAutomated Java, TCL, Python bindings Java, TCL, Python bindings
– Portable across Unix, Windows9x/NTPortable across Unix, Windows9x/NT
– Supports 3D/2D graphics, visualization, image Supports 3D/2D graphics, visualization, image processing, volume renderingprocessing, volume rendering
A visualization A visualization toolkittoolkit
– Designed and implemented using object-oriented Designed and implemented using object-oriented principlesprinciples
– C++ class library (250,000 LOC, <100,000 C++ class library (250,000 LOC, <100,000 executable lines)executable lines)
– AutomatedAutomated Java, TCL, Python bindings Java, TCL, Python bindings
– Portable across Unix, Windows9x/NTPortable across Unix, Windows9x/NT
– Supports 3D/2D graphics, visualization, image Supports 3D/2D graphics, visualization, image processing, volume renderingprocessing, volume rendering
Other FeaturesOther Features
• Reference CountingReference Counting• Abstract / Virtual Method AccessAbstract / Virtual Method Access
– data stored in native type (byte, short, int, etc.)data stored in native type (byte, short, int, etc.)– data accessed in native type (with templates) or data accessed in native type (with templates) or
using generic interface (float)using generic interface (float)
• Data In MemoryData In Memory– some objects read pieces (vtkSliceCubes)some objects read pieces (vtkSliceCubes)– data pipeline can stream pieces based on memory data pipeline can stream pieces based on memory
limitations (more later)limitations (more later)
VTK Is Not a SystemVTK Is Not a System
• EmbeddableEmbeddable– Plays with other softwarePlays with other software
• SeparableSeparable– Can pull out “pieces”Can pull out “pieces”
• AdaptableAdaptable– Not dependent on GUINot dependent on GUI– Not dependent on rendering libraryNot dependent on rendering library
VTK ArchitectureVTK Architecture
Hybrid approachHybrid approach– compiled C++ (faster algorithms)compiled C++ (faster algorithms)– interpreted applications (rapid development)interpreted applications (rapid development)
(Java, Tcl, Python)(Java, Tcl, Python)– A A toolkittoolkit
C++core
Interpreter
Interpreted layergenerated automatically
InterpretersInterpreters
• TclTcl• JavaJava• PythonPython
InterpretersInterpreters provide faster turn-around; provide faster turn-around;
suffer from slower executionsuffer from slower execution
Tcl InterpreterTcl Interpreter
• source vtkInt.tcl (define interpreter GUI)source vtkInt.tcl (define interpreter GUI)
AgendaAgenda
• VTK TechnologyVTK Technology– BackgroundBackground– The Graphics ModelThe Graphics Model– The Visualization ModelThe Visualization Model– Volume RenderingVolume Rendering
• VTK ProcessVTK Process– Open SourceOpen Source– Development ProcessDevelopment Process
Graphics ModelGraphics Model
Instances of render window (vtkRenderWindow)
Actor instances(vtkActor)
Renderer instances(vtkRenderer)
Graphics ModelGraphics Model
• RenderWindow - contains final imageRenderWindow - contains final image• Renderer - Renderer - draws into render windowdraws into render window• Actor - Actor - combines properties / geometry combines properties / geometry • Lights - illuminate actorsLights - illuminate actors• Camera - renders sceneCamera - renders scene• Mappers - represent geometryMappers - represent geometry• Transformations - position actorsTransformations - position actors
In Context: The Scene GraphIn Context: The Scene Graph
Group
Coords ShapeProperty
Transform
Separator
AgendaAgenda
• VTK TechnologyVTK Technology– BackgroundBackground– The Graphics ModelThe Graphics Model– The Visualization ModelThe Visualization Model– Volume RenderingVolume Rendering
• VTK ProcessVTK Process– Open SourceOpen Source– Development ProcessDevelopment Process
What Is The Visualization What Is The Visualization Pipeline?Pipeline?
A sequence of A sequence of process objectsprocess objects that operate on that operate on data data objectsobjects to generate geometry that can be rendered to generate geometry that can be rendered by the graphics engineby the graphics engine
Data
Filter
Data to graphicssystem
Data
Data Filter Actor
ActorMapper
Mapper
Source
Visualization ModelVisualization Model
• Data ObjectsData Objects– represent datarepresent data– provide access to dataprovide access to data– compute information particular to datacompute information particular to data
(e.g., bounding box, derivatives)(e.g., bounding box, derivatives)
• Process ObjectsProcess Objects– Ingest, transform, and output data objectsIngest, transform, and output data objects– represent visualization algorithmsrepresent visualization algorithms
Data ObjectsData Objects
• Represent a “blob” of dataRepresent a “blob” of data– contain instance of vtkFieldDatacontain instance of vtkFieldData– an array of arraysan array of arrays– no geometric/topological structureno geometric/topological structure– typically not used in pipelines (but its subclasses such typically not used in pipelines (but its subclasses such
as vtkDataSet are)as vtkDataSet are)
• Can be converted to vtkDataSetCan be converted to vtkDataSet– vtkDataObjectToDataSetFiltervtkDataObjectToDataSetFilter– advanced topic (see financialField.tcl)advanced topic (see financialField.tcl)
Data Objects / Data SetsData Objects / Data Sets
• vtkDataObject is a “blob” of datavtkDataObject is a “blob” of data– Contains an instance of vtkFieldDataContains an instance of vtkFieldData
• vtkDataSet is data with geometric & topological vtkDataSet is data with geometric & topological structure; and with structure; and with attributeattribute data data
Geometry& Topology
Data SetAttributes
Points& Cells
Point DataCell Data
Dataset ModelDataset Model
• A dataset is a data object with structureA dataset is a data object with structure
• Structure consists ofStructure consists of– cells (e.g., polygons, lines, voxels)cells (e.g., polygons, lines, voxels)– points (x-y-z coordinates)points (x-y-z coordinates)– cells defined by connectivity list referring to pointscells defined by connectivity list referring to points– implicit representationsimplicit representations– explicit representationsexplicit representations
Cell
Points
Dataset TypesDataset Types
vtkPolyData
vtkStructuredPoints
vtkStructuredGrid
vtkUnstructuredGrid
vtkRectilinearGrid
Data Set AttributesData Set Attributes
• ScalarsScalars - 1-4 values ( - 1-4 values (vtkScalarsvtkScalars))– single value ranging to RGBA colorsingle value ranging to RGBA color
• VectorsVectors - 3-vector ( - 3-vector (vtkVectorsvtkVectors))• TensorsTensors - 3x3 symmetric matrix ( - 3x3 symmetric matrix (vtkTensorsvtkTensors))• NormalsNormals - unit vector ( - unit vector (vtkNormalsvtkNormals))• Texture CoordinatesTexture Coordinates 1-3D ( 1-3D (vtkTCoordsvtkTCoords))• Field DataField Data (an array of arrays) ( (an array of arrays) (vtkFieldDatavtkFieldData))
Process ObjectsProcess Objects
Source
Mapper
Filter1 or more outputs
1 or more outputs
1 or more inputs
1 or more inputs
Pipeline Execution ModelPipeline Execution Model
direction of update (via Update())
Source
Data
Filter
Data
MapperRender()
direction of data flow (via Execute())
Creating Pipeline TopologyCreating Pipeline Topology
• aFilter->aFilter->SetInputSetInput( bFilter->( bFilter->GetOutputGetOutput());());
• The Role of Type-CheckingThe Role of Type-Checking– SetInput() accepts dataset type or subclassSetInput() accepts dataset type or subclass– C++ compile-time checkingC++ compile-time checking– Interpreter run-time checkingInterpreter run-time checking
• Decimation, smoothing, normalsDecimation, smoothing, normals• Implemented in C++Implemented in C++
Example PipelineExample Pipeline
vtkSmoothPolyDataFilter
vtkDecimatePro
vtkCyberReader
vtkPolyDataNormals
vtkPolyDataMapper
Note: data objects are notshown -> they are impliedfrom the output type of thefilter
Create Reader & DecimatorCreate Reader & Decimator
vtkCyberReader *cyber = vtkCyberReader::New();vtkCyberReader *cyber = vtkCyberReader::New(); cyber->SetFileName("../../vtkdata/fran_cut”); cyber->SetFileName("../../vtkdata/fran_cut”);
vtkDecimatePro *deci = vtkDecimatePro::New();vtkDecimatePro *deci = vtkDecimatePro::New(); deci->SetInput( cyber->GetOutput() ); deci->SetInput( cyber->GetOutput() ); deci->SetTargetReduction( 0.9 ); deci->SetTargetReduction( 0.9 ); deci->PreserveTopologyOn(); deci->PreserveTopologyOn(); deci->SetMaximumError( 0.0002 ); deci->SetMaximumError( 0.0002 );
vtkCyberReader *cyber = vtkCyberReader::New();vtkCyberReader *cyber = vtkCyberReader::New(); cyber->SetFileName("../../vtkdata/fran_cut”); cyber->SetFileName("../../vtkdata/fran_cut”);
vtkDecimatePro *deci = vtkDecimatePro::New();vtkDecimatePro *deci = vtkDecimatePro::New(); deci->SetInput( cyber->GetOutput() ); deci->SetInput( cyber->GetOutput() ); deci->SetTargetReduction( 0.9 ); deci->SetTargetReduction( 0.9 ); deci->PreserveTopologyOn(); deci->PreserveTopologyOn(); deci->SetMaximumError( 0.0002 ); deci->SetMaximumError( 0.0002 );
Smoother & Graphics ObjectsSmoother & Graphics Objects
vtkSmoothPolyDataFilter *smooth = vtkSmoothPolyDataFilter::New();vtkSmoothPolyDataFilter *smooth = vtkSmoothPolyDataFilter::New(); smooth->SetInput(deci->GetOutput()); smooth->SetInput(deci->GetOutput()); smooth->SetNumberOfIterations( 20 ); smooth->SetNumberOfIterations( 20 ); smooth->SetRelaxationFactor( 0.05 ); smooth->SetRelaxationFactor( 0.05 );
vtkPolyDataNormals *normals = vtkPolyDataNormals::New();vtkPolyDataNormals *normals = vtkPolyDataNormals::New(); normals->SetInput( smooth->GetOutput() ); normals->SetInput( smooth->GetOutput() );
vtkPolyDataMapper *cyberMapper = vtkPolyDataMapper::New();vtkPolyDataMapper *cyberMapper = vtkPolyDataMapper::New(); cyberMapper->SetInput( normals->GetOutput() ); cyberMapper->SetInput( normals->GetOutput() );
vtkActor *cyberActor = vtkActor::New();vtkActor *cyberActor = vtkActor::New(); cyberActor->SetMapper (cyberMapper); cyberActor->SetMapper (cyberMapper); cyberActor->GetProperty()->SetColor ( 1.0, 0.49, 0.25 ); cyberActor->GetProperty()->SetColor ( 1.0, 0.49, 0.25 ); cyberActor->GetProperty()->SetRepresentationToWireframe(); cyberActor->GetProperty()->SetRepresentationToWireframe();
vtkSmoothPolyDataFilter *smooth = vtkSmoothPolyDataFilter::New();vtkSmoothPolyDataFilter *smooth = vtkSmoothPolyDataFilter::New(); smooth->SetInput(deci->GetOutput()); smooth->SetInput(deci->GetOutput()); smooth->SetNumberOfIterations( 20 ); smooth->SetNumberOfIterations( 20 ); smooth->SetRelaxationFactor( 0.05 ); smooth->SetRelaxationFactor( 0.05 );
vtkPolyDataNormals *normals = vtkPolyDataNormals::New();vtkPolyDataNormals *normals = vtkPolyDataNormals::New(); normals->SetInput( smooth->GetOutput() ); normals->SetInput( smooth->GetOutput() );
vtkPolyDataMapper *cyberMapper = vtkPolyDataMapper::New();vtkPolyDataMapper *cyberMapper = vtkPolyDataMapper::New(); cyberMapper->SetInput( normals->GetOutput() ); cyberMapper->SetInput( normals->GetOutput() );
vtkActor *cyberActor = vtkActor::New();vtkActor *cyberActor = vtkActor::New(); cyberActor->SetMapper (cyberMapper); cyberActor->SetMapper (cyberMapper); cyberActor->GetProperty()->SetColor ( 1.0, 0.49, 0.25 ); cyberActor->GetProperty()->SetColor ( 1.0, 0.49, 0.25 ); cyberActor->GetProperty()->SetRepresentationToWireframe(); cyberActor->GetProperty()->SetRepresentationToWireframe();
More Graphics ObjectsMore Graphics Objects
vtkRenderer *ren1 = vtkRenderer::New();vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New(); vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer( ren1 );renWin->AddRenderer( ren1 );
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor ::New();vtkRenderWindowInteractor ::New(); iren->SetRenderWindow( renWin ); iren->SetRenderWindow( renWin );
ren1->AddActor( cyberActor );ren1->AddActor( cyberActor );ren1->SetBackground( 1, 1, 1 );ren1->SetBackground( 1, 1, 1 );renWin->SetSize( 500, 500 );renWin->SetSize( 500, 500 );
iren->Start();iren->Start();
vtkRenderer *ren1 = vtkRenderer::New();vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New(); vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer( ren1 );renWin->AddRenderer( ren1 );
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor ::New();vtkRenderWindowInteractor ::New(); iren->SetRenderWindow( renWin ); iren->SetRenderWindow( renWin );
ren1->AddActor( cyberActor );ren1->AddActor( cyberActor );ren1->SetBackground( 1, 1, 1 );ren1->SetBackground( 1, 1, 1 );renWin->SetSize( 500, 500 );renWin->SetSize( 500, 500 );
iren->Start();iren->Start();
ResultsResults
Before(52,260 triangles)
After Decimationand Smoothing(7,477 triangles)
Filter Overview: SourcesFilter Overview: Sources
ReadersReaders• vtkOBJReadervtkOBJReader
• vtkBYUReadervtkBYUReader
• vtkCyberReadervtkCyberReader
• vtkDataSetReadervtkDataSetReader
• vtkMCubesReadervtkMCubesReader
• vtkPLOT3DReadervtkPLOT3DReader
• vtkPolyDataReadervtkPolyDataReader
• vtkRectilinearGridReadervtkRectilinearGridReader
• vtkSLCReader• vtkSTLReader• vtkStructuredGridReader• vtkStructuredPointsReader• vtkUnstructuredGridReader• vtkVolume16Reader• vtkFieldDataReader• vtkBMPReader• vtkPNMReader• vtkTIFFReader
SourcesSources
Procedural SourcesProcedural Sources• vtkEarthSourcevtkEarthSource
• vtkConeSourcevtkConeSource
• vtkCylinderSourcevtkCylinderSource
• vtkDiskSourcevtkDiskSource
• vtkLineSourcevtkLineSource
• vtkOutlineSourcevtkOutlineSource
• vtkPlaneSourcevtkPlaneSource
• vtkPointSourcevtkPointSource
• vtkTextSourcevtkTextSource
• vtkVectorTextvtkVectorText
• vtkSphereSource• vtkTexturedSphereSource• vtkAxes• vtkCursor3D• vtkProgrammableSource• vtkPointLoad
FiltersFilters
• vtkAppendFilter vtkAppendFilter
• vtkAppendPolyData vtkAppendPolyData
• vtkBooleanTexturevtkBooleanTexture
• vtkBrownianPointsvtkBrownianPoints
• vtkCastToConcretevtkCastToConcrete
• vtkCellCentersvtkCellCenters
• vtkCellDataToPointData vtkCellDataToPointData
• vtkCullVisiblePoints vtkCullVisiblePoints
• vtkCleanPolyDatavtkCleanPolyData
• vtkClipPolyDatavtkClipPolyData
• vtkClipVolume• vtkConnectivityFilter• vtkContourFilter• vtkCutter• vtkDashedStreamLine• vtkDecimate• vtkDecimatePro• vtkDelaunay2D• vtkDelaunay3D• vtkDicers
Filters (2)Filters (2)
• vtkEdgePointsvtkEdgePoints
• vtkElevationFiltervtkElevationFilter
• vtkExtractEdgesvtkExtractEdges
• vtkExtractGeometryvtkExtractGeometry
• vtkExtractGridvtkExtractGrid
• vtkExtractTensorComponentsvtkExtractTensorComponents
• vtkExtractUnstructuredGridvtkExtractUnstructuredGrid
• vtkExtractVOIvtkExtractVOI
• vtkExtractVectorComponentsvtkExtractVectorComponents
• vtkFeatureEdgesvtkFeatureEdges
• vtkGaussianSplatter• vtkGeometryFilter• vtkGlyph3D• vtkHedgeHog• vtkHyperStreamline• vtkIdFilter• vtkLinearExtrusionFilter• vtkMaskPolyData• vtkOutlineFilter• vtkPointDataToCellData
Filters (3)Filters (3)
• vtkMaskPoints• vtkMaskPolyData• vtkMergeFilter• vtkMergePoints• vtkPolyDataNormals• vtkProbeFilter• vtkProgrammableAttributeDataFilter• vtkSelectVisiblePoints• vtkSpatialRepresentationFilter• vtkStreamLine
• vtkProgrammableFiltervtkProgrammableFilter
• vtkProjectedTexturevtkProjectedTexture
• vtkRecursiveDividingCubesvtkRecursiveDividingCubes
• vtkReverseSensevtkReverseSense
• vtkRibbonFiltervtkRibbonFilter
• vtkRotationalExtrusionFiltervtkRotationalExtrusionFilter
• vtkShepardMethodvtkShepardMethod
• vtkShrinkFiltervtkShrinkFilter
• vtkShrinkPolyDatavtkShrinkPolyData
• vtkSmoothPolyDataFiltervtkSmoothPolyDataFilter
Filters (4)Filters (4)
• vtkStreamPointsvtkStreamPoints
• vtkStrippervtkStripper
• vtkStructuredGridGeometryFiltervtkStructuredGridGeometryFilter
• vtkStructuredGridOutlineFiltervtkStructuredGridOutlineFilter
• vtkStructuredPointsGeometryFiltervtkStructuredPointsGeometryFilter
• vtkTensorGlyphvtkTensorGlyph
• vtkTextureMapToBoxvtkTextureMapToBox
• vtkTextureMapToCylindervtkTextureMapToCylinder
• vtkTextureMapToPlanevtkTextureMapToPlane
• vtkTextureMapToSpherevtkTextureMapToSphere
• vtkTexturedSphereSource• vtkThreshold• vtkThresholdPoints• vtkThresholdTextureCoords• vtkTransformFilter• vtkTransformPolyDataFilter• vtkTransformTextureCoords• vtkTriangleFilter• vtkTriangularTCoords• vtkTriangularTexture
Filters (5)Filters (5)
• vtkTubeFiltervtkTubeFilter
• vtkVectorDotvtkVectorDot
• vtkVectorNormvtkVectorNorm
• vtkVectorTopologyvtkVectorTopology
• vtkVoxelModellervtkVoxelModeller
• vtkWarpScalarvtkWarpScalar
• vtkWarpTovtkWarpTo
• vtkWarpVector vtkWarpVector
MappersMappers
Writers• vtkIVWriter• vtkBYUWriter• vtkSTLWriter• vtkMCubesWriter• vtkPolyDataWriter• vtkRectilinearGridWriter• vtkStructuredGridWriter• vtkStructuredPointsWriter• vtkUnstructuredGridWriter• vtkFieldDataWriter• vtkBMPWriter
• vtkPNMWriter• vtkTIFFWriter
Graphics Mappers• vtkPolyDataMapper• vtkDataSetMapper• (volume mappers - later)• (image mappers - later)
Data ManagementData Management
Why Data Management is Critical - SizeWhy Data Management is Critical - Size– Medical imaging (512x512x100x2 = 50Meg)Medical imaging (512x512x100x2 = 50Meg)– Scientific visualizationScientific visualization– Video data (fluoroscope, ultrasound)Video data (fluoroscope, ultrasound)– Digital X-rayDigital X-ray– Satellite imagerySatellite imagery
Data ManagementData Management
• Visible Woman CT DataVisible Woman CT Data 870 MBytes 1734 Slices at 512x512x2870 MBytes 1734 Slices at 512x512x2
• Visible Woman CT DataVisible Woman CT Data 870 MBytes 1734 Slices at 512x512x2870 MBytes 1734 Slices at 512x512x2
Flow Computation: Flow Computation: Robert Meakin Robert Meakin Visualization: Visualization: David Kenwright and David Kenwright and David Lane David Lane Numerical Aerodynamic Numerical Aerodynamic Simulation Division at Simulation Division at NASA Ames Research NASA Ames Research CenterCenter
• Bell-Boeing V-2 2 tiltrotor 140 Gbytes
• Bell-Boeing V-2 2 tiltrotor 140 Gbytes
ExamplesExamples
• Modeling turbulence (Ken Jansen RPI)Modeling turbulence (Ken Jansen RPI)• 8.5 million tetrahedra, 200 time steps8.5 million tetrahedra, 200 time steps• 150 million tetrahedra, 2000 time steps (soon)150 million tetrahedra, 2000 time steps (soon)
Reference CountingReference Counting
Data Reader Elevation Filter Rendering System
- Scalar Values- 3D points- 3D normals
- New Scalar Values- 3D points- 3D normals
Reference Counting
Memory HierarchyMemory Hierarchy
Processor(Registers)
L1 DiskL2Main
MemoryTape
Access Time
0.5 Clock
1 Clock
5 Clock
10-50 Clock
105 Clock
107 Clock
Memory HierarchyMemory Hierarchy
• Depending on disk and tape is to be avoidedDepending on disk and tape is to be avoided
• A lot of instructions can be carried out in the A lot of instructions can be carried out in the time a single disk access occurstime a single disk access occurs
• Better through-put occurs when data is kept Better through-put occurs when data is kept in high-levels of memory hierarchyin high-levels of memory hierarchy
Enter (The) Streaming PipelineEnter (The) Streaming Pipeline
• Read data from disk/tape in piecesRead data from disk/tape in pieces
• Process piece through series of filters (supports a Process piece through series of filters (supports a data flow architecture)data flow architecture)
• Only when processing is complete is data written Only when processing is complete is data written back to disk/tapeback to disk/tape
• Control piece size to make best use of memory Control piece size to make best use of memory hierarchy (e.g., avoid swapping)hierarchy (e.g., avoid swapping)
Streaming DataStreaming Data• Data is broken into pieces, and pieces processed one Data is broken into pieces, and pieces processed one
at a timeat a time– Piece size based on memory limitsPiece size based on memory limits
– Can avoid system swapCan avoid system swap
– Supports parallel processingSupports parallel processing
– IssuesIssues
• How to create pieces
• Mapping output from input
• Results invarianceFilter
Multi-ThreadingMulti-Threading
Piece
Sub-Piece
Entire Data
Numerical ExperimantsNumerical ExperimantsvtkImageReader
vtkImageMagnify
vtkImageGradient
vtkImageShrink
vtkImageReader
vtkImageCast
vtkImageMagnify
vtkImageGauss-ianSmooth
vtkImageGradient
vtkImageEuclid-eanToPolar
vtkImageCon-stantPad
vtkImageExtract-Components
vtkImageHSV-ToRGB
vtkImageReader
vtkImageCast
vtkImageFFT
vtkImageRFFT
vtkImageIdeal-HighPass
vtkImageButter-worthHighPass
vtkImageExtract-Components
vtkImageExtract-Components
vtkImageRFFT
The Effect of Cache SizeThe Effect of Cache Size
AgendaAgenda
• VTK TechnologyVTK Technology– BackgroundBackground– The Graphics ModelThe Graphics Model– The Visualization ModelThe Visualization Model– Volume RenderingVolume Rendering
• VTK ProcessVTK Process– Open SourceOpen Source– Development ProcessDevelopment Process
The Volume Data StructureThe Volume Data Structure
3D RegularRectilinear Grid
vtkStructuredPoints:Dimensions = (Dx, Dy, Dz)Spacing = (Sx, Sy, Sz)
Volume Rendering StrategiesVolume Rendering Strategies
Image-Order ApproachImage-Order Approach: Traverse the image : Traverse the image pixel-by-pixel and sample the volume via pixel-by-pixel and sample the volume via ray-casting.ray-casting.
Ray CastingRay Casting
Volume Rendering StrategiesVolume Rendering Strategies
Object-Order ApproachObject-Order Approach: Traverse the volume, : Traverse the volume, and project to the image plane.and project to the image plane.
SplattingSplattingcell-by-cellcell-by-cell
Texture MappingTexture Mappingplane-by-planeplane-by-plane
Transfer Functions Transfer Functions
Transfer functions are the key to volume renderingsTransfer functions are the key to volume renderings
Ray Casting ProcessRay Casting Process
Ray Cast FunctionsRay Cast Functions
Ray DistanceRay Distance
Sca
lar
Valu
eS
cala
r V
alu
e
A A Ray FunctionRay Function examines the scalar examines the scalar values encountered along a ray, and values encountered along a ray, and produces a final pixel value according produces a final pixel value according to the volume properties, and the to the volume properties, and the specific transfer function.specific transfer function.
Scalar Value InterpolationScalar Value Interpolation
v = v = (1-x)(1-y)(1-z)S(0,0,0) +(1-x)(1-y)(1-z)S(0,0,0) +
(x)(1-y)(1-z)S(1,0,0) +(x)(1-y)(1-z)S(1,0,0) +
(1-x)(y)(1-z)S(0,1,0) +(1-x)(y)(1-z)S(0,1,0) +
(x)(y)(1-z)S(1,1,0) +(x)(y)(1-z)S(1,1,0) +
(1-x)(1-y)(z)S(0,0,1) +(1-x)(1-y)(z)S(0,0,1) +
(x)(1-y)(z)S(1,0,1) +(x)(1-y)(z)S(1,0,1) +
(1-x)(y)(z)S(0,1,1) +(1-x)(y)(z)S(0,1,1) +
(x)(y)(z)S(1,1,1)(x)(y)(z)S(1,1,1)
x
yz
(0,0,0)
(1,1,1)
v = S(rnd(x), rnd(y), rnd(z))
Nearest Neighbor Trilinear
Scalar Value InterpolationScalar Value Interpolation
Nearest NeighborNearest NeighborInterpolationInterpolation
TrilinearTrilinearInterpolationInterpolation
Maximum Intensity FunctionMaximum Intensity Function
Ray DistanceRay DistanceSca
lar
Valu
eS
cala
r V
alu
e
Scalar ValueScalar Value
Op
aci
tyO
paci
ty
Maximize Scalar ValueMaximize Scalar Value
Maximum ValueMaximum Value
Gradient MagnitudeGradient Magnitude
Op
aci
tyO
paci
ty
Composite FunctionComposite Function
Ray DistanceRay DistanceSca
lar
Valu
eS
cala
r V
alu
e
Scalar ValueScalar Value
Op
aci
tyO
paci
ty
Use Use -blending along the ray -blending along the ray to produce final RGBA value to produce final RGBA value for each pixel.for each pixel.
Gradient MagnitudeGradient Magnitude
Op
aci
tyO
paci
ty
Isosurface FunctionIsosurface Function
Ray DistanceRay Distance
Sca
lar
Valu
eS
cala
r V
alu
e Isosurface ValueIsosurface Value
Stop ray traversal Stop ray traversal at isosurface value. at isosurface value. Use cubic equation Use cubic equation solver if solver if interpolation is interpolation is trilinear.trilinear.
Sampling DistanceSampling Distance
0.1 Unit0.1 UnitStep SizeStep Size
1.0 Unit1.0 UnitStep SizeStep Size
2.0 Unit2.0 UnitStep SizeStep Size
Intermixing GeometryIntermixing Geometry
Render the Render the geometry geometry (opaque, (opaque,
then then translucent) translucent)
using the using the graphics graphics hardwarehardware
Capture the Capture the hardware hardware color and color and
depth depth buffersbuffers
z value
Cast the Cast the rays, rays,
stopping at stopping at the the
captured captured depth value depth value
for that for that pixelpixel
Blend the Blend the ray RGBA ray RGBA value into value into the color the color
image and image and draw to the draw to the hardware hardware
color buffercolor buffer
Intermixed GeometryIntermixed Geometry
High potential High potential iron proteiniron protein
CT scan of the CT scan of the visible visible
woman's kneewoman's knee
Speed / Accuracy Trade-OffSpeed / Accuracy Trade-Off
1x1 Sampling1x1 Sampling 2x2 Sampling2x2 Sampling 4x4 Sampling4x4 Sampling
Combined approached: vtkLODProp3D can be used to hold mappers of various types. A volume can be represented at multiple levels-of-detail using a geometric isosurface, texture mapping, and ray casting. A decision between levels-of-detail is made based on allocated render time.
Multi-resolution ray casting:
AgendaAgenda
• VTK TechnologyVTK Technology– BackgroundBackground– The Graphics ModelThe Graphics Model– The Visualization ModelThe Visualization Model– Volume RenderingVolume Rendering
• VTK ProcessVTK Process– Open SourceOpen Source– Development ProcessDevelopment Process
Why Open Source?Why Open Source?
• FunFun– form communitiesform communities– engage in a hobby / learning experienceengage in a hobby / learning experience
• ProfitableProfitable - successful business models - successful business models– Red Hat, Inc. (Linux Support)Red Hat, Inc. (Linux Support)– Cygnus SolutionsCygnus Solutions– Use Value versus Sale Value (service-oriented Use Value versus Sale Value (service-oriented
business model)business model)
• AltruismAltruism - serve the planet - serve the planet
Why Open Source?Why Open Source?
• Kick M$’s ButtKick M$’s Butt
• Intellectual freedomIntellectual freedom– Ideas are propertyIdeas are property– The territory is being claimedThe territory is being claimed– Freedom of expression is being controlled by Freedom of expression is being controlled by
othersothers– Don’t give up your freedom!Don’t give up your freedom!
Why Open Source? Why Open Source?
• Scalable Software DevelopmentScalable Software Development– Eric Raymond Eric Raymond The Cathedral & The BazaarThe Cathedral & The Bazaar
““open-source peer review is the only open-source peer review is the only scalable method for achieving high scalable method for achieving high reliability and quality.”reliability and quality.”
• Microsoft Halloween DocumentsMicrosoft Halloween Documents– www.www.opensource.orgopensource.org
AgendaAgenda
• VTK TechnologyVTK Technology– BackgroundBackground– The Graphics ModelThe Graphics Model– The Visualization ModelThe Visualization Model– Volume RenderingVolume Rendering
• VTK ProcessVTK Process– Open SourceOpen Source– Development ProcessDevelopment Process
Development ProcessDevelopment Process
• Standard C++ Style / MethodologyStandard C++ Style / Methodology• Documentation embedded in code (use Documentation embedded in code (use
Doxygen to generated HTML)Doxygen to generated HTML)• Use CVS source code control systemUse CVS source code control system
– Allows simultaneous editsAllows simultaneous edits– Merges files, flags conflictsMerges files, flags conflicts
• Automatic wrapper generator (look at SWIG)Automatic wrapper generator (look at SWIG)• Daily regression testingDaily regression testing
Testing Process (Nightly)Testing Process (Nightly)
• Regression test ~500 examplesRegression test ~500 examples• Check styleCheck style• Check PrintSelf()Check PrintSelf()• Check memory problems (Purify)Check memory problems (Purify)
– Read/write beyond memory boundsRead/write beyond memory bounds– Memory leaksMemory leaks
• Check CoverageCheck Coverage– Running around 75%Running around 75%– If it ain’t covered, it don’t workIf it ain’t covered, it don’t work
Regression TestingRegression Testing
• Compare generated image against standard Compare generated image against standard “correct” image“correct” image– pixel-by-pixel comparisonpixel-by-pixel comparison– can use a threshold metriccan use a threshold metric– adjusted for effects like ditheringadjusted for effects like dithering– OpenGL is rather loose about image qualityOpenGL is rather loose about image quality
VTK Quality DashboardVTK Quality Dashboard
Why Test Daily?Why Test Daily?
• Large code base too large for any single Large code base too large for any single developer to understanddeveloper to understand
• Developers distributed around the worldDevelopers distributed around the world• Identify problems as they occurIdentify problems as they occur• Insure that object API remains unchangedInsure that object API remains unchanged• Provide feedback to developers as they Provide feedback to developers as they
experiment with new implementationsexperiment with new implementations
ResourcesResources
• VTKVTK– www.kitware.com/vtk.htmlwww.kitware.com/vtk.html– vtkusers mailing listvtkusers mailing list– other resources (Sebastien Barre’s web pages)other resources (Sebastien Barre’s web pages)
• Eric Raymond Eric Raymond The Cathedral and the BazaarThe Cathedral and the Bazaar
• CVS DocumentationCVS Documentation
• www.opensource.orgwww.opensource.org