Created
August 10, 2016 14:51
-
-
Save rexissimus/5ac7374cde8525d84f9443f019d234e2 to your computer and use it in GitHub Desktop.
Example of turning a vtk example into a script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import vtk | |
# MODULE 61 org.vistrails.vistrails.vtk:vtkCellArray | |
vtk_cell_array = vtk.vtkCellArray() | |
vtk_cell_array.vtkInstance = vtk_cell_array | |
vtk_cell_array.InsertNextCell(12) | |
vtk_cell_array.InsertCellPoint(0) | |
vtk_cell_array.InsertCellPoint(1) | |
vtk_cell_array.InsertCellPoint(2) | |
vtk_cell_array.InsertCellPoint(3) | |
vtk_cell_array.InsertCellPoint(4) | |
vtk_cell_array.InsertCellPoint(5) | |
vtk_cell_array.InsertCellPoint(6) | |
vtk_cell_array.InsertCellPoint(7) | |
vtk_cell_array.InsertCellPoint(8) | |
vtk_cell_array.InsertCellPoint(9) | |
vtk_cell_array.InsertCellPoint(10) | |
vtk_cell_array.InsertCellPoint(11) | |
vtk_cell_array.InsertNextCell(28) | |
vtk_cell_array.InsertCellPoint(39) | |
vtk_cell_array.InsertCellPoint(38) | |
vtk_cell_array.InsertCellPoint(37) | |
vtk_cell_array.InsertCellPoint(36) | |
vtk_cell_array.InsertCellPoint(35) | |
vtk_cell_array.InsertCellPoint(34) | |
vtk_cell_array.InsertCellPoint(33) | |
vtk_cell_array.InsertCellPoint(32) | |
vtk_cell_array.InsertCellPoint(31) | |
vtk_cell_array.InsertCellPoint(30) | |
vtk_cell_array.InsertCellPoint(29) | |
vtk_cell_array.InsertCellPoint(28) | |
vtk_cell_array.InsertCellPoint(27) | |
vtk_cell_array.InsertCellPoint(26) | |
vtk_cell_array.InsertCellPoint(25) | |
vtk_cell_array.InsertCellPoint(24) | |
vtk_cell_array.InsertCellPoint(23) | |
vtk_cell_array.InsertCellPoint(22) | |
vtk_cell_array.InsertCellPoint(21) | |
vtk_cell_array.InsertCellPoint(20) | |
vtk_cell_array.InsertCellPoint(19) | |
vtk_cell_array.InsertCellPoint(18) | |
vtk_cell_array.InsertCellPoint(17) | |
vtk_cell_array.InsertCellPoint(16) | |
vtk_cell_array.InsertCellPoint(15) | |
vtk_cell_array.InsertCellPoint(14) | |
vtk_cell_array.InsertCellPoint(13) | |
vtk_cell_array.InsertCellPoint(12) | |
# MODULE 51 org.vistrails.vistrails.vtk:vtkProperty | |
vtk_property = vtk.vtkProperty() | |
vtk_property.vtkInstance = vtk_property | |
vtk_property.SetSpecular(0.3) | |
vtk_property.SetColor((0.2, 0.63, 0.79)) | |
vtk_property.SetSpecularColor((1.0, 1.0, 1.0)) | |
vtk_property.SetSpecularPower(20.0) | |
vtk_property.SetAmbient(0.2) | |
vtk_property.SetDiffuse(0.8) | |
# MODULE 106 org.vistrails.vistrails.vtk:vtkPoints | |
vtk_points = vtk.vtkPoints() | |
vtk_points.vtkInstance = vtk_points | |
vtk_points.InsertPoint(0, 1.0, 4.0, 0.0) | |
vtk_points.InsertPoint(1, 3.0, 4.0, 0.0) | |
vtk_points.InsertPoint(2, 7.0, 4.0, 0.0) | |
vtk_points.InsertPoint(3, 11.0, 4.0, 0.0) | |
vtk_points.InsertPoint(4, 13.0, 4.0, 0.0) | |
vtk_points.InsertPoint(5, 13.0, 8.0, 0.0) | |
vtk_points.InsertPoint(6, 13.0, 12.0, 0.0) | |
vtk_points.InsertPoint(7, 10.0, 12.0, 0.0) | |
vtk_points.InsertPoint(8, 7.0, 12.0, 0.0) | |
vtk_points.InsertPoint(9, 4.0, 12.0, 0.0) | |
vtk_points.InsertPoint(10, 1.0, 12.0, 0.0) | |
vtk_points.InsertPoint(11, 1.0, 8.0, 0.0) | |
vtk_points.InsertPoint(12, 3.5, 5.0, 0.0) | |
vtk_points.InsertPoint(13, 4.5, 5.0, 0.0) | |
vtk_points.InsertPoint(14, 5.5, 8.0, 0.0) | |
vtk_points.InsertPoint(15, 6.5, 8.0, 0.0) | |
vtk_points.InsertPoint(16, 6.5, 5.0, 0.0) | |
vtk_points.InsertPoint(17, 7.5, 5.0, 0.0) | |
vtk_points.InsertPoint(18, 7.5, 8.0, 0.0) | |
vtk_points.InsertPoint(19, 9.0, 8.0, 0.0) | |
vtk_points.InsertPoint(20, 9.0, 5.0, 0.0) | |
vtk_points.InsertPoint(21, 10.0, 5.0, 0.0) | |
vtk_points.InsertPoint(22, 10.0, 7.0, 0.0) | |
vtk_points.InsertPoint(23, 11.0, 5.0, 0.0) | |
vtk_points.InsertPoint(24, 12.0, 5.0, 0.0) | |
vtk_points.InsertPoint(25, 10.5, 8.0, 0.0) | |
vtk_points.InsertPoint(26, 12.0, 11.0, 0.0) | |
vtk_points.InsertPoint(27, 11.0, 11.0, 0.0) | |
vtk_points.InsertPoint(28, 10.0, 9.0, 0.0) | |
vtk_points.InsertPoint(29, 10.0, 11.0, 0.0) | |
vtk_points.InsertPoint(30, 9.0, 11.0, 0.0) | |
vtk_points.InsertPoint(31, 9.0, 9.0, 0.0) | |
vtk_points.InsertPoint(32, 7.5, 9.0, 0.0) | |
vtk_points.InsertPoint(33, 7.5, 11.0, 0.0) | |
vtk_points.InsertPoint(34, 6.5, 11.0, 0.0) | |
vtk_points.InsertPoint(35, 6.5, 9.0, 0.0) | |
vtk_points.InsertPoint(36, 5.0, 9.0, 0.0) | |
vtk_points.InsertPoint(37, 4.0, 6.0, 0.0) | |
vtk_points.InsertPoint(38, 3.0, 9.0, 0.0) | |
vtk_points.InsertPoint(39, 2.0, 9.0, 0.0) | |
# MODULE 56 org.vistrails.vistrails.vtk:vtkPolyData | |
# CONNECTION Polys vtk_cell_array | |
# CONNECTION Points vtk_points | |
points = [vtk_points] | |
polys = [vtk_cell_array] | |
vtk_poly_data = vtk.vtkPolyData() | |
vtk_poly_data.vtkInstance = vtk_poly_data | |
for polys_item in polys: | |
vtk_poly_data.SetPolys(polys_item) | |
for points_item in points: | |
vtk_poly_data.SetPoints(points_item) | |
# MODULE 76 org.vistrails.vistrails.vtk:vtkDelaunay2D | |
# CONNECTION InputData_1 vtk_poly_data | |
# CONNECTION SourceData vtk_poly_data | |
input_data_1 = [vtk_poly_data] | |
source_data = [vtk_poly_data] | |
vtk_delaunay2_d = vtk.vtkDelaunay2D() | |
vtk_delaunay2_d.vtkInstance = vtk_delaunay2_d | |
for input_data_1_item in input_data_1: | |
vtk_delaunay2_d.SetInputData(input_data_1_item) | |
for source_data_item in source_data: | |
vtk_delaunay2_d.SetSourceData(source_data_item) | |
vtk_delaunay2_d.Update() | |
get_output_port0 = vtk_delaunay2_d.GetOutputPort() | |
# MODULE 111 org.vistrails.vistrails.vtk:vtkExtractEdges | |
# CONNECTION SetInputConnection0 get_output_port0 | |
vtk_extract_edges = vtk.vtkExtractEdges() | |
vtk_extract_edges.vtkInstance = vtk_extract_edges | |
vtk_extract_edges.SetInputConnection(0, get_output_port0) | |
vtk_extract_edges.Update() | |
get_output_port0_2 = vtk_extract_edges.GetOutputPort() | |
# MODULE 101 org.vistrails.vistrails.vtk:vtkTubeFilter | |
# CONNECTION SetInputConnection0 get_output_port0_2 | |
vtk_tube_filter = vtk.vtkTubeFilter() | |
vtk_tube_filter.vtkInstance = vtk_tube_filter | |
vtk_tube_filter.SetRadius(0.1) | |
vtk_tube_filter.SetNumberOfSides(6) | |
vtk_tube_filter.SetInputConnection(0, get_output_port0_2) | |
vtk_tube_filter.Update() | |
get_output_port0_3 = vtk_tube_filter.GetOutputPort() | |
# MODULE 86 org.vistrails.vistrails.vtk:vtkPolyDataMapper | |
# CONNECTION SetInputConnection0 get_output_port0_3 | |
vtk_poly_data_mapper = vtk.vtkPolyDataMapper() | |
vtk_poly_data_mapper.vtkInstance = vtk_poly_data_mapper | |
vtk_poly_data_mapper.SetInputConnection(0, get_output_port0_3) | |
vtk_poly_data_mapper.Update() | |
# MODULE 96 org.vistrails.vistrails.vtk:vtkPolyDataMapper | |
# CONNECTION SetInputConnection0 get_output_port0 | |
vtk_poly_data_mapper_2 = vtk.vtkPolyDataMapper() | |
vtk_poly_data_mapper_2.vtkInstance = vtk_poly_data_mapper_2 | |
vtk_poly_data_mapper_2.SetInputConnection(0, get_output_port0) | |
vtk_poly_data_mapper_2.Update() | |
# MODULE 81 org.vistrails.vistrails.vtk:vtkActor | |
# CONNECTION Mapper vtk_poly_data_mapper_2 | |
mapper = [vtk_poly_data_mapper_2] | |
vtk_actor = vtk.vtkActor() | |
vtk_actor.vtkInstance = vtk_actor | |
for mapper_item in mapper: | |
vtk_actor.SetMapper(mapper_item) | |
# MODULE 71 org.vistrails.vistrails.vtk:vtkActor | |
# CONNECTION Property vtk_property | |
# CONNECTION Mapper vtk_poly_data_mapper | |
mapper_2 = [vtk_poly_data_mapper] | |
property_1 = [vtk_property] | |
vtk_actor_2 = vtk.vtkActor() | |
vtk_actor_2.vtkInstance = vtk_actor_2 | |
for mapper_item in mapper_2: | |
vtk_actor_2.SetMapper(mapper_item) | |
for property_1_item in property_1: | |
vtk_actor_2.SetProperty(property_1_item) | |
# MODULE 66 org.vistrails.vistrails.vtk:vtkCamera | |
vtk_camera = vtk.vtkCamera() | |
vtk_camera.vtkInstance = vtk_camera | |
vtk_camera.Zoom(2.0) | |
# MODULE 91 org.vistrails.vistrails.vtk:vtkRenderer | |
# CONNECTION ActiveCamera vtk_camera | |
# CONNECTION AddActor vtk_actor_2 | |
# CONNECTION AddActor vtk_actor | |
active_camera = [vtk_camera] | |
add_actor = [vtk_actor_2] + [vtk_actor] | |
vtk_renderer = vtk.vtkRenderer() | |
vtk_renderer.vtkInstance = vtk_renderer | |
for add_actor_item in add_actor: | |
vtk_renderer.AddActor(add_actor_item) | |
for active_camera_item in active_camera: | |
vtk_renderer.SetActiveCamera(active_camera_item) | |
vtk_renderer.SetBackground((0.0, 0.0, 0.0)) | |
vtk_renderer.ResetCamera() | |
# MODULE 46 org.vistrails.vistrails.vtk:VTKCell | |
# CONNECTION AddRenderer vtk_renderer | |
AddRenderer = [vtk_renderer] | |
renWin = vtk.vtkRenderWindow() | |
for renderer_item in AddRenderer: | |
renWin.AddRenderer(renderer_item) | |
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