html5-img
1 / 25

VTK: The Visualization Toolkit

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 3D graphics, image processing, and visualization.

konala
Télécharger la présentation

VTK: The Visualization Toolkit

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.

E N D

Presentation Transcript


  1. VTK: The Visualization Toolkit Qaiser Chaudry Georgia Institute of Technology June 28, 2006

  2. Visualization Box ?

  3. What is VTK? • An open source, freely available software system for 3D graphics, image processing, and visualization. • Support for hundreds of algorithms in visualization and image processing • Object-oriented design with different interpreted language wrapers.

  4. At a Glance • The core of VTK is written entirely in C++ • Contains 600 existing classes with 325K lines of code • VTK will compile and run on Windows 98/NT, SGI, Linux, Sun, HP, etc. • Supports OpenGL • Different interfaces for fast prototyping: Tcl , Java, and Python • Has users all over the world – The beauty of Open Source!

  5. Interpreted Wrapper (Tcl, Java, Python) • Tcl/Tk shell • Java interpreter • Python interpreter • Tcl/Tk source • Java JDK • Python source C++ core All class source code (could take hours to compile) Libraries and includes (dll and .h files) 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 System Architecture

  6. VTK classes

  7. The Graphics Model The purpose is to render the geometry (volume) on the screen vtkCamera vtkActor • vtkProperty • vtkMapper • vtkTransform vtkLight vtkRenderWindow vtkRenderer vtkRenderWindowInteractor

  8. To see is to believe … 1 vtkRenderWindow vtkCamera 2 vtkRenderer vtkLight vtkActor ( property, geometry(mapper), transformation, etc)

  9. camera Light screen Actor The Graphics Model The purpose is to render the geometry (volume) on the screen

  10. 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

  11. Example -1 • A polygonal model of a cone • Render to screen. • Rotate the cone 360 degrees • source -> mapper -> actor -> renderer -> renderwindow

  12. Example -1 // First include the required header files for the VTK classes we are using. #include "vtkConeSource.h" #include "vtkPolyDataMapper.h" #include "vtkRenderWindow.h" #include "vtkCamera.h" #include "vtkActor.h" #include "vtkRenderer.h“ int main( int argc, char *argv[] ) { // Create an instance of vtkConeSource. vtkConeSource *cone = vtkConeSource::New(); cone->SetHeight( 3.0 ); cone->SetRadius( 1.0 ); cone->SetResolution( 10 );

  13. Example -1 // We create an instance of vtkPolyDataMapper vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New(); coneMapper->SetInput( cone->GetOutput() ); // Create an actor. vtkActor *coneActor = vtkActor::New(); coneActor->SetMapper( coneMapper ); // Create the renderer. vtkRenderer *ren1= vtkRenderer::New(); ren1->AddActor( coneActor ); ren1->SetBackground( 0.1, 0.2, 0.4 ); // Finally we create the render window. vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer( ren1 ); renWin->SetSize( 300, 300 );

  14. 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. renWin->Render(); // Rotate the active camera by one degree. ren1->GetActiveCamera()->Azimuth( 1 ); // Introduce delay to slow down motion. Sleep(10); } // Free up any objects we created. cone->Delete(); coneMapper->Delete(); coneActor->Delete(); ren1->Delete(); renWin->Delete(); return 0; }

  15. Creating Multiple Renderers vtkRenderer *ren1= vtkRenderer::New(); ren1->AddActor( coneActor ); ren1->SetBackground( 0.1, 0.2, 0.4 ); ren1->SetViewport(0.0, 0.0, 0.5, 1.0); vtkRenderer *ren2= vtkRenderer::New(); ren2->AddActor( coneActor ); ren2->SetBackground( 0.2, 0.3, 0.5 ); ren2->SetViewport(0.5, 0.0, 1.0, 1.0); vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer( ren1 ); renWin->AddRenderer( ren2 ); renWin->SetSize( 600, 300 );

  16. Creating Multiple Renderers // Make one view 90 degrees from the other. ren1->GetActiveCamera()->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 renWin->Render(); // rotate the active camera by one degree ren1->GetActiveCamera()->Azimuth( 1 ); ren2->GetActiveCamera()->Azimuth( 1 ); Sleep(10); }

  17. 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 GetProperty() method can be used. vtkActor *coneActor = vtkActor::New(); coneActor->SetMapper( coneMapper ); coneActor->GetProperty()->SetColor(0.2, 0.63, 0.79); coneActor->GetProperty()->SetDiffuse(0.7); coneActor->GetProperty()->SetSpecular(0.4); coneActor->GetProperty()->SetSpecularPower(20);

  18. Properties and Transformation // Create a property and directly manipulate it. Assign it to the second actor. vtkProperty *property = vtkProperty::New(); property->SetColor(1.0, 0.3882, 0.2784); property->SetDiffuse(0.7); property->SetSpecular(0.4); property->SetSpecularPower(20); vtkActor *coneActor2 = vtkActor::New(); coneActor2->SetMapper(coneMapper); coneActor2->GetProperty()->SetColor(0.2, 0.63, 0.79); coneActor2->SetProperty(property); coneActor2->SetPosition(0, 3, 0);

  19. Properties and Transformation // Create the renderer and assign actors to it. vtkRenderer *ren1= vtkRenderer::New(); ren1->AddActor( coneActor ); ren1->AddActor( coneActor2 ); ren1->SetBackground( 0.1, 0.2, 0.4 );

  20. User interaction • vtkRenderWindowInteractor – 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

  21. User interaction // The vtkRenderWindowInteractor class watches for events (e.g., keypress, mouse) in the vtkRenderWindow. vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); // Here we specify a particular interactor style. vtkInteractorStyleTrackballCamera *style = vtkInteractorStyleTrackballCamera::New(); iren->SetInteractorStyle(style); // Leave an event loop running. Exit when the user presses the "e" key. iren->Initialize(); iren->Start();

  22. TCL Vs C++ #include "vtkConeSource.h" #include "vtkPolyDataMapper.h" #include "vtkRenderWindow.h" #include "vtkCamera.h" #include "vtkActor.h" #include "vtkRenderer.h" int main( int argc, char *argv[] ){ vtkConeSource *cone = vtkConeSource::New(); cone->SetHeight( 3.0 ); cone->SetRadius( 1.0 ); cone->SetResolution( 10 ); vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New(); coneMapper->SetInput( cone->GetOutput() ); vtkActor *coneActor = vtkActor::New(); coneActor->SetMapper( coneMapper ); vtkRenderer *ren1= vtkRenderer::New(); ren1->AddActor( coneActor ); ren1->SetBackground( 0.1, 0.2, 0.4 ); vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer( ren1 ); renWin->SetSize( 300, 300 ); int i; for (i = 0; i < 360; ++i) { Sleep(10); renWin->Render(); ren1->GetActiveCamera()->Azimuth( 1 ); } cone->Delete(); coneMapper->Delete(); coneActor->Delete(); ren1->Delete(); renWin->Delete(); return 0;} package require vtk vtkConeSource cone cone SetHeight 3.0 cone SetRadius 1.0 cone SetResolution 10 vtkPolyDataMapper coneMapper coneMapper SetInput [cone GetOutput] vtkActor coneActor coneActor SetMapper coneMapper vtkRenderer ren1 ren1 AddActor coneActor ren1 SetBackground 0.1 0.2 0.4 vtkRenderWindow renWin renWin AddRenderer ren1 renWin SetSize 300 300 for {set i 0} {$i < 360} {incr i} { after 10 renWin Render [ren1 GetActiveCamera] Azimuth 1 } vtkCommand DeleteAllObjects exit

  23. Demos • Diffuse Lighting • Modeling • Volume Rendering • 3D Model Motor • Medical imaging

  24. What is ITK? National Library of Medicine Insight Segmentation and Registration Toolkit (ITK) • Image Processing • Segmentation • Registration • No Graphical User Interface (GUI) • No Visualization

  25. References • www.cse.ohio-state.edu/~hwshen/788/sp01/ • http://www.kitware.com/ • http://www.vtk.org/ • The VTK Users's Guide • The Visualization Toolkit An Object-Oriented Approach To 3D Graphics 3rd Edition • http://www.itk.org/

More Related