source: development/steve/visualisation/vtkPipe.py @ 3295

Last change on this file since 3295 was 2229, checked in by steve, 19 years ago

Moved directories into production and development parent directories

File size: 1.4 KB
RevLine 
[2229]1# Basic VTK pipeline
2
3from pylab import *
4from vtk import *
5
6
7# ------- a boilerplate VTK pipeline ---------
8#--- Create some LUTs
9# (default) red -> blue (lo->hi)LUT
10lutRedBlue = vtkLookupTable()
11lutRedBlue.Build()
12
13# blue -> red LUT
14lutBlueRed = vtkLookupTable()
15lutBlueRed.SetHueRange(0.667,0.0)
16lutBlueRed.Build()
17
18
19vtkRen=vtkRenderer()
20vtkRenWin=vtkRenderWindow()
21
22# TODO - allow changing window size
23global winWidth, winHeight
24winWidth = 256
25winHeight = 256
26vtkRenWin.SetSize(winWidth,winHeight)
27im = zeros((winWidth,winHeight,3), typecode=Float)
28
29vtkRenWin.OffScreenRenderingOn()
30vtkRenWin.AddRenderer(vtkRen)
31
32vtkRGB = vtkUnsignedCharArray()
33
34"""
35def copyVTKImage():
36  vtkRenWin.Render()
37  vtkRenWin.GetPixelData(0,0,winWidth-1,winHeight-1, 1,vtkRGB)
38#  vtkRGB.Squeeze()
39  idx=0
40  for iy in range(winHeight-1,-1,-1):
41    for ix in range(winWidth):
42      im[iy,ix,0] = vtkRGB.GetValue(idx) / 255.
43      im[iy,ix,1] = vtkRGB.GetValue(idx+1) / 255.
44      im[iy,ix,2] = vtkRGB.GetValue(idx+2) / 255.
45      idx += 3
46
47def vtkRotX(degs):
48  vtkRen.GetActiveCamera().Elevation(degs)
49
50def vtkPerspective(flag):
51  if flag > 0:
52    vtkRen.GetActiveCamera().ParallelProjectionOff()
53  else:
54    vtkRen.GetActiveCamera().ParallelProjectionOn()
55
56def vtkWinsize(w,h):
57  winWidth = w
58  winHeight = h
59  im = zeros((winWidth,winHeight,3), typecode=Float)
60  vtkRenWin.SetSize(winWidth,winHeight)
61"""
62
Note: See TracBrowser for help on using the repository browser.