Commit acb3ded9 authored by Will Schroeder's avatar Will Schroeder

ENH:UG examples

parent 97075d63
# This example shows how to color an isosurface with other data.
# This example shows how to color an isosurface with other data. Basically
# an isosurface is generated, and a data array is selected and used by the
# mapper to color the surface.
package require vtk
package require vtkinteraction
# Read some data. The important thing here is to read a function
# as a data array as well as the scalar and vector. Later this
# data array will be used to color the isosurface.
# Read some data. The important thing here is to read a function as a data
# array as well as the scalar and vector. (here function 153 is named
# "Velocity Magnitude").Later this data array will be used to color the
# isosurface.
#
vtkPLOT3DReader pl3d
pl3d SetXYZFileName "$VTK_DATA_ROOT/Data/combxyz.bin"
......@@ -16,6 +19,10 @@ vtkPLOT3DReader pl3d
pl3d Update
pl3d DebugOn
# The contoru filter uses the labeled scalar (function number 100
# above to generate the contour surface; all other data is interpolated
# during the contouring process.
#
vtkContourFilter iso
iso SetInput [pl3d GetOutput]
iso SetValue 0 .24
......@@ -24,6 +31,9 @@ vtkPolyDataNormals normals
normals SetInput [iso GetOutput]
normals SetFeatureAngle 45
# We indicate to the mapper to use the velcoity magnitude, which is a
# vtkDataArray that makes up part of the point attribute data.
#
vtkPolyDataMapper isoMapper
isoMapper SetInput [normals GetOutput]
isoMapper ScalarVisibilityOn
......@@ -42,7 +52,7 @@ vtkPolyDataMapper outlineMapper
vtkActor outlineActor
outlineActor SetMapper outlineMapper
# Create the RenderWindow, Renderer and both Actors
# Create the usual rendering stuff.
#
vtkRenderer ren1
vtkRenderWindow renWin
......@@ -67,10 +77,7 @@ $cam1 SetViewUp -0.16123 0.264271 0.950876
# render the image
#
iren SetUserMethod {wm deiconify .vtkInteract}
renWin Render
#renWin SetFileName "combColorIso.tcl.ppm"
#renWin SaveImageAsPPM
# prevent the tk window from showing up then start the event loop
wm withdraw .
......
# This example shows how to extract a piece of a dataset using an implicit
# function. In this case the implicit function is formed by the boolean
# combination of two ellipsoids.
#
package require vtk
package require vtkinteraction
# Here we create two ellipsoidal implicit functions and boolean them
# together tto form a "cross" shaped implicit function.
vtkQuadric quadric
quadric SetCoefficients .5 1 .2 0 .1 0 0 .2 0 0
vtkSampleFunction sample
sample SetSampleDimensions 50 50 50
sample SetImplicitFunction quadric
sample ComputeNormalsOff
vtkTransform trans
trans Scale 1 .5 .333
vtkSphere sphere
sphere SetRadius 0.25
sphere SetTransform trans
vtkTransform trans2
trans2 Scale .25 .5 1.0
vtkSphere sphere2
sphere2 SetRadius 0.25
sphere2 SetTransform trans2
vtkImplicitBoolean union
union AddFunction sphere
union AddFunction sphere2
union SetOperationType 0;#union
# Here is where it gets interesting. The implicit function is used to
# extract those cells completely inside the function. They are then
# shrunk to help show what was extracted.
vtkExtractGeometry extract
extract SetInput [sample GetOutput]
extract SetImplicitFunction union
vtkShrinkFilter shrink
shrink SetInput [extract GetOutput]
shrink SetShrinkFactor 0.5
vtkDataSetMapper dataMapper
dataMapper SetInput [shrink GetOutput]
vtkActor dataActor
dataActor SetMapper dataMapper
# The outline gives context to the original data.
vtkOutlineFilter outline
outline SetInput [sample GetOutput]
vtkPolyDataMapper outlineMapper
outlineMapper SetInput [outline GetOutput]
vtkActor outlineActor
outlineActor SetMapper outlineMapper
set outlineProp [outlineActor GetProperty]
eval $outlineProp SetColor 0 0 0
# The usual rendering stuff is created.
vtkRenderer ren1
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
# Add the actors to the renderer, set the background and size
#
ren1 AddActor outlineActor
ren1 AddActor dataActor
ren1 SetBackground 1 1 1
renWin SetSize 500 500
[ren1 GetActiveCamera] Zoom 1.5
iren Initialize
# render the image
#
iren SetUserMethod {wm deiconify .vtkInteract}
# prevent the tk window from showing up then start the event loop
wm withdraw .
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment