Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
API script example
import vistrails.core.api as API
org_vistrails_vistrails_url = API.load_package('org.vistrails.vistrails.url')
from vistrails.packages.vtk.vtk_wrapper import vvtk
import vtk
# MODULE 364 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
download_file = org_vistrails_vistrails_url.DownloadFile()
file = download_file.compute('file', url=url, insecure=insecure)
# MODULE 363 org.vistrails.vistrails.vtk:vtkStructuredPointsReader
# CONNECTION File file
vtk_structured_points_reader = vvtk.vtkStructuredPointsReader()
def input_t(value):
return value.name
def output_t(value):
from vistrails.core.modules.basic_modules import PathObject
return PathObject(value)
file = input_t(file)
vtk_structured_points_reader.SetFileName(file)
vtk_structured_points_reader.Update()
GetOutputPort0 = vtk_structured_points_reader.GetOutputPort()
vtk_structured_points_reader._cleanup()
# MODULE 357 org.vistrails.vistrails.vtk:vtkCamera
vtk_camera = vvtk.vtkCamera()
vtk_camera.SetViewUp(0.0, 0.0, -1.0)
vtk_camera.SetPosition(745.0, -453.0, 369.0)
vtk_camera.SetFocalPoint(135.0, 135.0, 150.0)
vtk_camera._cleanup()
# MODULE 345 org.vistrails.vistrails.vtk:vtkContourFilter
# CONNECTION SetInputConnection0 GetOutputPort0
vtk_contour_filter = vvtk.vtkContourFilter()
vtk_contour_filter.SetValue(0, 67.0)
vtk_contour_filter.SetInputConnection(0, GetOutputPort0)
vtk_contour_filter.Update()
GetOutputPort0_2 = vtk_contour_filter.GetOutputPort()
vtk_contour_filter._cleanup()
# MODULE 341 org.vistrails.vistrails.vtk:vtkDataSetMapper
# CONNECTION SetInputConnection0 GetOutputPort0_2
vtk_data_set_mapper = vvtk.vtkDataSetMapper()
vtk_data_set_mapper.ScalarVisibilityOff()
vtk_data_set_mapper.SetInputConnection(0, GetOutputPort0_2)
vtk_data_set_mapper.Update()
vtk_data_set_mapper._cleanup()
# MODULE 353 org.vistrails.vistrails.vtk:vtkActor
# CONNECTION Mapper vtk_data_set_mapper
Mapper = [vtk_data_set_mapper]
vtk_actor = vvtk.vtkActor()
for MapperItem in Mapper:
vtk_actor.SetMapper(MapperItem)
vtk_actor._cleanup()
# MODULE 349 org.vistrails.vistrails.vtk:vtkRenderer
# CONNECTION AddActor vtk_actor
# CONNECTION ActiveCamera vtk_camera
ActiveCamera = [vtk_camera]
AddActor = [vtk_actor]
vtk_renderer = vvtk.vtkRenderer()
for AddActorItem in AddActor:
vtk_renderer.AddActor(AddActorItem)
for ActiveCameraItem in ActiveCamera:
vtk_renderer.SetActiveCamera(ActiveCameraItem)
vtk_renderer._cleanup()
# MODULE 359 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.