# Demonstration # Creating a sequence of 100 BMP files to show the variation of potential # along an axis of an electrostatic solution # File names set to generate an AVI animation with CECIL_B # Stanley Humphries, Field Precision, Copyright 2010 # --------------------- # Set control parameters # Range and step size along z axis $ZMin = -0.065; $ZMax = 0.065; $NStep = 100; $dZ = ($ZMax-$ZMin)/$NStep; # Graphics file resolution $XRes = "640"; $YRes = "480"; # File names # Saved surface plot view to set style, orientation and view limits. The # variable parameter (SurfacePlanePos) has been replaced with @ $ViewTemplate = "template.fpv"; # Temporary view file with different values of SurfacePlanePos $ViewTemp = "temp.fpv"; $ViewTempPrefix = "temp"; # Script file to call phiview, referencing the current view file $Script = "pvscript.scr"; $ScriptPrefix = "pvscript"; # --------------------- # Loop along the z axis for ($n=0;$n<($NStep+1);$n++) { $Z = $ZMin + $n*$dZ; # Create the temporary view file, replacing @ with the current position $Z open (InFile,"<",$ViewTemplate); open (OutFile,">",$ViewTemp); while () { $Line = $_; $Line =~ s/@/$Z/; print OutFile $Line; } close InFile; close OutFile; # Create the BMP file prefix if ($n < 10) { $BMPFilePrefix = "bmpout" . "00" . $n; } elsif ($n < 100) { $BMPFilePrefix = "bmpout" . "0" . $n; } else { $BMPFilePrefix = "bmpout" . $n; } # Write the PhiView script open (SCRFile,">",$Script); print SCRFile "INPUT TARGET.HOU\n"; $PlotCommand = "PLOT " . $ViewTempPrefix . " " . $BMPFilePrefix . " " . $XRes . " " . $YRes; print SCRFile "$PlotCommand\n"; print SCRFile "ENDFILE\n"; close SCRFile; # Run phiview to generate the BMP file $status = system("../phiview",$ScriptPrefix); } # --------------------- # Erase the last temporary view file unlink($ViewTemp); # Erase the last temporary script unlink($Script); exit;