commented out not working use of vtk class

This commit is contained in:
Martin Diehl 2013-09-20 11:27:11 +00:00
parent 40c399bf2e
commit 1915215c6f
1 changed files with 37 additions and 37 deletions

View File

@ -477,45 +477,45 @@ for filename in args:
nodes=nodes.reshape(3,grid[0]+1,grid[1]+1,grid[2]+1) nodes=nodes.reshape(3,grid[0]+1,grid[1]+1,grid[2]+1)
#--- generate grid -------------------------------------------------------------------------------- #--- generate grid --------------------------------------------------------------------------------
structure = vtk.vtkIntArray() # structure = vtk.vtkIntArray()
structure.SetName('Microstructures') # structure.SetName('Microstructures')
temp = [] # temp = []
i=0 # i=0
aHexahedronGrid = vtk.vtkUnstructuredGrid() # aHexahedronGrid = vtk.vtkUnstructuredGrid()
for z in range (grid[2]): # for z in range (grid[2]):
for y in range (grid[1]): # for y in range (grid[1]):
for x in range (grid[0]): # for x in range (grid[0]):
temp.append(vtk.vtkHexahedron()) # temp.append(vtk.vtkHexahedron())
base = z*(grid[1]+1)*(grid[0]+1)+y*(grid[0]+1)+x # base = z*(grid[1]+1)*(grid[0]+1)+y*(grid[0]+1)+x
temp[i].GetPointIds().SetId(0, base) # temp[i].GetPointIds().SetId(0, base)
temp[i].GetPointIds().SetId(1, base+1) # temp[i].GetPointIds().SetId(1, base+1)
temp[i].GetPointIds().SetId(2, base+grid[0]+2) # temp[i].GetPointIds().SetId(2, base+grid[0]+2)
temp[i].GetPointIds().SetId(3, base+grid[0]+1) # temp[i].GetPointIds().SetId(3, base+grid[0]+1)
temp[i].GetPointIds().SetId(4, base+(grid[1]+1)*(grid[0]+1)) # temp[i].GetPointIds().SetId(4, base+(grid[1]+1)*(grid[0]+1))
temp[i].GetPointIds().SetId(5, base+(grid[1]+1)*(grid[0]+1)+1) # temp[i].GetPointIds().SetId(5, base+(grid[1]+1)*(grid[0]+1)+1)
temp[i].GetPointIds().SetId(6, base+(grid[1]+1)*(grid[0]+1)+grid[0]+2) # temp[i].GetPointIds().SetId(6, base+(grid[1]+1)*(grid[0]+1)+grid[0]+2)
temp[i].GetPointIds().SetId(7, base+(grid[1]+1)*(grid[0]+1)+grid[0]+1) # temp[i].GetPointIds().SetId(7, base+(grid[1]+1)*(grid[0]+1)+grid[0]+1)
aHexahedronGrid.InsertNextCell(temp[i].GetCellType(),temp[i].GetPointIds()) # aHexahedronGrid.InsertNextCell(temp[i].GetCellType(),temp[i].GetPointIds())
i+=1 # i+=1
structure.InsertNextValue(i) # structure.InsertNextValue(i)
pcoords = vtk.vtkDoubleArray() # pcoords = vtk.vtkDoubleArray()
pcoords.SetNumberOfComponents(3) # pcoords.SetNumberOfComponents(3)
for i in range(grid[0]+1): # for i in range(grid[0]+1):
for j in range(grid[1]+1): # for j in range(grid[1]+1):
for k in range(grid[2]+1): # for k in range(grid[2]+1):
pcoords.InsertNextTuple3(nodes[0,i,j,k],nodes[1,i,j,k],nodes[2,i,j,k]) # pcoords.InsertNextTuple3(nodes[0,i,j,k],nodes[1,i,j,k],nodes[2,i,j,k])
points = vtk.vtkPoints() # points = vtk.vtkPoints()
points.SetData(pcoords) # points.SetData(pcoords)
aHexahedronGrid.SetPoints(points) # aHexahedronGrid.SetPoints(points)
aHexahedronGrid.GetCellData().SetScalars(structure) # aHexahedronGrid.GetCellData().SetScalars(structure)
outWriter = vtk.vtkXMLUnstructuredGridWriter() # outWriter = vtk.vtkXMLUnstructuredGridWriter()
outWriter.SetDataModeToBinary() # outWriter.SetDataModeToBinary()
outWriter.SetCompressorTypeToZLib() # outWriter.SetCompressorTypeToZLib()
outWriter.SetFileName('ddd.vtu') # outWriter.SetFileName('ddd.vtu')
outWriter.SetInput(aHexahedronGrid) # outWriter.SetInput(aHexahedronGrid)
# outWriter.Write() # outWriter.Write()