[vtkusers] Picking points?

Bert VanSesamstraat bertvansesamstraat at hotmail.com
Wed Aug 21 04:50:49 EDT 2002


Dear all,
My question is quite easy,
I want to pick some points of an image.
I do this using the following script:


package require vtk
package require vtkinteraction
package require vtktesting




# Start by loading some data.
#


vtkImageReader v16
  v16 DebugOff
  v16 SetDataByteOrderToBigEndian
  v16 SetDataExtent 0 511 0 80 1 81
  v16 SetFileName "dataInt81_81.raw"
  v16 SetDataOrigin 0 0 0
  v16 SetFileDimensionality 3
  v16 Update

vtkImageShiftScale shiftScale
  shiftScale SetInput [v16 GetOutput]
  shiftScale SetShift 0
  shiftScale SetScale 0.07
  shiftScale SetOutputScalarTypeToUnsignedChar

vtkImageActor ia
  ia SetInput [shiftScale GetOutput]
  ia SetZSlice 14

# Create the RenderWindow, Renderer and both Actors
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1


vtkPointPicker LocalPicker
  LocalPicker SetEndPickMethod HandleLocalPick
  LocalPicker SetTolerance 0.2

vtkRenderWindowInteractor LocalInteractor
  LocalInteractor SetRenderWindow renWin
  LocalInteractor SetLightFollowCamera 1
  LocalInteractor SetPicker LocalPicker
  LocalInteractor Initialize




# Add the actors to the renderer, set the background and size
ren1 AddActor ia



# render the image
LocalInteractor AddObserver UserEvent {wm deiconify .vtkInteract}
renWin Render

set cam1 [ren1 GetActiveCamera]

#ren1 ResetCameraClippingRange
renWin Render

# prevent the tk window from showing up then start the event loop
wm withdraw .

proc HandleLocalPick {} {
    set pid [LocalPicker GetPointId]
    puts "$pid"
    # Test the actor that was hit: depending on the
    # actor, select the point data from the part of
    # the pipeline that was used to produce the
    # actor.
    if { $pid >= 0 } {
    	set pickPos [[LocalInteractor GetPicker] GetPickPosition]
	set xp [lindex $pickPos 0]
	set yp [lindex $pickPos 1]
	set zp [lindex $pickPos 2]
	puts "$xp   $yp    $zp   "
       puts "picked"

    		     }
                        }


As fas as I understand the procedure you get the actor by $pid which can be 
used to get the actual pickpoints.
I tried this script with several values of the tolerance but $pid stays -1.
Can someone please help me?


_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com




More information about the vtkusers mailing list