Você está na página 1de 77

Scientific visualisation in 2D and 3D

Roman Putanowicz
R.Putanowicz@L5.pk.edu.pl
Some rights reserved (CC) 2010. See License slide.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

Right tool for the right job

gnuplot All sorts of 2D visualisation and simple 3D visualisation

octave More advanced 2D visualisations that require extensive


data manipulations

octave + octaviz Simple 3D programming

VTK Advanced computer graphics and 3D programming

ParaView, OpenDX 3D visualisations

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

Part I
Gnuplot Overview

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

Gnuplot

Home page: http://www.gnuplot.info/

Portable: MS Windows, GNU/Linux, UNIX, and OSX.

Book: Gnuplot in Action. Understanding Data with Graphs,


Philipp K. Janert, Manning Publications Co., 2009

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

Plotting functions given by formulas

1
2

f(x) = 1/(1+(x*sin(x))**2)
plot f(x)

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

Axes setup

1
2
3
4
5

f(x) = 1/(1+(x*sin(x))**2)
plot f(x)
set xrange[-5:5]
set yrange[0:1.3]
replot

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

Labels and graph tytle

1
2
3
4
5
6
7
8
9

f(x) = 1/(1+(x*sin(x))**2)
plot f(x)
set xrange[-5:5]
set yrange[0:1.3]
set xlabel "Temperature [K]"
set ylabel "Distance [m]"
set title \
"Temperature distribution"
replot

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

Setting lines and markers style

1
2
3
4
5
6
7
8
9
10

f(x) = 1/(1+(x*sin(x))**2)
set xrange[-5:5]
set yrange[0:1.3]
set xlabel "Temperature [K]"
set ylabel "Distance [m]"
set title \
"Temperature distribution"
set style lines 1 lw 0 linecolor rgb "green" pt 5 ps 2 pointinterval 5
set style lines 2 lc rgb "red"
plot f(x) with linespoints ls 1, f(x) notitle ls 2

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

Legend

1
2
3
4
5
6
7
8
9
10
11
12

f(x) = 1/(1+(x*sin(x))**2)
set xrange[-5:5]
set yrange[0:1.3]
set xlabel "Temperature [K]"
set ylabel "Distance [m]"
set title \
"Temperature distribution"
set style lines 1 lc rgb "red"
set style lines 2 lw 0 linecolor rgb "green" pt 5 ps 2 pointinterval 5
set style lines 3 linecolor rgb "blue" lw 3
set key left width 1 height 1 box ls 3
plot f(x) w linespoint title "f(x) samples" ls 2, f(x) ls 1

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

Plotting many functions

1
2
3
4

f(x) = 1/(1+x**2)
set xrange[-5:5]
plot f(x), sin(x)
replot cos(x) w points

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

10

Filled functions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

f1(x) = 0.2*cos(x)
f2(x) = 0.5*sin(x)
f3(x) = 1/(1+x**2)
t1 = "0.2*cos(x)"
t2 = "0.5*sin(x)"
t3 = "1/(1+x**2)"
set clip two
unset colorbox
set xrange [-5:5]
set style fill
solid 1.00 noborder
set style function filledcurves y1=0
set title "Solid filled curves"
plot 0.2*cos(x) fs solid 1.0 lc rgb "forest-green" title t1
replot 0.5*sin(x) lc rgb "gold" title t2
replot 1/(1+x**2) lc rgb "red" title t3
Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

11

Transparent filling

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

12

Saving figures
Selected formats:
Nazwa
canvas
cgm
corel
dumb
dxf
fig
gif
jpeg
latex
pdfcairo
png
pngcairo
postscript
svg
wxt
x11

Description
HTML Canvas object
Computer Graphics Metafile
EPS format for CorelDRAW
ascii art for anything that prints text
dxf-file for AutoCad (default size 120x80)
FIG graphics language for XFIG graphics editor
GIF images using libgd and TrueType fonts
JPEG images using libgd and TrueType fonts
LaTeX picture environment
pdf terminal based on cairo
PNG images using libgd and TrueType fonts
png terminal based on cairo
PostScript graphics, including EPSF embedded files (*.eps)
W3C Scalable Vector Graphics driver
wxWidgets cross-platform windowed terminal
X11 Window System

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

13

Saving in vector formats


fig
gnuplot> set output rys.fig
gnuplot> set term fig
Terminal type set to fig
Options are color small pointsmax 1000 landscape inches \
dashed textnormal font Times Roman fontsize 10 linewidth 1\
depth 10 version 3.2

PostScript
gnuplot> set output rys.ps
gnuplot> set term postscript color
Terminal type set to postscript
Options are landscape noenhanced defaultplex leveldefault color \
colortext dashed dashlength 1.0 linewidth 1.0 butt noclip \
palfuncparam 2000,0.003 Helvetica 14
Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

14

Saving in raster formats


GIF
gnuplot> set output rys.gif
gnuplot> set term gif
Terminal type set to gif
Options are truecolor nocrop \
font /usr/share/fonts/truetype/ttfliberation/LiberationSansRegular.ttf 12\
size 640,480

PNG
gnuplot> set output rys.png
gnuplot> set term png
Terminal type set to png
Options are truecolor nocrop
font /usr/share/fonts/truetype/ttfliberation/LiberationSansRegular.ttf 12\
size 640,480
Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

15

Data visualisation
Data file:
1
2
3
4
5
6
7
8
9
10

1 0
2 3
3 5
4 -1
5 -2
6 0
7 4
8 3.5
9 2
10 0

Script:
1
2

set xzeroaxis
plot data w l

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

16

Operation on data stream and data filtering

Gnuplot provides tools for filtering input data stream and selecting data
to be plotted.
I

selecting data records option every

selecting data columns option using

selecting data sets option index

data interpolation and approximation option smooth


filtering through external programs

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

17

Overlays

2
3
4
5
6
7
8
9

set object 1 rect


from graph 0, 0 to graph 0.6, 0.7
front fc rgb "green"
set key left
set multiplot
plot sin(x)
unset object 1
set key outside center top
set size 0.5,0.6
set origin 0.1 , 0.1
plot cos(x) lc rgb "black"

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

18

Subwindows

1
2
3
4
5
6

set multiplot layout 2, 2


set key outside center top
plot sin(x)
plot cos(x)
plot x*x
plot 1/(1+x**2)

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

19

Histograms
Script and data taken form gnuplot distribution.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

20

Histograms
1
2
3
4
5
6

9
10

set boxwidth 0.9 absolute


set style fill solid 1.00 border 1
set style histogram clustered gap 1 title offset character 0, 0, 0
set datafile missing
set style data histograms
set xtics border in scale 1,0.5 nomirror rotate by 45
offset character 0, 0, 0
set xtics (18911900 0.00000, 19011910 1.00000, 19111920
2.00000,19211930 3.00000, 19311940 4.00000,
19411950 5.00000, 19511960 6.00000, 19611970 7.00000)
set title US immigration from Northern Europe\n
Plot selected data columns as histogram of clustered boxes
set yrange [ 0.00000 : 300000. ] noreverse nowriteback
plot immigration.dat using 6:xtic(1) ti col,
u 12 ti col, u 13 ti col, u 14 ti col
Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

21

Pie plots
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

circ="circle at 0,0 size 1"


wedge(color, s, e, title)= sprintf("set obj %d @circ arc [%d:%d] fc rgb c%d;\
replot -2 linecolor rgb c%d title \"%s\"",color,s,e,color,color,title)
set style fill
solid 1.0 border -1
set key outside
horizontal center top
set size square
set notics
set xrange [-1.2:1.2]
set yrange [-1.2:1.2]
c1="red"
c2="orange"
c3="yellow"
c4="forest-green"
c5="dark-turquoise"
c6="dark-magenta"
set style function filledcurves
set macro
plot -2 notitle
eval wedge(1,0,40, "Carbon 11.1%")
eval wedge(2,40,70, "Gold 8.3%")
eval wedge(3,70,90, "Mercury 5.5%")
eval wedge(4,90,120, "Iron 8.3%")
eval wedge(5,120,220, "Silver 27.7%")
eval wedge(6,220,360, "Tungsten 38.8%")
Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

22

Plotting parametric curves

1
2
3
4
5
6
7
8
9

set xrange[-10:10]
set yrange[-10:10]
set size square
set parametric
set termoption enhanced
R=4
set key Left left
plot R*cos(t),R*sin(t) title "Circle R=4"
replot 0.5*t**2, t title "Parabole:\n
x=t^2/2\n\r y=t"

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

23

Interactive elements

New terminal type based on wx library allows some user interaction like
rotating, panning and zooming with mouse. It also provides the way to
define keyboard short-cuts for user commands.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

24

Visualisation of function of two variables

1
2
3
4
5

6
7
8
9
10

f(x,y) = x*x-y*y
set isosamples 25, 25
unset key
set style fill solid
0.50 border
set hidden3d front offset 1
trianglepattern 3
undefined 1
altdiagonal bentover
set xyplane at 0
set palette rgbformulae 31, -11, 32
set colorbox vertical origin screen 0.9, 0.2, 0
size screen 0.05, 0.6, 0 front bdefault
splot f(x,y) with pm3d
replot f(x,y) with lines lt 1 lc rgb "#000000"

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

25

Command line history


I

history show the complete history

history 5 show last 5 entries in the history

history quiet 5 show last 5 entries without entry numbers

history hist.gp write the complete history to file hist.gp

history hist.gp append append the complete history to file hist.gp

history 10 head -5 >>diary.gp write 5 history commands using


pipe

history 10 hist.gp write last 10 commands to file hist.gp

history ?load show all history entries starting with load

history ?set c like above, several words enclosed in quotes

hi !reread execute last entry starting with reread

hist !set xr like above, several words enclosed in quotes

hi !hi guess yourself :-))


Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

26

Gnuplot scripts

Gnuplot scripts can be run


I

in terminal

during interactive gnuplot session using load command.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

27

Other gnuplot features

More gnuplot features can be seen at gnuplot demo pages:


http://gnuplot.sourceforge.net/demo/

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

28

Part II
VTK Overview

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

29

VTK Visualization Toolkit

The Visualization ToolKit (VTK) is an open source, freely available


software system for 3D computer graphics, image processing, and
visualization.
I

Book: The Visualization Toolkit, An Object-Oriented to 3D


Graphics, 2nd edition, Prentice-Hall

Software: http://www.kitware.com/vtk.html

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

30

VTK Applications

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

31

VTK Applications cont.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

32

VTK Applications cont.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

33

VTK Applications cont.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

34

VTK on jinx

Which packages: dpkg l | grep i vtk


I

Visualization Toolkit - A high level 3D visualization library

VTK header files for building C++ code

Python bindings for VTK

Tcl bindings for VTK

VTK class reference documentation

C++, Tcl and Python example programs/scripts

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

35

Technical Overview

I
I
I

C++ implementation
Open source

Not super-fast graphics


engine

Scripting interface:
Tcl/Tk, Python, Java

Very large not a toy

Requires decent system to


use it effectively

Portable
Supports parallelization

Commercial support

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

36

VTK: 3D Graphics

Surface Rendering:
OpenGL, gl, starbase, xgl
Volume Rendering
I
I
I

Flexible ray casting implementation


Support for VoumePRO volume rendering hardware
Supports mixing opaque surface geometry and volume rendering

Rendering primitives:
points, lines, polygons, tringle strips, volumes

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

37

VTK: Datasets Types

Structured Points

Structured Grid

Rectlinear Grid

Unstructured Points

Polygonal Data

Unstructured Grid

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

38

VTK: Cell Types

Vertex

Polyline

Pixel

Tetrahedron

Polyvertex

Triangle strip

Quad

Hexahedron

Triangle

Polygon

Voxel

Line

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

39

VTK: Atribute Types

Scalars (single valued + grayscale, grayscale-alpha, rgb, rgb-alpha)

Vectors

3x3 Tensors

Texture Coordinates (1-3D)

Field Data

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

40

VTK: Scalar Algorithms

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

41

VTK: Scalar Algorithms cont.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

42

VTK: Scalar Algorithms cont.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

43

VTK: Scalar Algorithms cont.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

44

VTK: Vector Algorithms

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

45

VTK: Vector Algorithms cont.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

46

VTK: Tensor Algorithms

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

47

VTK: Multidimensional solution

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

48

VTK: Modeling Algorithms

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

49

VTK: Modeling Algorithms cont.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

50

VTK: Modeling Algorithms cont.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

51

VTK:Imaging

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

52

VTK: Visualization Pipeline


I

Demand-driven data-flow with automatic network updates

Network looping and feedback supported

Supports multiple input/multiple output filters


vtkSphereSource

vtkActor

vtkPolyDataMapper

vtkRenerer

vtkRendererWindow

vtkRenderer WindowInteractor

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

53

VTK: Programming - Tcl/Tk


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

vtkSphereSource sphere
sphere SetRadius 1.0
sphere SetThetaResolution 18
sphere SetPhiResolution 18
vtkPolyDataMapper map
map SetInput [sphere GetOutput]
vtkActor aSphere
aSphere SetMapper map
[aSphere GetProperty] SetColor 0 0 1
vtkRenderWindow renWin
vtkRenderer ren1
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
ren1 AddActor aSphere
ren1 SetBackground 1 1 1
renWin Render
wm withdraw .
Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

54

Mayavi

free scientific data visualizer

implemented in Python + Tkinter + VTK

A pipeline browser can browse and edit objects in the VTK pipeline.

Visualize computational grids.

Visualize scalar, vector and tensor data.

A modular design so you can add your own modules and filters.

Output to: PostScript, PPM/BMP/TIFF/JPEG/PNG, Open


Inventor, VRML or RenderMan.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

55

Mayavi - examples

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

56

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

57

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

58

Credits

Most of the figures in this part and Tcl/Tk example come from VTK
distribution.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

59

Part III
VTK Programming

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

60

VTK: Visualization Pipe

vtkConeSource

vtkActor

vtkPolyDataMapper

vtkRenerer

vtkRendererWindow

vtkRenderer WindowInteractor

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

61

VTK: Programming - C++


1
2
3
4
5
6

#include
#include
#include
#include
#include
#include

vtkConeSource.h
vtkPolyDataMapper.h
vtkRenderWindow.h
vtkRenderWindowInteractor.h
vtkActor.h
vtkRenderer.h

7
8

11
12
13
14
15
16
17
18

24
25
26
27
28
29

int main( int argc, char argv[] ) {

9
10

vtkRenderer ren1=
vtkRenderer::New();
ren1>AddActor( coneActor );
ren1>SetBackground(0.1, 0.2, 0.4);
vtkRenderWindow renWin =
vtkRenderWindow::New();
renWin>AddRenderer( ren1 );
renWin>SetSize( 400, 400 );

23

30
31

vtkConeSource cone =
vtkConeSource::New();
cone>SetHeight( 3.0 );
cone>SetRadius( 1.0 );
cone>SetResolution( 5 );
vtkPolyDataMapper coneMapper =
vtkPolyDataMapper::New();
coneMapper>SetInput(
cone>GetOutput() );

vtkRenderWindowInteractor iren =
vtkRenderWindowInteractor::New();
iren>SetRenderWindow(renWin);

32
33
34
35

iren>Initialize();
iren>Start();

36
37
38

return 0;

39
40

19
20
21
22

vtkActor coneActor =
vtkActor::New();
coneActor>SetMapper( coneMapper );

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

62

VTK: Programming - Makefile


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

CXX = g++ g Wall


# for queen VTK 4.2
#INCLUDES = I. I/home/pracow/putanowr/include/vtk
#LDFLAGS = L/home/pracow/putanowr/lib/vtk \
L/usr/X11R6/lib
#LDADD = lvtkCommon lvtkIO lvtkGraphics \
lvtkRendering lGL lX11 lm
#for jinx VTK 3.2
INCLUDES = I. I/usr/include/vtk
LDFLAGS = L/usr/lib/vtk L/usr/X11R6/lib
LDADD = lVTKCommon lVTKGraphics lGL \
lXt lX11 lm
#for foo VTK 4.2
#INCLUDES = I. I/opt/include/vtk
#LDFLAGS = L/opt/lib/vtk L/usr/X11R6/lib
#LDADD = lvtkCommon lvtkIO lvtkGraphics \
lvtkRendering lGL lX11 lm
%.o : %.cxx
$(CXX) c $(INCLUDES) $< o $@
Cone1 : Cone1.o
$(CXX) $ $(LDFLAGS) $(LDADD) o $@
.PHONY : clean distclean
clean :
/bin/rm rf .o
distclean :
rm f Cone1

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

63

VTK: Programming - Tcl/Tk

1
2

package require vtk


package require vtkinteraction

3
4
5
6
7

10

19
20

vtkConeSource cone
cone SetHeight 3.0
cone SetRadius 1.0
cone SetResolution 5

8
9

18

vtkRenderWindow renWin
renWin AddRenderer ren1
renWin SetSize 400 400

21
22
23
24

vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
iren Initialize

25

vtkPolyDataMapper coneMapper
coneMapper SetInput [cone GetOutput]

26

wm withdraw .

11
12
13

vtkActor coneActor
coneActor SetMapper coneMapper

14
15
16
17

vtkRenderer ren1
ren1 AddActor coneActor
ren1 SetBackground 0.1 0.2 0.4

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

64

Part IV
OpenDX Overview

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

65

OpenDX

Open source software project based on IBMs Visualization Data


Explored (DX)
I

Powerful, full-featured visualization system

Visual programming, advanced GUI

Modular design, object-oriented, self-describing data model

I
I

C implementation
Scripting

Python and Tcl/Tk wrappers

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

66

Visual Programs Gradient

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

67

Visual Programs Gradient

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

68

Visual Programs Gradient

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

69

Visual Programs Streamlines

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

70

Visual Programs Streamlines

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

71

Visual Programs isosurfaces

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

72

Visual Programs Isosurfaces

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

73

Credits

All figures in this presentation come from OpenDx distribution.

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

74

References

1. Gnuplot home page http://www.gnuplot.info


2. Gnuplot demo page http://gnuplot.sourceforge.net/demo
3. GNU Octave http://www.gnu.org
4. Octaviz http://octaviz.sourceforge.net/
5. VTK - The Visualization Toolkit http://www.vtk.org
6. OpenDX http://www.opendx.org
7. Own materials

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

75

Thank you for your attention

Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

76

License
This work is licensed under the Creative Commons Attribution-Share
Alike 3.0 Unported License. To view a copy of this license, either visit
http://creativecommons.org/licenses/by-sa/3.0/deed.en;
or, send a letter to Creative Commons, 171 2nd Street, Suite 300, San
Francisco, California, 94105, USA.
You are free:
I

to share to copy, distribute and transmit the work

to remix to adapt the work

Under the following conditions:


I

attribution You must attribute the work in the manner specified


by the author or licensor (but not in any way that suggests that they
endorse you or your use of the work).

share alike If you alter, transform, or build upon this work, you
may distribute the resulting work only under the same or similar
license to this one.
Prepared for lectures in Selected Topics in Computer Science as a part of Computational Engineering MSc program at Civil
Engineering Faculty, Cracow University of Technology

77

Você também pode gostar