$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}
        }
    }
} 

    
# This test excecises the new way we select scalars
# in the WarpScalar and Contour filters.
# it also uses LoopSubdivision filter to get a nice smooth surface.


$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) Open "$DataDir/Data/vox8_bin.vtk"
set pv(vtkTemp100) [$pv(vtkTemp1) GetCurrentPVSource]
set pv(vtkTemp101) [$pv(vtkTemp100) GetPVOutput]
$pv(vtkTemp101) DrawWireframe
$pv(vtkTemp101) ColorByProperty
set pv(vtkTemp136) [$pv(vtkTemp1) CreatePVSource Contour]
set pv(vtkTemp142) [$pv(vtkTemp136) GetPVWidget {Input}]
$pv(vtkTemp142) SetCurrentValue $pv(vtkTemp100)
set pv(vtkTemp143) [$pv(vtkTemp136) GetPVWidget {Scalars}]
set pv(vtkTemp146) [$pv(vtkTemp136) GetPVWidget {Contour Values}]
$pv(vtkTemp146) RemoveAllValues
$pv(vtkTemp146) AddValue 0.850000
$pv(vtkTemp146) AddValue 0.950000
set pv(vtkTemp152) [$pv(vtkTemp136) GetPVWidget {Compute Normals}]
$pv(vtkTemp152) SetState 0
set pv(vtkTemp155) [$pv(vtkTemp136) GetPVWidget {Compute Gradients}]
set pv(vtkTemp158) [$pv(vtkTemp136) GetPVWidget {Compute Scalars}]
$pv(vtkTemp136) AcceptCallback
$pv(vtkTemp142) SetCurrentValue $pv(vtkTemp100)
$pv(vtkTemp143) SetValue xRamp
$pv(vtkTemp146) RemoveAllValues
$pv(vtkTemp146) AddValue 0.850000
$pv(vtkTemp146) AddValue 0.950000
$pv(vtkTemp136) AcceptCallback
$pv(vtkTemp142) SetCurrentValue $pv(vtkTemp100)
$pv(vtkTemp143) SetValue yRamp
$pv(vtkTemp146) RemoveAllValues
$pv(vtkTemp146) AddValue 0.850000
$pv(vtkTemp146) AddValue 0.950000
$pv(vtkTemp136) AcceptCallback
$pv(vtkTemp142) SetCurrentValue $pv(vtkTemp100)
$pv(vtkTemp143) SetValue zRamp
$pv(vtkTemp146) RemoveAllValues
$pv(vtkTemp146) AddValue 0.450000
$pv(vtkTemp146) AddValue 0.950000
$pv(vtkTemp136) AcceptCallback
set pv(vtkTemp137) [$pv(vtkTemp136) GetPVOutput] 
$pv(vtkTemp137) ColorByPointField "scalars" 1
set pv(vtkTemp188) [$pv(vtkTemp1) CreatePVSource WarpScalar]
set pv(vtkTemp194) [$pv(vtkTemp188) GetPVWidget {Input}]
$pv(vtkTemp194) SetCurrentValue $pv(vtkTemp136)
set pv(vtkTemp195) [$pv(vtkTemp188) GetPVWidget {Scalars}]
set pv(vtkTemp200) [$pv(vtkTemp188) GetPVWidget {ScaleFactor}]
set pv(vtkTemp203) [$pv(vtkTemp188) GetPVWidget {Normal}]
set pv(vtkTemp208) [$pv(vtkTemp188) GetPVWidget {UseNormal}]
set pv(vtkTemp211) [$pv(vtkTemp188) GetPVWidget {XYPlane}]
$pv(vtkTemp188) AcceptCallback
$pv(vtkTemp194) SetCurrentValue $pv(vtkTemp136)
$pv(vtkTemp208) SetState 1
$pv(vtkTemp188) AcceptCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp136)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) ShowCurrentSourceProperties
set pv(vtkTemp221) [$pv(vtkTemp1) CreatePVSource LoopSubdivisionFilter]
set pv(vtkTemp227) [$pv(vtkTemp221) GetPVWidget {Input}]
$pv(vtkTemp227) SetCurrentValue $pv(vtkTemp136)
set pv(vtkTemp232) [$pv(vtkTemp221) GetPVWidget {NumberOfSubdivisions}]
$pv(vtkTemp221) AcceptCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp136)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp188)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp194) SetCurrentValue $pv(vtkTemp221)
$pv(vtkTemp188) AcceptCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp221)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp136)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) ShowCurrentSourceProperties
set pv(vtkTemp241) [$pv(vtkTemp1) CreatePVSource LoopSubdivisionFilter]
set pv(vtkTemp247) [$pv(vtkTemp241) GetPVWidget {Input}]
$pv(vtkTemp247) SetCurrentValue $pv(vtkTemp136)
set pv(vtkTemp252) [$pv(vtkTemp241) GetPVWidget {NumberOfSubdivisions}]
$pv(vtkTemp241) AcceptCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp136)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp221)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp188)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp194) SetCurrentValue $pv(vtkTemp241)
$pv(vtkTemp188) AcceptCallback
$pv(vtkTemp194) SetCurrentValue $pv(vtkTemp241)
$pv(vtkTemp200) SetValue 2
$pv(vtkTemp188) AcceptCallback
$pv(vtkTemp221) DeleteCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp241)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp247) SetCurrentValue $pv(vtkTemp136)
$pv(vtkTemp252) SetValue 3
$pv(vtkTemp241) AcceptCallback
$pv(vtkTemp247) SetCurrentValue $pv(vtkTemp136)
$pv(vtkTemp252) SetValue 4
$pv(vtkTemp241) AcceptCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp136)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp142) SetCurrentValue $pv(vtkTemp100)
$pv(vtkTemp146) RemoveAllValues
$pv(vtkTemp146) AddValue 0.450000
$pv(vtkTemp146) AddValue 0.350000
$pv(vtkTemp136) AcceptCallback
$pv(vtkTemp142) SetCurrentValue $pv(vtkTemp100)
$pv(vtkTemp146) RemoveAllValues
$pv(vtkTemp146) AddValue 0.450000
$pv(vtkTemp146) AddValue 0.050000
$pv(vtkTemp136) AcceptCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp241)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp188)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp194) SetCurrentValue $pv(vtkTemp241)
$pv(vtkTemp195) SetValue xRamp
$pv(vtkTemp188) AcceptCallback
$pv(vtkTemp194) SetCurrentValue $pv(vtkTemp241)
$pv(vtkTemp195) SetValue yRamp
$pv(vtkTemp188) AcceptCallback
$pv(vtkTemp194) SetCurrentValue $pv(vtkTemp241)
$pv(vtkTemp195) SetValue zRamp
$pv(vtkTemp188) AcceptCallback
$pv(vtkTemp194) SetCurrentValue $pv(vtkTemp241)
$pv(vtkTemp195) SetValue scalars
$pv(vtkTemp188) AcceptCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp136)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp142) SetCurrentValue $pv(vtkTemp100)
$pv(vtkTemp143) SetValue yRamp
$pv(vtkTemp136) AcceptCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp188)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp194) SetCurrentValue $pv(vtkTemp241)
$pv(vtkTemp203) SetValue 0 1 0
$pv(vtkTemp188) AcceptCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp136)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp142) SetCurrentValue $pv(vtkTemp100)
$pv(vtkTemp143) SetValue scalars
$pv(vtkTemp136) AcceptCallback
$pv(vtkTemp1) ResetCameraCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp100)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp136)
$pv(vtkTemp1) ShowCurrentSourceProperties
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp100)
$pv(vtkTemp1) ShowCurrentSourceProperties
set pv(vtkTemp261) [$pv(vtkTemp1) CreatePVSource Clip]
$pv(vtkTemp261) DeleteCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp100)
$pv(vtkTemp1) ShowCurrentSourceProperties
set pv(vtkTemp282) [$pv(vtkTemp1) CreatePVSource Contour]
set pv(vtkTemp288) [$pv(vtkTemp282) GetPVWidget {Input}]
$pv(vtkTemp288) SetCurrentValue $pv(vtkTemp100)
set pv(vtkTemp289) [$pv(vtkTemp282) GetPVWidget {Scalars}]
$pv(vtkTemp289) SetValue xRamp
set pv(vtkTemp292) [$pv(vtkTemp282) GetPVWidget {Contour Values}]
$pv(vtkTemp292) RemoveAllValues
$pv(vtkTemp292) AddValue 0.050000
$pv(vtkTemp292) AddValue 0.850000
$pv(vtkTemp292) AddValue 0.950000
set pv(vtkTemp298) [$pv(vtkTemp282) GetPVWidget {Compute Normals}]
$pv(vtkTemp298) SetState 0
set pv(vtkTemp301) [$pv(vtkTemp282) GetPVWidget {Compute Gradients}]
set pv(vtkTemp304) [$pv(vtkTemp282) GetPVWidget {Compute Scalars}]
$pv(vtkTemp282) AcceptCallback
set pv(vtkTemp283) [$pv(vtkTemp282) GetPVOutput]
$pv(vtkTemp283) ColorByPointField "scalars" 1
set pv(vtkTemp316) [$pv(vtkTemp1) CreatePVSource LoopSubdivisionFilter]
set pv(vtkTemp322) [$pv(vtkTemp316) GetPVWidget {Input}]
$pv(vtkTemp322) SetCurrentValue $pv(vtkTemp282)
set pv(vtkTemp327) [$pv(vtkTemp316) GetPVWidget {NumberOfSubdivisions}]
$pv(vtkTemp327) SetValue 4
$pv(vtkTemp316) AcceptCallback
set pv(vtkTemp336) [$pv(vtkTemp1) CreatePVSource WarpScalar]
set pv(vtkTemp342) [$pv(vtkTemp336) GetPVWidget {Input}]
$pv(vtkTemp342) SetCurrentValue $pv(vtkTemp316)
set pv(vtkTemp343) [$pv(vtkTemp336) GetPVWidget {Scalars}]
set pv(vtkTemp348) [$pv(vtkTemp336) GetPVWidget {ScaleFactor}]
$pv(vtkTemp348) SetValue 3
set pv(vtkTemp351) [$pv(vtkTemp336) GetPVWidget {Normal}]
$pv(vtkTemp351) SetValue 1 0 0
set pv(vtkTemp356) [$pv(vtkTemp336) GetPVWidget {UseNormal}]
set pv(vtkTemp359) [$pv(vtkTemp336) GetPVWidget {XYPlane}]
$pv(vtkTemp336) AcceptCallback

$pv(vtkTemp136) SetVisibility 1

$pv(vtkTemp1) ResetCameraCallback

# 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
