$Application ExitOnReturnOn

set kw(vtkTemp5) [$Application GetMainWindow]
set kw(vtkTemp19) [$kw(vtkTemp5) GetMainView]

if {[info exists argc]} { 
    set argcm1 [expr $argc - 1]
    for {set i 0} {$i < $argcm1} {incr i} {
        if {[lindex $argv $i] == "-D" && $i < $argcm1} {
		set DataDir [lindex $argv [expr $i + 1]]
        }
        if {[lindex $argv $i] == "-UC" && $i < $argcm1} {
            set rmui [$kw(vtkTemp19) GetRenderModuleUI]
            catch {$rmui SetCompositeThreshold 0}
        }
    }
} 


set kw(vtkTemp781) [$kw(vtkTemp5) InitializeReadCustom "XMLRectilinearGridReader" "$DataDir/Data/cth.vtr"]
$kw(vtkTemp5) ReadFileInformation $kw(vtkTemp781) "$DataDir/Data/cth.vtr"
$kw(vtkTemp5) FinalizeRead $kw(vtkTemp781) "$DataDir/Data/cth.vtr"
set kw(vtkTemp797) [$kw(vtkTemp781) GetPVWidget {Filename}]
$kw(vtkTemp797) SetValue "$DataDir/Data/cth.vtr"
$kw(vtkTemp781) AcceptCallback
$kw(vtkTemp19) SetCameraState 11.651 7.426 34.047  -1.750 -0.000 0.000  -0.152 0.976 -0.153
set kw(vtkTemp973) [$kw(vtkTemp5) CreatePVSource CTHPart]
set kw(vtkTemp813) [$kw(vtkTemp781) GetPVOutput]
$kw(vtkTemp813) SetVisibility 1
$kw(vtkTemp813) SetVisibility 0
set kw(vtkTemp1007) [$kw(vtkTemp973) GetPVWidget {Input}]
$kw(vtkTemp1007) SetCurrentValue $kw(vtkTemp781)
set kw(vtkTemp980) [$kw(vtkTemp973) GetPVWidget {ArraySelection}]
$kw(vtkTemp980) ClearAllSelections
$kw(vtkTemp980) SetSelectState {Volume Fraction for Armor Plate} 1
$kw(vtkTemp980) SetSelectState {Volume Fraction for Body, Nose} 1
set kw(vtkTemp1006) [$kw(vtkTemp973) GetPVWidget {Clipping}]
$kw(vtkTemp1006) SetCurrentValue {On}
set kw(vtkTemp989) [$kw(vtkTemp1006) GetPVWidget {On}]
$kw(vtkTemp989) SetCenter -1.75 0 0
$kw(vtkTemp989) SetNormal 0 0 1
$kw(vtkTemp973) AcceptCallback
$kw(vtkTemp19) SetCameraState 1.513 -34.657 -13.496  -1.750 0.000 -0.000  0.933 0.203 -0.296
$kw(vtkTemp19) SetCameraState 1.513 -34.657 -13.496  -1.750 0.000 -0.000  0.933 0.203 -0.296
$kw(vtkTemp19) SetCameraState 4.384 15.117 -33.582  -1.750 0.000 0.000  0.986 -0.101 0.135
$kw(vtkTemp989) SetVisibility 0
$kw(vtkTemp19) SetCameraState 0.866 6.447 -14.321  -5.268 -8.670 19.261  0.986 -0.101 0.135
$kw(vtkTemp19) SetCameraState 0.485 -3.504 15.369  -4.756 4.713 -20.671  0.935 -0.291 -0.202
set kw(vtkTemp1011) [$kw(vtkTemp973) GetPVOutput]
$kw(vtkTemp1011) ColorByCellField {Pressure} 1
$kw(vtkTemp1011) ColorByCellField {Void Volume Fraction} 1
$kw(vtkTemp1011) ColorByCellField {Mass for Armor Plate} 1
$kw(vtkTemp19) SetCameraState 4.441 1.790 14.559  -10.076 -2.407 -19.581  0.896 -0.277 -0.347
$kw(vtkTemp1011) ColorByCellField {Z Velocity} 1


# Retrace
update
$Application StopRecordingScript
[ $Application GetMainWindow ] DeleteAllSources
# Source the trace to regenerate the sources.
if {[catch {set channel [open test.tmp w]}] == 0 } {
   close $channel
   file delete -force test.tmp
   source "[$Application GetTraceFileName]"
}

# Fix the size of the image.
set RenWin1 [[[$Application GetMainWindow] GetMainView] GetRenderWindow]
$RenWin1 SetSize 300 300
$RenWin1 Render
update

for {set i  1} {$i < [expr $argc - 1]} {incr i} {
    if {[lindex $argv $i] == "-C"} {
	source [lindex $argv [expr $i + 1]]
	$Application SetExitStatus [CompareImage [[$Application GetMainWindow] GetMainView]]
    }
}

$Application Exit

