Fixed code so that vtkView works for cell, edge and face. extent and limits work for the rendering as well.

This commit is contained in:
Gudni Karl Rosenkjaer
2013-11-15 08:50:29 -08:00
parent 2cbbb3639c
commit 0cafa56104
2 changed files with 27 additions and 6 deletions
+22 -3
View File
@@ -240,15 +240,34 @@ class vtkTools(object):
vtkObj.GetCellData().SetActiveScalars(scalarName)
@staticmethod
def makeRectiVTKVOIThres(vtkObj):
def makeRectiVTKVOIThres(vtkObj,VOI,limits):
"""Make volume of interest and threshold for rectilinear grid."""
# Check for the input
cellCore = vtk.vtkExtractRectilinearGrid()
cellCore.SetVOI(VOI)
cellCore.SetInput(vtkObj)
cellCore.SetVOI(vtkObj.GetExtent())
cellThres = vtk.vtkThreshold()
cellThres.AllScalarsOn()
cellThres.SetInputConnection(cellCore.GetOutputPort())
cellThres.ThresholdByUpper(-1)
cellThres.ThresholdByUpper(limits[0])
cellThres.ThresholdByLower(limits[1])
cellThres.Update()
return cellThres.GetOutput(), cellCore.GetOutput()
@staticmethod
def makeUnstructVTKVOIThres(vtkObj,extent,limits):
"""Make volume of interest and threshold for rectilinear grid."""
# Check for the input
cellCore = vtk.vtkExtractUnstructuredGrid()
cellCore.SetExtent(extent)
cellCore.SetInput(vtkObj)
cellThres = vtk.vtkThreshold()
cellThres.AllScalarsOn()
cellThres.SetInputConnection(cellCore.GetOutputPort())
cellThres.ThresholdByUpper(limits[0])
cellThres.ThresholdByLower(limits[1])
cellThres.Update()
return cellThres.GetOutput(), cellCore.GetOutput()
+5 -3
View File
@@ -89,11 +89,13 @@ class vtkView(object):
# Sort out the actor
if imageType == 'cell':
self._vtkobj, self._core = vtkSP.makeRectiVTKVOIThres(self._cell)
self._vtkobj, self._core = vtkSP.makeRectiVTKVOIThres(self._cell,self.extent,self.limits)
elif imageType == 'face':
self._vtkobj, self._core = vtkSP.makeRectiVTKVOIThres(self._face)
extent = [self._mesh.vectorNx[self.extent[0]], self._mesh.vectorNx[self.extent[1]], self._mesh.vectorNy[self.extent[2]], self._mesh.vectorNy[self.extent[3]], self._mesh.vectorNz[self.extent[4]], self._mesh.vectorNz[self.extent[5]] ]
self._vtkobj, self._core = vtkSP.makeUnstructVTKVOIThres(self._face,extent,self.limits)
elif imageType == 'edge':
self._vtkobj, self._core = vtkSP.makeRectiVTKVOIThres(self._edge)
extent = [self._mesh.vectorNx[self.extent[0]], self._mesh.vectorNx[self.extent[1]], self._mesh.vectorNy[self.extent[2]], self._mesh.vectorNy[self.extent[3]], self._mesh.vectorNz[self.extent[4]], self._mesh.vectorNz[self.extent[5]] ]
self._vtkobj, self._core = vtkSP.makeUnstructVTKVOIThres(self._edge,extent,self.limits)
else:
raise Exception("{:s} is not a vailid imageType. Has to be 'cell':'face':'edge'".format(imageType))