commented out not working use of vtk class
This commit is contained in:
parent
40c399bf2e
commit
1915215c6f
|
@ -477,46 +477,46 @@ for filename in args:
|
|||
nodes=nodes.reshape(3,grid[0]+1,grid[1]+1,grid[2]+1)
|
||||
|
||||
#--- generate grid --------------------------------------------------------------------------------
|
||||
structure = vtk.vtkIntArray()
|
||||
structure.SetName('Microstructures')
|
||||
temp = []
|
||||
i=0
|
||||
aHexahedronGrid = vtk.vtkUnstructuredGrid()
|
||||
for z in range (grid[2]):
|
||||
for y in range (grid[1]):
|
||||
for x in range (grid[0]):
|
||||
temp.append(vtk.vtkHexahedron())
|
||||
base = z*(grid[1]+1)*(grid[0]+1)+y*(grid[0]+1)+x
|
||||
temp[i].GetPointIds().SetId(0, base)
|
||||
temp[i].GetPointIds().SetId(1, base+1)
|
||||
temp[i].GetPointIds().SetId(2, base+grid[0]+2)
|
||||
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(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(7, base+(grid[1]+1)*(grid[0]+1)+grid[0]+1)
|
||||
aHexahedronGrid.InsertNextCell(temp[i].GetCellType(),temp[i].GetPointIds())
|
||||
i+=1
|
||||
structure.InsertNextValue(i)
|
||||
# structure = vtk.vtkIntArray()
|
||||
# structure.SetName('Microstructures')
|
||||
# temp = []
|
||||
# i=0
|
||||
# aHexahedronGrid = vtk.vtkUnstructuredGrid()
|
||||
# for z in range (grid[2]):
|
||||
# for y in range (grid[1]):
|
||||
# for x in range (grid[0]):
|
||||
# temp.append(vtk.vtkHexahedron())
|
||||
# base = z*(grid[1]+1)*(grid[0]+1)+y*(grid[0]+1)+x
|
||||
# temp[i].GetPointIds().SetId(0, base)
|
||||
# temp[i].GetPointIds().SetId(1, base+1)
|
||||
# temp[i].GetPointIds().SetId(2, base+grid[0]+2)
|
||||
# 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(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(7, base+(grid[1]+1)*(grid[0]+1)+grid[0]+1)
|
||||
# aHexahedronGrid.InsertNextCell(temp[i].GetCellType(),temp[i].GetPointIds())
|
||||
# i+=1
|
||||
# structure.InsertNextValue(i)
|
||||
|
||||
pcoords = vtk.vtkDoubleArray()
|
||||
pcoords.SetNumberOfComponents(3)
|
||||
for i in range(grid[0]+1):
|
||||
for j in range(grid[1]+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 = vtk.vtkDoubleArray()
|
||||
# pcoords.SetNumberOfComponents(3)
|
||||
# for i in range(grid[0]+1):
|
||||
# for j in range(grid[1]+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])
|
||||
|
||||
points = vtk.vtkPoints()
|
||||
points.SetData(pcoords)
|
||||
aHexahedronGrid.SetPoints(points)
|
||||
aHexahedronGrid.GetCellData().SetScalars(structure)
|
||||
# points = vtk.vtkPoints()
|
||||
# points.SetData(pcoords)
|
||||
# aHexahedronGrid.SetPoints(points)
|
||||
# aHexahedronGrid.GetCellData().SetScalars(structure)
|
||||
|
||||
outWriter = vtk.vtkXMLUnstructuredGridWriter()
|
||||
outWriter.SetDataModeToBinary()
|
||||
outWriter.SetCompressorTypeToZLib()
|
||||
outWriter.SetFileName('ddd.vtu')
|
||||
outWriter.SetInput(aHexahedronGrid)
|
||||
# outWriter.Write()
|
||||
# outWriter = vtk.vtkXMLUnstructuredGridWriter()
|
||||
# outWriter.SetDataModeToBinary()
|
||||
# outWriter.SetCompressorTypeToZLib()
|
||||
# outWriter.SetFileName('ddd.vtu')
|
||||
# outWriter.SetInput(aHexahedronGrid)
|
||||
# outWriter.Write()
|
||||
|
||||
|
||||
fields = {\
|
||||
|
|
Loading…
Reference in New Issue