_Decimating Polygon Meshes_
by Will Schroeder and Tom Citriniti

Listing One
catch {load vtktcl}
# get the interactor ui
source vtkInt.tcl

# Read in CAD part
#
vtkSTLReader sr
    sr SetFileName "../../data/42400-IDGH.stl"
vtkDecimate deci
    deci SetInput [sr GetOutput]
    deci SetTargetReduction 0.9
    deci SetErrorIncrement 0.002
    deci SetMaximumIterations 8
    deci DebugOn
vtkPolyMapper   stlMapper
    stlMapper SetInput [deci GetOutput]
vtkLODActor stlActor
    stlActor SetMapper stlMapper

# Create graphics stuff
vtkRenderMaster rm

# Now create the RenderWindow, Renderer and both Actors
set renWin [rm MakeRenderWindow]
set ren1   [$renWin MakeRenderer]
set iren [$renWin MakeRenderWindowInteractor]
# Add the actors to the renderer, set the background and size
$ren1 AddActors stlActor
$ren1 SetBackground 0.1 0.2 0.4
$renWin SetSize 450 450

vtkCamera cam
  cam SetClippingRange 2.21973 110.986
  cam SetFocalPoint 128.766 86.0079 224.742
  cam SetPosition 133.866 68.8423 211.626
  cam SetViewAngle 30
  cam SetViewPlaneNormal 0.2298 -0.773329 -0.590893
  cam SetViewUp -0.0185622 0.603548 -0.797111
$ren1 SetActiveCamera cam

# render the image
$iren SetUserMethod {wm deiconify .vtkInteract}
$iren Initialize

# prevent the tk window from showing up then start the event loop
wm withdraw .


Listing Two
catch {load vtktcl}

# this is a tcl version to decimate fran's face
# get the interactor gui
source vtkInt.tcl

# create visualization pipeline
# create decimated model with surface normals
vtkCyberReader cyber
    cyber SetFileName "../../data/fran_cut"
vtkDecimate deci
    deci SetInput [cyber GetOutput]
    deci SetTargetReduction 0.95

    deci SetErrorIncrement 0.002
    deci SetMaximumIterations 8
    deci DebugOn
vtkPolyNormals normals
    normals SetInput [deci GetOutput]

# ingest image and apply as texture map
vtkPNMReader pnm
    pnm SetFileName fran_cut.ppm
vtkTexture aTexture
  aTexture SetInput [pnm GetOutput]
  aTexture InterpolateOn

# map to graphics system
vtkPolyMapper cyberMapper
    cyberMapper SetInput [normals GetOutput]
vtkActor cyberActor
    cyberActor SetMapper cyberMapper
    cyberActor SetTexture aTexture

# Create graphics objects
vtkRenderMaster rm

# Create the RenderWindow, Renderer and both Actors
set renWin [rm MakeRenderWindow]
set ren1   [$renWin MakeRenderer]
set iren [$renWin MakeRenderWindowInteractor]

# Add the actors to the renderer, set the background and size
$ren1 AddActors cyberActor
$ren1 SetBackground 1 1 1
$renWin SetSize 450 450

# Define method to invoke when "u" is pressed in graphics window
$iren SetUserMethod {wm deiconify .vtkInteract}

# Define nice view
vtkCamera cam1
    cam1 SetClippingRange 0.0475572 2.37786
    cam1 SetFocalPoint 0.052665 -0.129454 -0.0573973
    cam1 SetPosition 0.327637 -0.116299 -0.256418
    cam1 CalcViewPlaneNormal
    cam1 SetViewUp -0.0225386 0.999137 0.034901
$ren1 SetActiveCamera cam1

$iren Initialize

# prevent the tk window from showing up then start the event loop
wm withdraw .



