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 |
|
|
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 |
|
|
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 |
|
|