[vtkusers] Re: Picking points from multiple surfaces.
Luke Hua
luke_qz at yahoo.com
Tue Feb 24 14:43:33 EST 2004
When you rotate your scene, it is the camera that rotates not the actor itself. So if the picker project a ray from the camera, it is not neccessary from the origin (0,0,0) cause your camera position has changed. The ray should be from the current possition of the camera to the object.
This is my understanding of the picker. I am not sure if it is true though.
BTW: if you use vtkcellpointer, do you eliminate the problem of getting the point from the back surface?
Thank you!
Luke
#23433; #32487;#19994; <an_jiye at hotmail.com> wrote:
Hi.
I have understood why the picking results are not as expected. Here are the
explanations.
There is a section in the vtk textbook introducing the picking functions of
vtk. Unfortunately, I only have the 2nd edition for vtk 2.0. But I think
the principle should be the same. Here I quote some contents from it.
"The Visualization Toolkit provides four classes to perform actor, point,
cell and world point picking. These are the classes vtkPicker,
vtkPointPicker, vtkCellPicker and vtkWorldPointPicker. These pickers vary
in speed and functionality as described in the following."
"The object vtkPicker intersects a ray defined from camera position to a
screen (i.e., pixel coordinate) against the bounding box of all pickable
and nontransparent actors. (An actor is pickable if its Pickable instance
variable is true.) The result of the vtkPicker pick operation is to return
a list of the actors whose bounding box is intersected. The actor closest
to the camera position is also returned."
"The object vtkPointPicker intersects the ray against the points defining
each actor, and returns the point coordinate closest to the camera
position, as well as the actor that the point belongs to. Since screen
resolution prevents precise selection of a point, a tolerance around the
ray must be specified. The tolerance is expressed as a fraction of the
rendering window size. (Rendering window size is measured across the window
diagonal) Points must lie within this tolerance to be picked."
==========================================================================================
According to the above introduction to vtkPointPicker, my problems can be
easily explained.
First, the returning points y coordinate is not necessarily one of the 1,
20, 39 and 49. This is because I set the camera position to (0, 0, 0). So
when I perform a picking, the ray is from origin to the cursor position. It
doesn't run parallel with the y-axis.
Second, I will get one or two points as a result. This is because the
vtkPointPicker will return both the point coordinate closest to the camera
position, and the actor that the point belongs to. When these two points
are actually the same, one point is returned.
Third, the points from the back surface are picked sometimes. This is
because the vtkPointPicker only pick the points defining each actor. So the
ray will traverse all the surfaces, no matter it is front or back. If it
doesn't intersect any points on the front surface, a back surface point
will be returned of course. And do not forget that the ray comes from the
origin (0, 0, 0).
Combining the second and third situation, you will probably get two points.
And neither of them is on the front surface.
==========================================================================================
Let's go on with other vtk pickers.
"The object vtkCellPicker intersects the ray with the cells defining each
actor, and returns the point of intersection, as well as the actor that the
cell belongs to. If you are trying to select a unique actor, vtkCellPicker
is the object to use because it performs surface (or cell) intersection.
Picking actors using vtkPicker can yield undesirable results because of the
overlap of bounding boxes; the same is true of vtkPointPicker because of
tolerance problems. Unfortunately, vtkCellPicker is the slowest object of
the three because of greater computational requirements."
==========================================================================================
So I decided to use vtkCellPicker for my picking application. Since the
camera affects the picking results directly. Remember to manipulate it
carefully. In my application, I set its position to ahead of the screen,
and at the middle of the z-axis, (32, -1, 46.5). Also I set the focal point
to (32, 63, 46.5), which lies in the center of the back most surfaces in my
former example. It works well for picking if user does not change the
camera or actor positions by vtkRenderWindowInteractor. But if this
happens, I still don't know how to deal with it.
==========================================================================================
For completeness, please allow me to introduce vtkWorldPointPicker at last.
"The calss vtkWorldPointPicker returns the (x,y,z) coordinate value of a
pick in the rendering window. To determine this information, it combines
the display (x,y) values with the z-buffer depth values. Of all the pickers
it is the fastest, but it cannot determine the actual cell, point or actor
that is selected. (Note: on some system z-buffer operations are inoperative
and this object will not function properly)"
Hope this will help some newbie who are performing picking in vtk, just
like me.
Best Regards,
Jiye An
_________________________________________________________________
#19982;#32852;#26426;#30340;#26379;#21451;#36827;#34892;#20132;#27969;#65292;#35831;#20351;#29992; MSN Messenger: http://messenger.msn.com/cn
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040224/84950f23/attachment.htm>
More information about the vtkusers
mailing list