$Application ExitOnReturnOn

set pv(vtkTemp1) [$Application GetMainWindow]
set pv(vtkTemp43) [$pv(vtkTemp1) 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 [$pv(vtkTemp43) GetRenderModuleUI]
            catch {$rmui SetCompositeThreshold 0}
        }
    }
} 


$pv(vtkTemp43) SetBackgroundColor 0 0 0
set pv(vtkTemp89) [$pv(vtkTemp1) GetPVSource GlyphSources Arrow0]
set pv(vtkTemp93) [$pv(vtkTemp1) GetPVSource GlyphSources Cone0]
set pv(vtkTemp97) [$pv(vtkTemp1) GetPVSource GlyphSources Sphere0]

$pv(vtkTemp1) ChangeInteractorStyle 1

set pv(vtkTemp574) [$pv(vtkTemp1) InitializeReadCustom "ensight" "$DataDir/Data/elements.case"]
$pv(vtkTemp1) ReadFileInformation $pv(vtkTemp574) "$DataDir/Data/elements.case"
$pv(vtkTemp1) FinalizeRead $pv(vtkTemp574) "$DataDir/Data/elements.case"
set pv(vtkTemp585) [$pv(vtkTemp574) GetPVWidget PointArrays]
$pv(vtkTemp585) SetArrayStatus {pointCScalars} 0
$pv(vtkTemp585) SetArrayStatus {pointCVectors} 0
set pv(vtkTemp589) [$pv(vtkTemp574) GetPVWidget CellArrays]
$pv(vtkTemp589) SetArrayStatus {cellCScalars} 0
$pv(vtkTemp589) SetArrayStatus {cellCVectors} 0
$pv(vtkTemp574) AcceptCallback
[$pv(vtkTemp574) GetPVOutput] DrawSurface

$pv(vtkTemp1) ResetCameraCallback

set pv(vtkTemp159) [$pv(vtkTemp1) CreatePVSource Contour]
set pv(vtkTemp170) [$pv(vtkTemp159) GetPVWidget {Contour Values}]
$pv(vtkTemp170) RemoveAllValues
$pv(vtkTemp170) AddValue 110.000000
$pv(vtkTemp170) AddValue 111.000000
set pv(vtkTemp176) [$pv(vtkTemp159) GetPVWidget {Compute Normals}]
$pv(vtkTemp176) SetState 0
$pv(vtkTemp159) AcceptCallback

# 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
