Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
New patching script
import vtk
import vistrails.core.scripting.api as api
org_vistrails_vistrails_url = api.Package('org.vistrails.vistrails.url')
import locale
import os
from vistrails.packages.vtk import tf_widget
# MODULE 381 org.vistrails.vistrails.vtk:vtkVolumeRayCastCompositeFunction
vtk_volume_ray_cast_composite_function = vtk.vtkVolumeRayCastCompositeFunction()
vtk_volume_ray_cast_composite_function.vtkInstance = vtk_volume_ray_cast_composite_function
# MODULE 376 org.vistrails.vistrails.vtk:vtkCamera
vtk_camera = vtk.vtkCamera()
vtk_camera.vtkInstance = vtk_camera
vtk_camera.SetPosition(745.0, -453.0, 370.0)
vtk_camera.SetViewUp(0.0, 0.0, -1.0)
vtk_camera.SetFocalPoint(135.0, 135.0, 150.0)
# MODULE 410 org.vistrails.vistrails.url:DownloadFile
# FUNCTION url url
url = 'http://www.vistrails.org/download/download.php?type=DATA&id=head.120.vtk'
# DEFAULT insecure insecure
insecure = False
file = org_vistrails_vistrails_url.DownloadFile('file', url=url, insecure=insecure)
# MODULE 404 org.vistrails.vistrails.vtk:vtkStructuredPointsReader
# CONNECTION File file
vtk_structured_points_reader = vtk.vtkStructuredPointsReader()
vtk_structured_points_reader.vtkInstance = vtk_structured_points_reader
vtk_structured_points_reader._previous_locale = locale.setlocale(locale.LC_ALL)
locale.setlocale(locale.LC_ALL, 'C')
file = file.name
vtk_structured_points_reader.SetFileName(file)
# This checks for the presence of file in VTK readers
# Skips the check if it's a vtkImageReader or vtkPLOT3DReader, because
# it has other ways of specifying files, like SetFilePrefix for
# multiple files
if not os.path.isfile(vtk_structured_points_reader.GetFileName()):
raise Exception('File does not exist')
vtk_structured_points_reader.Update()
Output = vtk_structured_points_reader.GetOutput()
GetOutputPort0 = vtk_structured_points_reader.GetOutputPort()
locale.setlocale(locale.LC_ALL, vtk_structured_points_reader._previous_locale)
# MODULE 391 org.vistrails.vistrails.vtk:vtkVolumeRayCastMapper
# CONNECTION VolumeRayCastFunction vtk_volume_ray_cast_composite_function
# CONNECTION AddInputConnection GetOutputPort0
AddInputConnection = [GetOutputPort0]
VolumeRayCastFunction = [vtk_volume_ray_cast_composite_function]
vtk_volume_ray_cast_mapper = vtk.vtkVolumeRayCastMapper()
vtk_volume_ray_cast_mapper.vtkInstance = vtk_volume_ray_cast_mapper
for AddInputConnectionItem in AddInputConnection:
vtk_volume_ray_cast_mapper.AddInputConnection(AddInputConnectionItem)
for VolumeRayCastFunctionItem in VolumeRayCastFunction:
vtk_volume_ray_cast_mapper.SetVolumeRayCastFunction(VolumeRayCastFunctionItem)
vtk_volume_ray_cast_mapper.Update()
# MODULE 399 org.vistrails.vistrails.vtk:vtkScaledTransferFunction
# FUNCTION TransferFunction TransferFunction_2
TransferFunction_2 = tf_widget.TransferFunction.parse('<transfer_function max_range="1.0" min_range="0.0"><point opacity="0.0" scalar="0.0"><color B="0.0" G="0.0" R="0.0" /></point><point opacity="0.0" scalar="0.0776021828653"><color B="0.0" G="0.0" R="0.0" /></point><point opacity="0.620071684588" scalar="0.14157014157"><color B="0.462745098039" G="0.537254901961" R="0.890196078431" /></point><point opacity="0.0" scalar="0.20592020592"><color B="0.0" G="0.0" R="0.0" /></point><point opacity="0.0" scalar="0.251911830859"><color B="1.0" G="1.0" R="1.0" /></point><point opacity="0.971655328798" scalar="0.463338831759"><color B="1.0" G="1.0" R="1.0" /></point><point opacity="0.0" scalar="0.683760683761"><color B="0.270588235294" G="0.270588235294" R="0.270588235294" /></point><point opacity="0.0" scalar="1.0"><color B="0.0" G="0.0" R="0.0" /></point></transfer_function>')
# CONNECTION Dataset Output
tf = TransferFunction_2
tf._min_range, tf._max_range = Output.GetScalarRange()
# MODULE 396 org.vistrails.vistrails.vtk:vtkVolumeProperty
# CONNECTION TransferFunction TransferFunction_2
vtk_volume_property = vtk.vtkVolumeProperty()
vtk_volume_property.vtkInstance = vtk_volume_property
vtk_volume_property.SetInterpolationTypeToLinear()
vtk_volume_property.ShadeOn()
TransferFunction_2.set_on_vtk_volume_property(vtk_volume_property)
# MODULE 386 org.vistrails.vistrails.vtk:vtkVolume
# CONNECTION Mapper vtk_volume_ray_cast_mapper
# CONNECTION Property vtk_volume_property
Mapper = [vtk_volume_ray_cast_mapper]
Property = [vtk_volume_property]
vtk_volume = vtk.vtkVolume()
vtk_volume.vtkInstance = vtk_volume
for MapperItem in Mapper:
vtk_volume.SetMapper(MapperItem)
for PropertyItem in Property:
vtk_volume.SetProperty(PropertyItem)
vtk_volume.Update()
# MODULE 409 org.vistrails.vistrails.vtk:vtkRenderer
# CONNECTION ActiveCamera vtk_camera
# CONNECTION AddVolume vtk_volume
ActiveCamera = [vtk_camera]
AddVolume = [vtk_volume]
vtk_renderer = vtk.vtkRenderer()
vtk_renderer.vtkInstance = vtk_renderer
for AddVolumeItem in AddVolume:
vtk_renderer.AddVolume(AddVolumeItem)
for ActiveCameraItem in ActiveCamera:
vtk_renderer.SetActiveCamera(ActiveCameraItem)
vtk_renderer.SetBackground((0.0, 0.0, 0.0))
# MODULE 398 org.vistrails.vistrails.vtk:vtkRendererOutput
# CONNECTION value vtk_renderer
value = [vtk_renderer]
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(value[0].vtkInstance)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
renWin.SetSize(1024, 768)
iren.Initialize()
renWin.Render()
iren.Start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.