初始图形显示的TCL代码如下:

package require vtk

vtkImageReader reader
  reader SetDataByteOrderToLittleEndian
  reader SetDataExtent 0 63 0 63 1 93
  reader SetFilePrefix "$VTK_DATA_ROOT/Data/headsq/quarter"
  reader SetDataMask 0x7fff

vtkImageGradient gradient
  gradient SetInputConnection [reader GetOutputPort]
  gradient SetDimensionality 3

vtkImageViewer viewer
  viewer SetInputConnection [gradient GetOutputPort]
  viewer SetZSlice 22
  viewer SetColorWindow 400
  viewer SetColorLevel 0
  [viewer GetRenderWindow] SetSize 64 64

vtkRenderWindowInteractor iren
  iren SetRenderWindow [viewer GetRenderWindow]

# Withdraw the default tk window
wm withdraw .

iren Start

我们知道vtkImageViewer显示的图片不会随着拖动窗体放大缩小而改变图像的尺寸。
所以第一张显示图正是window的Size 64 64。
现在使用filter vtkImageMagnify来处理数据,然后再传递给vtkImageViewer对象。

set mag_factor 10
vtkImageMagnify magnify
  magnify SetInputConnection [gradient GetOutputPort]
  magnify SetMagnificationFactors $mag_factor $mag_factor 1

然后,我们更新window的大小:

[viewer GetRenderWindow] SetSize 640 640

得到:


 

Categories: TCL

Leave a Reply

Your email address will not be published. Required fields are marked *