[vtkusers] drawing lines on curve surface

Sebastien BARRE seb-ml-vtk at barre.nom.fr
Thu Nov 23 18:21:12 EST 2000


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.

Then connect your points. If you are drawing loops, just have a look at 
vtkSelectPolyData and its GetSelectionEdges method, then feed your points 
to that filter. It should looks like this :
http://www.geocities.com/barre242/selectpolydata-ex.jpg

If not, or if you want to link the points during the interaction (i.e. 
build the line on the fly), then look at the vtkSelectPolyData 
implementation : basically, you should build the neighborhood topology for 
the objet (BuildLinks()), then starting from a point, follow the polygon 
edges until you reach the other point. Track the edges in the direction of 
the line separating the two points (and modify that direction at each 
edge). Then start with the next pair of points. It's not guaranteed that 
it's the shortest path, but hey... :)







More information about the vtkusers mailing list