[vtkusers] How to get point positions of a Polyline (vtkCell?)

aselmann at gmx.de aselmann at gmx.de
Tue Jul 22 09:52:34 EDT 2003


hello,

I'm trying to get the positions of a Polyline to follow a camera picked
polyline, but I don't know what vtkclass will give me the pointpositions
(vtkCell, vtkCellArray, vtkCellLinks, vtkIdFilter?)

so far modifications on annotatePick.py
#!/usr/bin/env python
import vtk
reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName("Data_polyline.vtk")
reader.Update()
geom = vtk.vtkGeometryFilter()
geom.SetInput(reader.GetOutput())
lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(256)
lut.SetHueRange(0.667, 0.0)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInput(geom.GetOutput())
mapper.SetLookupTable(lut)
mapper.SetScalarRange(0, 16)
aktor = vtk.vtkActor()
aktor.SetMapper(mapper)

# Create a text mapper and actor to display the results of picking.
textMapper = vtk.vtkTextMapper()
tprop = textMapper.GetTextProperty()
tprop.SetFontFamilyToArial()
tprop.SetFontSize(10)
tprop.BoldOn()
tprop.ShadowOn()
tprop.SetColor(1, 0, 0)
textActor = vtk.vtkActor2D()
textActor.VisibilityOff()
textActor.SetMapper(textMapper)

# Create a cell picker.
picker = vtk.vtkCellPicker()

kamera = vtk.vtkCamera()

# Create a Python function to follow a Polyline with a camera
def notierePick(object, event):
    global picker, textActor, textMapper ,kamera
    if picker.GetCellId() < 0:
        textActor.VisibilityOff()
    else:
        selPt = picker.GetSelectionPoint() 
	pickCid = picker.GetCellId()
        pickPos = picker.GetPickPosition()
	
        ### loop to put the position of polyline in here	
        ###for i in range(0,numPts): 
	    kamera.SetPosition(selPt[:3]) ### loop to put the position of polyline
in here
	    kamera.SetFocalPoint(0 ,0 ,0)
	    ren1.SetActiveCamera(kamera)
	
        
# Now at the end of the pick event call the above function.
picker.AddObserver("EndPickEvent", notierePick)

ren1 = vtk.vtkRenderer()
ren1.SetBackground(1,1,1)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetPicker(picker)
ren1.AddActor2D(textActor)
ren1.AddActor(aktor)
renWin.SetSize(500, 500)
iren.Initialize()
renWin.Render()
iren.Start()

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++

Jetzt ein- oder umsteigen und USB-Speicheruhr als Prämie sichern!




More information about the vtkusers mailing list