$Application ExitOnReturnOn

set pvWindow [$Application GetMainWindow]
set pv(vtkTemp43) [$pvWindow 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 pvSphere [$pvWindow CreatePVSource SphereSource]
[$pvSphere GetPVWidget {Theta Resolution}] SetValue 16
$pvSphere AcceptCallback

set pvShrink [$pvWindow CreatePVSource ShrinkFilter]
[$pvShrink GetPVWidget {ShrinkFactor}] SetValue 0.9
$pvShrink AcceptCallback

set pvElevation [$pvWindow CreatePVSource ElevationFilter]
set pv(vtkTemp999) [$pvElevation GetPVWidget {Line}]
$pv(vtkTemp999) SetPoint1 0 0 0
$pv(vtkTemp999) SetPoint2 0 0 1
$pvElevation AcceptCallback
[$pvElevation GetPVOutput] DrawSurface

set pvExtract [$pvWindow CreatePVSource ExtractEdges]
$pvExtract AcceptCallback

set extractOutput [$pvExtract GetPVOutput]
$extractOutput ColorByProperty

set elevOutput [$pvElevation GetPVOutput]
$elevOutput SetVisibility 1


set pvWindow [lindex [vtkPVWindow ListInstances] 0]
$pvWindow SetCurrentPVSource $pvSphere

set Ren1 [[[$Application GetMainWindow] GetMainView] GetRenderer]
set camera [$Ren1 GetActiveCamera]
$camera SetPosition 0 0 3.41078
$camera SetFocalPoint 0 0 0
$camera SetViewUp 0 1 0
$camera SetViewAngle 30
$camera SetClippingRange 2.38825 4.70618

$elevOutput SetVisibility 1
$extractOutput SetVisibility 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
set Ren1 [[[$Application GetMainWindow] GetMainView] GetRenderer]
for {set i 0} {$i < 100} {incr i 1} {
	set camera [$Ren1 GetActiveCamera]
	$camera Azimuth 10
        $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


