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


set pv(vtkTemp98) [$pv(vtkTemp1) CreatePVSource SphereSource]
set pv(vtkTemp118) [$pv(vtkTemp98) GetPVWidget {Theta Resolution}]
$pv(vtkTemp118) SetValue 100
set pv(vtkTemp127) [$pv(vtkTemp98) GetPVWidget {Phi Resolution}]
$pv(vtkTemp127) SetValue 100
set pv(vtkTemp110) [$pv(vtkTemp98) GetPVWidget {Center}]
$pv(vtkTemp110) SetValue 2 2 0
$pv(vtkTemp98) AcceptCallback

set pv(vtkTemp180) [$pv(vtkTemp1) CreatePVSource DecimatePro]
set pv(vtkTemp194) [$pv(vtkTemp180) GetPVWidget {TargetReduction}]
$pv(vtkTemp194) SetValue 0.99
$pv(vtkTemp180) AcceptCallback


set pv(vtkTemp212) [$pv(vtkTemp1) CreatePVSource ConeSource]
$pv(vtkTemp212) AcceptCallback

set pv(vtkTemp364) [$pv(vtkTemp1) CreatePVSource ExtractEdges]
$pv(vtkTemp364) AcceptCallback

set pv(vtkTemp416) [$pv(vtkTemp1) CreatePVSource CylinderSource]
set pv(vtkTemp437) [$pv(vtkTemp416) GetPVWidget {Center}]
$pv(vtkTemp437) SetValue 2 0 0
set pv(vtkTemp428) [$pv(vtkTemp416) GetPVWidget {Resolution}]
$pv(vtkTemp428) SetValue 30
$pv(vtkTemp416) AcceptCallback

set pv(vtkTemp452) [$pv(vtkTemp1) CreatePVSource LinearExtrusionFilter]
set pv(vtkTemp466) [$pv(vtkTemp452) GetPVWidget {ScaleFactor}]
$pv(vtkTemp466) SetValue .5
$pv(vtkTemp452) AcceptCallback


set pv(vtkTemp486) [$pv(vtkTemp1) CreatePVSource SuperquadricSource]
set pv(vtkTemp526) [$pv(vtkTemp486) GetPVWidget {Toroidal}]
$pv(vtkTemp526) SetState 1
set pv(vtkTemp498) [$pv(vtkTemp486) GetPVWidget {Center}]
$pv(vtkTemp498) SetValue 0 2 0
set pv(vtkTemp514) [$pv(vtkTemp486) GetPVWidget {Thickness}]
$pv(vtkTemp514) SetValue 0.4
$pv(vtkTemp486) AcceptCallback

set pv(vtkTemp536) [$pv(vtkTemp1) CreatePVSource OutlineCornerFilter]
$pv(vtkTemp536) AcceptCallback

[$pv(vtkTemp486) GetPVOutput] SetVisibility 1
$pv(vtkTemp1) ResetCameraCallback

# 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
