bugfix: need to addData to vtk

not really sure why 'SetScalars' was used for color. 'AddArray' seems to
work. Also, there seems to be no difference between 'data' and 'tensor'
This commit is contained in:
Martin Diehl 2020-01-02 11:31:33 +01:00
parent d4d419b713
commit a87e396b83
2 changed files with 9 additions and 12 deletions

View File

@ -2,8 +2,8 @@
import os import os
import sys import sys
from io import StringIO
from optparse import OptionParser from optparse import OptionParser
from collections import defaultdict
import vtk import vtk
from vtk.util import numpy_support from vtk.util import numpy_support
@ -120,14 +120,9 @@ for name in filenames:
damask.util.croak('{} mode...'.format(mode)) damask.util.croak('{} mode...'.format(mode))
for datatype,labels in active.items(): # loop over scalar,color for data in VTKarray:
if datatype == 'color': if mode == 'cell': rGrid.GetCellData().AddArray(VTKarray[data])
if mode == 'cell': rGrid.GetCellData().SetScalars(VTKarray[active['color'][0]]) elif mode == 'point': rGrid.GetPointData().AddArray(VTKarray[data])
elif mode == 'point': rGrid.GetPointData().SetScalars(VTKarray[active['color'][0]])
for me in labels: # loop over all requested items
if mode == 'cell': rGrid.GetCellData().AddArray(VTKarray[me])
elif mode == 'point': rGrid.GetPointData().AddArray(VTKarray[me])
rGrid.Modified() rGrid.Modified()
# ------------------------------------------ output result --------------------------------------- # ------------------------------------------ output result ---------------------------------------

View File

@ -2,8 +2,8 @@
import os import os
import sys import sys
from io import StringIO
from optparse import OptionParser from optparse import OptionParser
from collections import defaultdict
import vtk import vtk
from vtk.util import numpy_support from vtk.util import numpy_support
@ -104,10 +104,12 @@ for name in filenames:
VTKarray[tensor].SetName(tensor) VTKarray[tensor].SetName(tensor)
# ------------------------------------------ output result --------------------------------------- for data in VTKarray:
Polydata.GetPointData().AddArray(VTKarray[data])
Polydata.Modified() Polydata.Modified()
# ------------------------------------------ output result ---------------------------------------
writer = vtk.vtkXMLPolyDataWriter() writer = vtk.vtkXMLPolyDataWriter()
writer.SetDataModeToBinary() writer.SetDataModeToBinary()
writer.SetCompressorTypeToZLib() writer.SetCompressorTypeToZLib()