Animated slice movie
This script shows how to make a movie that shows a side by side movie of 2 plots that use a slice. The dataset used for this example was created by another example script.
# This script takes a dataset and makes a side by side movie of 2 plots. The
# left plot shows the original dataset and the location of the slice along the
# Z-axis. The right plot shows a Surface plot of the sliced data.
#
# To run the script and make a movie: visit -movie -scriptfile sliceanim.py
#
# Note that you can append any other "visit -movie" command line options to the
# above command line.
#
# Programmer: Brad Whitlock
# Date: Tue Sep 8 11:30:26 PDT 2009
#
# Modifications:
#
################################################################################
# Change these parameters to match your dataset. This script assumes that we want to slice along Z.
DB = "test.visit"
VAR = "var"
VARMESH="mesh"
def GetPercentZSlice(percent, to2d):
SliceAtts = SliceAttributes(1)
SliceAtts.originType = SliceAtts.Percent # Point, Intercept, Percent, Zone, Node
SliceAtts.originPoint = (0, 0, 0)
SliceAtts.originIntercept = 0
SliceAtts.originPercent = percent
SliceAtts.originZone = 0
SliceAtts.originNode = 0
SliceAtts.normal = (0, 0, 1)
SliceAtts.axisType = SliceAtts.ZAxis # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi
SliceAtts.upAxis = (0, 1, 0)
SliceAtts.project2d = to2d
SliceAtts.interactive = 1
SliceAtts.flip = 0
SliceAtts.originZoneDomain = 0
SliceAtts.originNodeDomain = 0
SliceAtts.meshName = "mesh"
SliceAtts.theta = 0
SliceAtts.phi = 90
return SliceAtts
# Draw the 3D dataset in a window and we'll put the mesh slice on it
def SetupWindow2(DB, var, varmesh):
OpenDatabase(DB)
AddPlot("Pseudocolor", var)
AddPlot("Mesh", varmesh)
MeshAtts = MeshAttributes(1)
MeshAtts.lineWidth = 4
SetPlotOptions(MeshAtts)
AddOperator("Slice", 0)
SetOperatorOptions(GetPercentZSlice(0, 0), 0)
DrawPlots()
ResetView()
v = GetView3D()
v.RotateAxis(0, -80.)
SetView3D(v)
# Draw the surface dataset in window 1
def SetupWindow1(DB, var):
OpenDatabase(DB)
AddPlot("Pseudocolor", var)
AddOperator("Slice")
SetOperatorOptions(GetPercentZSlice(0, 1), 0)
AddOperator("Elevate")
DrawPlots()
ResetView()
v = GetView3D()
v.RotateAxis(0, -90.)
# TODO: Adjust the view so the bbox will remain fixed?
SetView3D(v)
# Setup the windows
SetupWindow1(DB, VAR)
AddWindow()
DeleteAllPlots()
SetupWindow2(DB, VAR, VARMESH)
# Setup savewindow attributes so we'll saved "tiled images" that contain both window 1 and 2
SaveWindowAtts = SaveWindowAttributes()
SaveWindowAtts.outputToCurrentDirectory = 1
SaveWindowAtts.outputDirectory = "."
SaveWindowAtts.fileName = "visit"
SaveWindowAtts.family = 1
SaveWindowAtts.format = SaveWindowAtts.JPEG # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK
SaveWindowAtts.width = 1024
SaveWindowAtts.height = 1024
SaveWindowAtts.screenCapture = 0
SaveWindowAtts.saveTiled = 1
SaveWindowAtts.quality = 80
SaveWindowAtts.progressive = 0
SaveWindowAtts.binary = 0
SaveWindowAtts.stereo = 0
SaveWindowAtts.compression = SaveWindowAtts.PackBits # None, PackBits, Jpeg, Deflate
SaveWindowAtts.forceMerge = 0
SaveWindowAtts.resConstraint = SaveWindowAtts.ScreenProportions # NoConstraint, EqualWidthHeight, ScreenProportions
SetSaveWindowAttributes(SaveWindowAtts)
# Do an animation of 100 slices in Z
for i in range(100):
# Make both windows use the same slice.
SetActiveWindow(1)
SetOperatorOptions(GetPercentZSlice(i, 1), 0)
SetActiveWindow(2)
SetOperatorOptions(GetPercentZSlice(i, 0), 0)
SaveWindow()