mirror of
https://github.com/OpenFOAM/ThirdParty-6.git
synced 2025-12-08 06:57:43 +00:00
ParaView-5.0.1: Added the source-tree to ThirdParty-dev and patched as described in the README file
Resolves bug-report http://bugs.openfoam.org/view.php?id=2098
This commit is contained in:
60
ParaView-5.0.1/VTK/Examples/VolumeRendering/Python/SimpleTextureMap2D.py
Executable file
60
ParaView-5.0.1/VTK/Examples/VolumeRendering/Python/SimpleTextureMap2D.py
Executable file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This is a simple volume rendering example that uses a
|
||||
# vtkVolumeTextureMapper2D mapper
|
||||
|
||||
import vtk
|
||||
from vtk.util.misc import vtkGetDataRoot
|
||||
VTK_DATA_ROOT = vtkGetDataRoot()
|
||||
|
||||
# Create the standard renderer, render window and interactor
|
||||
ren = vtk.vtkRenderer()
|
||||
renWin = vtk.vtkRenderWindow()
|
||||
renWin.AddRenderer(ren)
|
||||
iren = vtk.vtkRenderWindowInteractor()
|
||||
iren.SetRenderWindow(renWin)
|
||||
|
||||
# Create the reader for the data
|
||||
reader = vtk.vtkStructuredPointsReader()
|
||||
reader.SetFileName(VTK_DATA_ROOT + "/Data/ironProt.vtk")
|
||||
|
||||
# Create transfer mapping scalar value to opacity
|
||||
opacityTransferFunction = vtk.vtkPiecewiseFunction()
|
||||
opacityTransferFunction.AddPoint(20, 0.0)
|
||||
opacityTransferFunction.AddPoint(255, 0.2)
|
||||
|
||||
# Create transfer mapping scalar value to color
|
||||
colorTransferFunction = vtk.vtkColorTransferFunction()
|
||||
colorTransferFunction.AddRGBPoint(0.0, 0.0, 0.0, 0.0)
|
||||
colorTransferFunction.AddRGBPoint(64.0, 1.0, 0.0, 0.0)
|
||||
colorTransferFunction.AddRGBPoint(128.0, 0.0, 0.0, 1.0)
|
||||
colorTransferFunction.AddRGBPoint(192.0, 0.0, 1.0, 0.0)
|
||||
colorTransferFunction.AddRGBPoint(255.0, 0.0, 0.2, 0.0)
|
||||
|
||||
# The property describes how the data will look
|
||||
volumeProperty = vtk.vtkVolumeProperty()
|
||||
volumeProperty.SetColor(colorTransferFunction)
|
||||
volumeProperty.SetScalarOpacity(opacityTransferFunction)
|
||||
|
||||
# The mapper knows how to render the data
|
||||
volumeMapper = vtk.vtkVolumeTextureMapper2D()
|
||||
volumeMapper.SetInputConnection(reader.GetOutputPort())
|
||||
|
||||
# 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)
|
||||
|
||||
ren.AddVolume(volume)
|
||||
renWin.Render()
|
||||
|
||||
def CheckAbort(obj, event):
|
||||
if obj.GetEventPending() != 0:
|
||||
obj.SetAbortRender(1)
|
||||
|
||||
renWin.AddObserver("AbortCheckEvent", CheckAbort)
|
||||
|
||||
iren.Initialize()
|
||||
renWin.Render()
|
||||
iren.Start()
|
||||
Reference in New Issue
Block a user