我有一个包含多个数据数组的卷,并使用vtkVolumeMapper(vtkFixedPointVolumeRayCastMapper)渲染它。你知道吗
如何告诉映射器使用特定数组作为标量? (SelectColorArray不是vtkVolumeMapper的函数)
我用的是vtk6
# Create the reader for the data
reader = vtk.vtkXMLImageDataReader()
reader.SetFileName(self.scan_analysis.content.vtk_path)
reader.GetOutput().GetPointData().SetActiveScalars('smooth')
# Create transfer mapping scalar value to opacity
opacityTransferFunction = vtk.vtkPiecewiseFunction()
opacityTransferFunction.AddPoint(5, 0.0)
opacityTransferFunction.AddPoint(80, 0.4)
opacityTransferFunction.AddPoint(81, 0.0)
opacityTransferFunction.AddPoint(100, 0.0)
# Create transfer mapping scalar value to color
lut = vtk.vtkColorTransferFunction()
lut.AddRGBPoint(0.0, 0.0, 0.0, 1.0)
lut.AddRGBPoint(50.0, 1.0, 1.0, 1.0)
lut.AddRGBPoint(100.0, 1.0, 0.0, 0.0)
# The property describes how the data will look
volumeProperty = vtk.vtkVolumeProperty()
volumeProperty.SetColor(lut)
volumeProperty.SetScalarOpacity(opacityTransferFunction)
volumeProperty.ShadeOn()
volumeProperty.SetInterpolationTypeToLinear()
# The mapper / ray cast function know how to render the data
#volumeMapper = vtk.vtkGPUVolumeRayCastMapper()
#volumeMapper = vtk.vtkSmartVolumeMapper()
volumeMapper = vtk.vtkFixedPointVolumeRayCastMapper()
volumeMapper.SetBlendModeToComposite()
volumeMapper.SetInputConnection(reader.GetOutputPort())
volumeMapper.SelectColorArray('smooth') ## -> exception
# The volume holds the mapper and the property and
# can be used to position/orient the volume
volume = vtk.vtkVolume()
volume.SetMapper(volumeMapper)
volume.SetProperty(volumeProperty)
另外,是否可以将单元标量用于体积映射器?你知道吗
谢谢
更新: 我结束了对每个标量使用不同的vtk文件。 它工作正常,不会占用更多的磁盘空间。。。 但我知道这不是正确的解决方案(令人沮丧)
我使用setCalarsName找到了以下解决方案:
解决方案:
https://vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/DataManipulation/Python/pointToCellData.py
相关问题 更多 >
编程相关推荐