[vtkusers] illustrate a line

Eric E. Monson emonson at cs.duke.edu
Mon Jan 19 17:24:51 EST 2009


Hello,

If you just want to draw a single line, you can do something like this  
(which is just a version of the VTK/Examples/Tutorial/Step5/Python/ 
Cone5.py with cone changed to line, plus setting the start and end  
points of the line):
================
import vtk

line = vtk.vtkLineSource()
line.SetPoint1(1,0,0)
line.SetPoint2(0,1,0)
line.SetResolution( 10 )

lineMapper = vtk.vtkPolyDataMapper()
lineMapper.SetInputConnection( line.GetOutputPort() )

lineActor = vtk.vtkActor()
lineActor.SetMapper( lineMapper )

ren1= vtk.vtkRenderer()
ren1.AddActor( lineActor )
ren1.SetBackground( 0.1, 0.2, 0.4 )

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer( ren1 )
renWin.SetSize( 300, 300 )

iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

style = vtk.vtkInteractorStyleTrackballCamera()
iren.SetInteractorStyle(style)

iren.Initialize()
iren.Start()
================

There is a class, vtkPoints, for representing sets of points. I have a  
feeling, though, that you're not being specific enough with your  
question. There are a few different types of data objects that can be  
used to store/represent your data, and the right one will depend upon  
how your data is structured (e.g. vtkImageData, vtkPolyData,  
vtkUnstructuredGrid, etc.).

If you have access to the VTK books, they are a great way to learn ( http://www.kitware.com/products/books.html 
  ), and there are a lot of good examples that come with the source  
code, including Python.

-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Jan 19, 2009, at 4:06 PM, אליה מירוב wrote:

> Hi all,
>
> what is the best way to illustrate a line between - given two space  
> points?
> and what is a good way to represent points?
> i.e
> given (1,0,0) and (0,1,0) ==>
> vtkPython script illustrates  the line : (t,1-t,0)
>
> thank you!
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list