Escolar Documentos
Profissional Documentos
Cultura Documentos
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
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
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
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
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
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
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
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
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
Gnuplot provides tools for filtering input data stream and selecting data
to be plotted.
I
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
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
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
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
22
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
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
26
Gnuplot scripts
in terminal
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
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
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
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
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
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
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
Scripting interface:
Tcl/Tk, Python, Java
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
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
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
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
Vectors
3x3 Tensors
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
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
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
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
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
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
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
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
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
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
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
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
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
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
A pipeline browser can browse and edit objects in the VTK pipeline.
A modular design so you can add your own modules and filters.
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
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
#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
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
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
1
2
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
I
I
C implementation
Scripting
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
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
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
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
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
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
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
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
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
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
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
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