VTK The Visualization Toolkit Qaiser Chaudry Georgia Institute
- Slides: 25
VTK: The Visualization Toolkit Qaiser Chaudry Georgia Institute of Technology June 28, 2006
Visualization Box ?
What is VTK? • An open source, freely available software system for 3 D graphics, image processing, and visualization. • Support for hundreds of algorithms in visualization and image processing • Object-oriented design with different interpreted language wrapers.
At a Glance • The core of VTK is written entirely in C++ • Contains 600 existing classes with 325 K lines of code • VTK will compile and run on Windows 98/NT, SGI, Linux, Sun, HP, etc. • Supports Open. GL • Different interfaces for fast prototyping: Tcl , Java, and Python • Has users all over the world – The beauty of Open Source!
System Architecture Interpreted Wrapper (Tcl, Java, Python) • Tcl/Tk shell • Java interpreter • Python interpreter • Tcl/Tk source • Java JDK • Python source C++ core Libraries and includes All class source code (could take hours to (dll and. h files) compile) Or (. a and. h files) Binary Installation: if you will use the classes to build your applicatoin Source code Installation: If you want to extend vtk
VTK classes
The Graphics Model The purpose is to render the geometry (volume) on the screen vtk. Camera vtk. Render. Window. Interactor vtk. Actor vtk. Light • vtk. Property • vtk. Mapper • vtk. Transform vtk. Renderer
To see is to believe … 1 vtk. Render. Window 2 vtk. Renderer vtk. Camera vtk. Light vtk. Actor ( property, geometry(mapper), transformation, etc)
The Graphics Model The purpose is to render the geometry (volume) on the screen camera Actor screen Light
Example Program Main() { create a window; create a renderer; give the renderer to the window; create procedural geometry; create a mapper; give the geometry to the mapper; create an actor; give the mapper to the actor; } give the actor to the renderer; window->render(); Window Renderer Actor Mapper Geometry
Example -1 • • A polygonal model of a cone Render to screen. Rotate the cone 360 degrees source -> mapper -> actor -> renderer -> renderwindow
Example -1 // First include the required header files for the VTK classes we are using. #include "vtk. Cone. Source. h" #include "vtk. Poly. Data. Mapper. h" #include "vtk. Render. Window. h" #include "vtk. Camera. h" #include "vtk. Actor. h" #include "vtk. Renderer. h“ int main( int argc, char *argv[] ) { // Create an instance of vtk. Cone. Source *cone = vtk. Cone. Source: : New(); cone->Set. Height( 3. 0 ); cone->Set. Radius( 1. 0 ); cone->Set. Resolution( 10 );
Example -1 // We create an instance of vtk. Poly. Data. Mapper *cone. Mapper = vtk. Poly. Data. Mapper: : New(); cone. Mapper->Set. Input( cone->Get. Output() ); // Create an actor. vtk. Actor *cone. Actor = vtk. Actor: : New(); cone. Actor->Set. Mapper( cone. Mapper ); // Create the renderer. vtk. Renderer *ren 1= vtk. Renderer: : New(); ren 1 ->Add. Actor( cone. Actor ); ren 1 ->Set. Background( 0. 1, 0. 2, 0. 4 ); // Finally we create the render window. vtk. Render. Window *ren. Win = vtk. Render. Window: : New(); ren. Win->Add. Renderer( ren 1 ); ren. Win->Set. Size( 300, 300 );
Example -1 // Now we loop over 360 degrees and render the cone each time. int i; for (i = 0; i < 360; ++i) { // Render the image. ren. Win->Render(); // Rotate the active camera by one degree. ren 1 ->Get. Active. Camera()->Azimuth( 1 ); // Introduce delay to slow down motion. Sleep(10); } // Free up any objects we created. cone->Delete(); cone. Mapper->Delete(); cone. Actor->Delete(); ren 1 ->Delete(); ren. Win->Delete(); return 0; }
Creating Multiple Renderers vtk. Renderer *ren 1= vtk. Renderer: : New(); ren 1 ->Add. Actor( cone. Actor ); ren 1 ->Set. Background( 0. 1, 0. 2, 0. 4 ); ren 1 ->Set. Viewport(0. 0, 0. 5, 1. 0); vtk. Renderer *ren 2= vtk. Renderer: : New(); ren 2 ->Add. Actor( cone. Actor ); ren 2 ->Set. Background( 0. 2, 0. 3, 0. 5 ); ren 2 ->Set. Viewport(0. 5, 0. 0, 1. 0); vtk. Render. Window *ren. Win = vtk. Render. Window: : New(); ren. Win->Add. Renderer( ren 1 ); ren. Win->Add. Renderer( ren 2 ); ren. Win->Set. Size( 600, 300 );
Creating Multiple Renderers // Make one view 90 degrees from the other. ren 1 ->Get. Active. Camera()->Azimuth(90); // Now we loop over 360 degrees and render the cone each time. int i; for (i = 0; i < 360; ++i) { // render the image ren. Win->Render(); // rotate the active camera by one degree ren 1 ->Get. Active. Camera()->Azimuth( 1 ); ren 2 ->Get. Active. Camera()->Azimuth( 1 ); Sleep(10); }
Properties and Transformation // Create an actor to represent the first cone. The actor's properties are modified to give it different surface properties. By default, an actor is created with a property so the Get. Property() method can be used. vtk. Actor *cone. Actor = vtk. Actor: : New(); cone. Actor->Set. Mapper( cone. Mapper ); cone. Actor->Get. Property()->Set. Color(0. 2, 0. 63, 0. 79); cone. Actor->Get. Property()->Set. Diffuse(0. 7); cone. Actor->Get. Property()->Set. Specular(0. 4); cone. Actor->Get. Property()->Set. Specular. Power(20);
Properties and Transformation // Create a property and directly manipulate it. Assign it to the second actor. vtk. Property *property = vtk. Property: : New(); property->Set. Color(1. 0, 0. 3882, 0. 2784); property->Set. Diffuse(0. 7); property->Set. Specular(0. 4); property->Set. Specular. Power(20); vtk. Actor *cone. Actor 2 = vtk. Actor: : New(); cone. Actor 2 ->Set. Mapper(cone. Mapper); cone. Actor 2 ->Get. Property()->Set. Color(0. 2, 0. 63, 0. 79); cone. Actor 2 ->Set. Property(property); cone. Actor 2 ->Set. Position(0, 3, 0);
Properties and Transformation // Create the renderer and assign actors to it. vtk. Renderer *ren 1= vtk. Renderer: : New(); ren 1 ->Add. Actor( cone. Actor 2 ); ren 1 ->Set. Background( 0. 1, 0. 2, 0. 4 );
User interaction • vtk. Render. Window. Interactor – allow the user to interact with the graphics objects • • w: wireframe mode s: surface mode r: reset the transformation e: exit • • Left Button: rotate Right Button: zoom
User interaction // The vtk. Render. Window. Interactor class watches for events (e. g. , keypress, mouse) in the vtk. Render. Window. Interactor *iren = vtk. Render. Window. Interactor: : New(); iren->Set. Render. Window(ren. Win); // Here we specify a particular interactor style. vtk. Interactor. Style. Trackball. Camera *style = vtk. Interactor. Style. Trackball. Camera: : New(); iren->Set. Interactor. Style(style); // Leave an event loop running. Exit when the user presses the "e" key. iren->Initialize(); iren->Start();
TCL Vs C++ package require vtk. Cone. Source cone Set. Height 3. 0 cone Set. Radius 1. 0 cone Set. Resolution 10 #include "vtk. Cone. Source. h" #include "vtk. Poly. Data. Mapper. h" #include "vtk. Render. Window. h" #include "vtk. Camera. h" #include "vtk. Actor. h" #include "vtk. Renderer. h" int main( int argc, char *argv[] ){ vtk. Cone. Source *cone = vtk. Cone. Source: : New(); cone->Set. Height( 3. 0 ); cone->Set. Radius( 1. 0 ); cone->Set. Resolution( 10 ); vtk. Poly. Data. Mapper *cone. Mapper = vtk. Poly. Data. Mapper: : New(); cone. Mapper->Set. Input( cone->Get. Output() ); vtk. Poly. Data. Mapper cone. Mapper Set. Input [cone Get. Output] vtk. Actor *cone. Actor = vtk. Actor: : New(); cone. Actor->Set. Mapper( cone. Mapper ); vtk. Actor cone. Actor Set. Mapper cone. Mapper vtk. Renderer *ren 1= vtk. Renderer: : New(); ren 1 ->Add. Actor( cone. Actor ); ren 1 ->Set. Background( 0. 1, 0. 2, 0. 4 ); vtk. Renderer ren 1 Add. Actor cone. Actor ren 1 Set. Background 0. 1 0. 2 0. 4 vtk. Render. Window ren. Win Add. Renderer ren 1 ren. Win Set. Size 300 for {set i 0} {$i < 360} {incr i} { after 10 ren. Win Render [ren 1 Get. Active. Camera] Azimuth 1 } vtk. Command Delete. All. Objects exit vtk. Render. Window *ren. Win = vtk. Render. Window: : New(); ren. Win->Add. Renderer( ren 1 ); ren. Win->Set. Size( 300, 300 ); int i; for (i = 0; i < 360; ++i) { Sleep(10); ren. Win->Render(); ren 1 ->Get. Active. Camera()->Azimuth( 1 ); } cone->Delete(); cone. Mapper->Delete(); cone. Actor->Delete(); ren 1 ->Delete(); ren. Win->Delete(); return 0; }
Demos • Diffuse Lighting • Modeling • Volume Rendering • 3 D Model Motor • Medical imaging
What is ITK? National Library of Medicine Insight Segmentation and Registration Toolkit (ITK) • Image Processing • Segmentation • Registration • No Graphical User Interface (GUI) • No Visualization
References • www. cse. ohio-state. edu/~hwshen/788/sp 01/ • http: //www. kitware. com/ • http: //www. vtk. org/ • The VTK Users's Guide • The Visualization Toolkit An Object-Oriented Approach To 3 D Graphics 3 rd Edition • http: //www. itk. org/
- Qaiser abbas md
- The visualization toolkit
- Google visualization toolkit
- Vtk structured grid example
- Vtk interactor style
- Vtk srbija
- Itk vtk
- Vtk chicago
- Vtk text
- Vtk github
- Pell institute
- Respect institute of georgia
- Thang điểm glasgow
- Bổ thể
- ưu thế lai là gì
- Thẻ vin
- Cái miệng nó xinh thế
- Thơ thất ngôn tứ tuyệt đường luật
- Các châu lục và đại dương trên thế giới
- Từ ngữ thể hiện lòng nhân hậu
- Diễn thế sinh thái là
- Tư thế ngồi viết
- Ví dụ giọng cùng tên
- Phép trừ bù
- Hát lên người ơi
- Hổ đẻ mỗi lứa mấy con