add tensor support for vtk_addRectlinearGridData
This commit is contained in:
parent
32c4a20a46
commit
20d1164e5d
|
@ -38,6 +38,10 @@ parser.add_option('-v', '--vector',
|
||||||
dest = 'vector',
|
dest = 'vector',
|
||||||
action = 'extend', metavar = '<string LIST>',
|
action = 'extend', metavar = '<string LIST>',
|
||||||
help = 'vector value label(s)')
|
help = 'vector value label(s)')
|
||||||
|
parser.add_option('-t', '--tensor',
|
||||||
|
dest = 'tensor',
|
||||||
|
action = 'extend', metavar = '<string LIST>',
|
||||||
|
help = 'tensor (3x3) value label(s)')
|
||||||
parser.add_option('-c', '--color',
|
parser.add_option('-c', '--color',
|
||||||
dest = 'color',
|
dest = 'color',
|
||||||
action = 'extend', metavar = '<string LIST>',
|
action = 'extend', metavar = '<string LIST>',
|
||||||
|
@ -45,6 +49,7 @@ parser.add_option('-c', '--color',
|
||||||
|
|
||||||
parser.set_defaults(scalar = [],
|
parser.set_defaults(scalar = [],
|
||||||
vector = [],
|
vector = [],
|
||||||
|
tensor = [],
|
||||||
color = [],
|
color = [],
|
||||||
inplace = False,
|
inplace = False,
|
||||||
render = False,
|
render = False,
|
||||||
|
@ -95,6 +100,7 @@ for name in filenames:
|
||||||
|
|
||||||
for datatype,dimension,label in [['scalar',1,options.scalar],
|
for datatype,dimension,label in [['scalar',1,options.scalar],
|
||||||
['vector',3,options.vector],
|
['vector',3,options.vector],
|
||||||
|
['tensor',9,options.tensor],
|
||||||
['color',3,options.color],
|
['color',3,options.color],
|
||||||
]:
|
]:
|
||||||
for i,dim in enumerate(table.label_dimension(label)):
|
for i,dim in enumerate(table.label_dimension(label)):
|
||||||
|
@ -105,7 +111,7 @@ for name in filenames:
|
||||||
remarks.append('adding {} "{}"...'.format(datatype,me))
|
remarks.append('adding {} "{}"...'.format(datatype,me))
|
||||||
active[datatype].append(me)
|
active[datatype].append(me)
|
||||||
|
|
||||||
if datatype in ['scalar','vector']: VTKarray[me] = vtk.vtkDoubleArray()
|
if datatype in ['scalar','vector','tensor']: VTKarray[me] = vtk.vtkDoubleArray()
|
||||||
elif datatype == 'color': VTKarray[me] = vtk.vtkUnsignedCharArray()
|
elif datatype == 'color': VTKarray[me] = vtk.vtkUnsignedCharArray()
|
||||||
|
|
||||||
VTKarray[me].SetNumberOfComponents(dimension)
|
VTKarray[me].SetNumberOfComponents(dimension)
|
||||||
|
@ -129,6 +135,7 @@ for name in filenames:
|
||||||
theData = [table.data[i] for i in table.label_indexrange(me)] # read strings
|
theData = [table.data[i] for i in table.label_indexrange(me)] # read strings
|
||||||
if datatype == 'color': VTKarray[me].InsertNextTuple3(*map(lambda x: int(255.*float(x)),theData))
|
if datatype == 'color': VTKarray[me].InsertNextTuple3(*map(lambda x: int(255.*float(x)),theData))
|
||||||
elif datatype == 'vector': VTKarray[me].InsertNextTuple3(*map(float,theData))
|
elif datatype == 'vector': VTKarray[me].InsertNextTuple3(*map(float,theData))
|
||||||
|
elif datatype == 'tensor': VTKarray[me].InsertNextTuple9(*map(float,theData))
|
||||||
elif datatype == 'scalar': VTKarray[me].InsertNextValue(float(theData[0]))
|
elif datatype == 'scalar': VTKarray[me].InsertNextValue(float(theData[0]))
|
||||||
|
|
||||||
table.close() # close input ASCII table
|
table.close() # close input ASCII table
|
||||||
|
|
Loading…
Reference in New Issue