2. VTK
• VTK stands for Visualization tool kit
•Act or process of interpreting in visual terms or
of putting into visual form.
• in other words, transformation of data or
information into picture.
•Example : Weather forecasting maps
C4console.com
4. How to create VTK file?
various ways to create VTK file like C++, Java,
Python and so on.
Import header file or standard library file and
simple use them.
C4console.com
5. Create cone file using VTK
Step 1: Header file
first include the required header files for the vtk
classes we are using like for cone,
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h“
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h“
C4console.com
6. Create cone file using VTK
Step 2: Source
In our case, source is a cone.
Next we create an instance of vtkConeSource
and set some of its properties.
Is a source process object means with no input.
Part of visualization pipeline.
Only produces data of output type is
vtkpolydata. Which other filter may process.
C4console.com
8. Create cone file using VTK
Step : filter
Process with both input and output.
Filter will be process object with at least one
input and one output (intermediate data store will
not be represented)
C4console.com
9. Create cone file using VTK
Step : intermediate filter
Output of source should be behave as input for
mapper by using these filter.
Source mapper
Intermediate filter
(Vtk shrink polydata filter)
C4console.com
10. Create cone file using VTK
Step 3: mapper
Now we create an instance of mapper to map
the polygonal data into graphics primitives.
declared in vtkploydatamapper.h header file.
also known as sink.
Process that consume data with no output.
Because these process map data to a final
image or output.
C4console.com
11. Create cone file using
VTK>mapper
Step 3: mapper
// create instance of mapper
vtkPolyDataMapper *coneMapper =
vtkPolyDataMapper::New();
// output of source into mapper
coneMapper->SetInputConnection( cone-
>GetOutputPort() );
C4console.com
12. Pipeline
Consist of object to represent,
•Data object
•Process Object
•Arrow connection object
C4console.com
13. Pipeline topology
Element of pipeline: Source, filter and mapper to
create visualization pipeline or network
C4console.com
14. Pipeline issue
Mostly 2 important issue that arises when we
use pipeline
1. Type
2. Multiplicity
Type :
means the form or type of data that process
object take as input or generate output.
For ex: Sphere, cone
C4console.com
16. Create cone file using VTK
Step 4: actor
Previously, we create source and set properties
and then map them now, we represent the cone.
Actor rendering of the mapper's graphics
primitives.
An actor also refers to properties via a
vtkProperty instance, and includes an internal
transformation matrix.
We set this actor's mapper to be coneMapper
which we created previous.
C4console.com
17. Create cone file using
VTK>actor
Step 4: actor
// set mapper graphics into actor for
represent
vtkActor *coneActor = vtkActor::New();
coneActor->SetMapper( coneMapper );
C4console.com
18. Create cone file using VTK
Step 5: rendering
Render is the process to convert data as input
and converted into graphics or pictorial
representation.
A renderer is like a viewport.
It is part or all of a window on the screen and it
is
responsible for drawing the actors it has.
also set the background color here.
C4console.com
19. Create cone file using
VTK>render
Step 5: rendering
// create render object
vtkRenderer *ren1= vtkRenderer::New();
// add render with actor
ren1->AddActor( coneActor );
// set background
ren1->SetBackground( 0.1, 0.2, 0.4 );
C4console.com
20. Create cone file using VTK
Step 6: rendering window
Now, finally show output in screen by
using renderwindow.h header file .
we put our renderer into the render window
using AddRenderer.
C4console.com
22. Create cone file using
Step 7: delete
Now we free OS memory or to release
resource by using delete() function.
cone->Delete();
coneMapper->Delete();
coneActor->Delete();
ren1->Delete();
renWin->Delete();
C4console.com
23. Result
When we configure and generate .cxx file
then we get following result like,
C4console.com