/[escript]/trunk/modellib/py_src/tsunami.py
ViewVC logotype

Diff of /trunk/modellib/py_src/tsunami.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 264 by cochrane, Tue Nov 29 10:06:39 2005 UTC revision 276 by cochrane, Wed Nov 30 04:31:40 2005 UTC
# Line 1122  class SurfMovie(Model): Line 1122  class SurfMovie(Model):
1122               # vtkobj=...               # vtkobj=...
1123               # save(self.__frame_name)               # save(self.__frame_name)
1124    
1125               # get the wave data           # make a reader for the data
1126               waveDomain = self.wave_height.getDomain().getX()           waveReader = vtk.vtkXMLUnstructuredGridReader()
1127               waveX = waveDomain[0].convertToNumArray()           waveReader.SetFileName(self.__fn)
1128               waveY = waveDomain[1].convertToNumArray()           waveReader.Update()
              waveZ = self.wave_height.convertToNumArray()  
   
              numPoints = len(waveZ)  
   
              # make the points  
              wavePoints = vtk.vtkPoints()  
              wavePoints.SetNumberOfPoints(numPoints)  
   
              # make the vtk data array  
              waveData = vtk.vtkFloatArray()  
              waveData.SetNumberOfComponents(1)  
              waveData.SetNumberOfTuples(numPoints)  
              waveData.SetName("data")  
   
              # put the data into the points and array  
              for i in range(numPoints):  
                  wavePoints.InsertPoint(i, waveX[i], waveY[i], 0.0)  
                  waveData.InsertTuple1(i, waveZ[i])  
1129    
1130               # make the grid               # make the grid
1131               waveGrid = vtk.vtkUnstructuredGrid()               waveGrid = waveReader.GetOutput()
1132               waveGrid.SetPoints(wavePoints)           waveGrid.Update()
              waveGrid.GetPointData().AddArray(waveData)  
              waveGrid.GetPointData().SetActiveScalars("data")  
1133    
1134               (zMin, zMax) = waveGrid.GetPointData().GetScalars().GetRange()               (zMin, zMax) = waveGrid.GetPointData().GetScalars().GetRange()
1135               print "Wave height range %f - %f" % (zMin, zMax)               print "Wave height range %f - %f" % (zMin, zMax)
1136    
          # do a delaunay on the data  
          waveDelaunay = vtk.vtkDelaunay2D()  
          waveDelaunay.SetInput(waveGrid)  
          waveDelaunay.SetTolerance(0.001)  
          waveDelaunay.SetAlpha(2.5)  
   
1137               # make a mapper for the grid               # make a mapper for the grid
1138               waveMapper = vtk.vtkDataSetMapper()               waveMapper = vtk.vtkDataSetMapper()
1139               waveMapper.SetInput(waveDelaunay.GetOutput())               waveMapper.SetInput(waveGrid)
1140           waveMapper.SetLookupTable(self.lutTrans)           waveMapper.SetLookupTable(self.lutTrans)
1141               waveMapper.SetScalarRange(zMin, zMax)               waveMapper.SetScalarRange(zMin, zMax)
1142    
# Line 1190  class SurfMovie(Model): Line 1164  class SurfMovie(Model):
1164               outWriter.SetFileName(imgFname)               outWriter.SetFileName(imgFname)
1165               outWriter.Write()               outWriter.Write()
1166               print "Wrote %s" % imgFname               print "Wrote %s" % imgFname
1167    
1168             # helpful for debugging:
1169             #os.system("display %s" % imgFname)
1170    
1171               self.paramsFileString += "%s\n" % imgFname               self.paramsFileString += "%s\n" % imgFname
1172           self.imageFiles.append(imgFname)           self.imageFiles.append(imgFname)
1173    
# Line 1264  if __name__=="__main__": Line 1242  if __name__=="__main__":
1242     src.end_lat=-12.     src.end_lat=-12.
1243     src.start_long=110.     src.start_long=110.
1244     src.end_long=120.     src.end_long=120.
1245     src.width=0.1     src.width=1.
1246     src.decay_zone=0.01     src.decay_zone=0.01
1247     src.amplitude=1.     src.amplitude=1.
1248    

Legend:
Removed from v.264  
changed lines
  Added in v.276

  ViewVC Help
Powered by ViewVC 1.1.26