[vtkusers] drawing lines on curve surface
Fabrice Vincent
fabrice.vincent at creatis.insa-lyon.fr
Fri Nov 24 09:03:32 EST 2000
Sebastien BARRE wrote:
> At 23/11/2000 14:05, Tao-Pak Chris Tsui wrote:
>
> >I have a 3D skull object made up of marching cubes...
> >what should I do if I want to draw irregular shape
> >polygon on the surface of the skull when I click on
> >it? to make it clear, the line should be LYING on the
> >surface of the skull instead of intersecting the
> >curved surface with a straight line...
>
> Well, here is a quick idea :
>
> I'm not sure you will be able to "draw", but anyway, you might try to
> sample user movements at some specific rate, and use some of the
> vtkPicker(s) to retrieve the point the user has clicked on. Something like
> (Tcl) :
>
> vtkPointPicker picker
> picker Pick $x $y 0 $viewport
> if {[picker GetPointId] != "-1" } {
> set id [picker GetPointId]
> }
> the picker will return the point Id of the point in the dataset (use
> GetPoint on the dataset to get the list of x,y,z coordinates).
>
> Actually, it behaves strangely in my app, the returned point is always more
> or less shifted from the actual mouse pointer position : that should be
> normal because the actual vertice might not be directly under the pointer,
> but my mesh resolution is high, and there were points much nearer the
> returned point. Should investigate.
The strange behaviour of your picker may come from the way the variables x and y are defined,
because I think the coordinate system
of a tcl widget and a vtk window are different.
So if x and y come from a tcl binding like :
bind $widget <Shift-B1-Motion> {SelectPoint %W %x %y}
then, in the function SelectPoint you should do :
proc SelectPoint { widget x y } {
# get the height of the tcl widget
set WindowY [lindex [$widget configure -height] 4]
Picker Pick $x [expr $WindowY - $y - 1] 0.0 $CurrentRenderer
}
I use this code with a vtkWorldPointPicker, and it works fine. It should work for vtkPointPicker
too.
Fabrice
--
Fabrice VINCENT
CREATIS (CNRS UMR 5515), INSA 502, 69621 Villeurbanne, FRANCE
email: fabrice.vincent at creatis.insa-lyon.fr
Tel. : +33 (0)4 72 43 63 06
Fax : +33 (0)4 72 43 85 26
More information about the vtkusers
mailing list