You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.0 KiB
69 lines
2.0 KiB
2 years ago
|
# This is a simple volume rendering example that
|
||
|
# uses a vtkVolumeRayCast mapper
|
||
|
|
||
|
package require vtk
|
||
|
package require vtkinteraction
|
||
|
|
||
|
# Create the standard renderer, render window
|
||
|
# and interactor
|
||
|
vtkRenderer ren1
|
||
|
vtkRenderWindow renWin
|
||
|
renWin AddRenderer ren1
|
||
|
vtkRenderWindowInteractor iren
|
||
|
iren SetRenderWindow renWin
|
||
|
|
||
|
# Create the reader for the data
|
||
|
vtkStructuredPointsReader reader
|
||
|
reader SetFileName "$VTK_DATA_ROOT/Data/ironProt.vtk"
|
||
|
|
||
|
# Create transfer mapping scalar value to opacity
|
||
|
vtkPiecewiseFunction opacityTransferFunction
|
||
|
opacityTransferFunction AddPoint 20 0.0
|
||
|
opacityTransferFunction AddPoint 255 0.2
|
||
|
|
||
|
# Create transfer mapping scalar value to color
|
||
|
vtkColorTransferFunction colorTransferFunction
|
||
|
colorTransferFunction AddRGBPoint 0.0 0.0 0.0 0.0
|
||
|
colorTransferFunction AddRGBPoint 64.0 1.0 0.0 0.0
|
||
|
colorTransferFunction AddRGBPoint 128.0 0.0 0.0 1.0
|
||
|
colorTransferFunction AddRGBPoint 192.0 0.0 1.0 0.0
|
||
|
colorTransferFunction AddRGBPoint 255.0 0.0 0.2 0.0
|
||
|
|
||
|
# The property describes how the data will look
|
||
|
vtkVolumeProperty volumeProperty
|
||
|
volumeProperty SetColor colorTransferFunction
|
||
|
volumeProperty SetScalarOpacity opacityTransferFunction
|
||
|
volumeProperty ShadeOn
|
||
|
volumeProperty SetInterpolationTypeToLinear
|
||
|
|
||
|
# The mapper / ray cast function know how to render the data
|
||
|
vtkVolumeRayCastCompositeFunction compositeFunction
|
||
|
vtkVolumeRayCastMapper volumeMapper
|
||
|
volumeMapper SetVolumeRayCastFunction compositeFunction
|
||
|
volumeMapper SetInputConnection [reader GetOutputPort]
|
||
|
|
||
|
# The volume holds the mapper and the property and
|
||
|
# can be used to position/orient the volume
|
||
|
vtkVolume volume
|
||
|
volume SetMapper volumeMapper
|
||
|
volume SetProperty volumeProperty
|
||
|
|
||
|
ren1 AddVolume volume
|
||
|
ren1 SetBackground 1 1 1
|
||
|
renWin SetSize 600 600
|
||
|
renWin Render
|
||
|
|
||
|
proc TkCheckAbort {} {
|
||
|
set foo [renWin GetEventPending]
|
||
|
if {$foo != 0} {renWin SetAbortRender 1}
|
||
|
}
|
||
|
renWin AddObserver AbortCheckEvent {TkCheckAbort}
|
||
|
|
||
|
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||
|
iren Initialize
|
||
|
|
||
|
wm withdraw .
|
||
|
|
||
|
|
||
|
|