Difference between revisions of "VTK/Examples/Python/DottedLine"

From KitwarePublic
< VTK‎ | Examples‎ | Python
Jump to navigationJump to search
(Created page with '==DottedLine.py== <source lang="python"> import vtk Line=vtkLineSource() Line.SetPoint1(-50,0,0) Line.SetPoint2(50,0,0) Line.SetResolution(100) Mapper=vtk.vtkPolyDataMapper()…')
 
 
Line 2: Line 2:
 
<source lang="python">
 
<source lang="python">
 
import vtk
 
import vtk
 
+
Line=vtkLineSource()
+
Line=vtk.vtkLineSource()
 
Line.SetPoint1(-50,0,0)
 
Line.SetPoint1(-50,0,0)
 
Line.SetPoint2(50,0,0)
 
Line.SetPoint2(50,0,0)
 
Line.SetResolution(100)
 
Line.SetResolution(100)
 
+
 
+
 
 
 
Mapper=vtk.vtkPolyDataMapper()
 
Mapper=vtk.vtkPolyDataMapper()
 
Mapper.SetInputConnection(Line.GetOutputPort())
 
Mapper.SetInputConnection(Line.GetOutputPort())
 
+
 
+
 
Actor=vtk.vtkActor()
 
Actor=vtk.vtkActor()
 
Actor.SetMapper(Mapper)
 
Actor.SetMapper(Mapper)
 
+
 
+
 
+
 
#create renderers and add actors of plane and cube
 
#create renderers and add actors of plane and cube
 
ren = vtk.vtkRenderer()
 
ren = vtk.vtkRenderer()
Line 27: Line 26:
 
Actor.GetProperty().SetPointSize(1)
 
Actor.GetProperty().SetPointSize(1)
 
Actor.GetProperty().SetLineWidth(1.5)
 
Actor.GetProperty().SetLineWidth(1.5)
 
+
 
#Add renderer to renderwindow and render
 
#Add renderer to renderwindow and render
 
renWin = vtk.vtkRenderWindow()
 
renWin = vtk.vtkRenderWindow()
Line 36: Line 35:
 
ren.SetBackground(0,0,0)
 
ren.SetBackground(0,0,0)
 
renWin.Render()
 
renWin.Render()
 +
iren.Start()
 
</source>
 
</source>

Latest revision as of 23:12, 28 May 2012

DottedLine.py

import vtk
 
Line=vtk.vtkLineSource()
Line.SetPoint1(-50,0,0)
Line.SetPoint2(50,0,0)
Line.SetResolution(100)
 
 
Mapper=vtk.vtkPolyDataMapper()
Mapper.SetInputConnection(Line.GetOutputPort())
 
 
Actor=vtk.vtkActor()
Actor.SetMapper(Mapper)
 
 
 
#create renderers and add actors of plane and cube
ren = vtk.vtkRenderer()
ren.AddActor(Actor)
Actor.GetProperty().SetColor(1,1,0)
Actor.GetProperty().SetLineStipplePattern(0xf0f0)
Actor.GetProperty().SetLineStippleRepeatFactor(1)
Actor.GetProperty().SetPointSize(1)
Actor.GetProperty().SetLineWidth(1.5)
 
#Add renderer to renderwindow and render
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(600, 600)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
ren.SetBackground(0,0,0)
renWin.Render()
iren.Start()