added new option "no-data" to omit output of microstructure data field, i.e. generates plain mesh only

This commit is contained in:
Philip Eisenlohr 2014-08-21 16:01:11 +00:00
parent 594c3c007b
commit 0bcd508298
1 changed files with 22 additions and 15 deletions

View File

@ -53,6 +53,11 @@ Produce VTK rectilinear mesh of structure data from geom description
""" + string.replace(scriptID,'\n','\\n') """ + string.replace(scriptID,'\n','\\n')
) )
parser.add_option('-n','--nodata', dest='data', action='store_false',
help='omit microstructure data, just generate mesh')
parser.set_defaults(data = True)
(options, filenames) = parser.parse_args() (options, filenames) = parser.parse_args()
#--- setup file handles -------------------------------------------------------------------------- #--- setup file handles --------------------------------------------------------------------------
@ -124,26 +129,28 @@ for file in files:
temp.SetNumberOfTuples(info['grid'][i]+1) temp.SetNumberOfTuples(info['grid'][i]+1)
for j in xrange(info['grid'][i]+1): for j in xrange(info['grid'][i]+1):
temp.InsertTuple1(j,j*info['size'][i]/info['grid'][i]+info['origin'][i]) temp.InsertTuple1(j,j*info['size'][i]/info['grid'][i]+info['origin'][i])
if i == 0: grid.SetXCoordinates(temp) if i == 0: grid.SetXCoordinates(temp)
if i == 1: grid.SetYCoordinates(temp) elif i == 1: grid.SetYCoordinates(temp)
if i == 2: grid.SetZCoordinates(temp) elif i == 2: grid.SetZCoordinates(temp)
#--- read microstructure information -------------------------------------------------------------- #--- read microstructure information --------------------------------------------------------------
structure = vtk.vtkIntArray()
structure.SetName('Microstructures')
while theTable.data_read(): if options.data:
items = theTable.data structure = vtk.vtkIntArray()
if len(items) > 2: structure.SetName('Microstructures')
if items[1].lower() == 'of': items = [int(items[2])]*int(items[0])
elif items[1].lower() == 'to': items = xrange(int(items[0]),1+int(items[2]))
else: items = map(int,items)
else: items = map(int,items)
for item in items: while theTable.data_read():
structure.InsertNextValue(item) items = theTable.data
if len(items) > 2:
if items[1].lower() == 'of': items = [int(items[2])]*int(items[0])
elif items[1].lower() == 'to': items = xrange(int(items[0]),1+int(items[2]))
else: items = map(int,items)
else: items = map(int,items)
grid.GetCellData().AddArray(structure) for item in items:
structure.InsertNextValue(item)
grid.GetCellData().AddArray(structure)
#--- write data ----------------------------------------------------------------------------------- #--- write data -----------------------------------------------------------------------------------
if file['name'] == 'STDIN': if file['name'] == 'STDIN':