[vtkusers] Questions for picking.
An Jiye
an_jiye at hotmail.com
Wed Feb 18 00:50:32 EST 2004
Hi. It's me again.
Through most of my questions seem to be solved. There are still some
phenomena that confuse me.
With a carema lies right in front of the screen, the position and focal
point is:
aCamera->SetViewUp (0, 0, 1);
aCamera->SetPosition (32, -1, 46.5); <-- In front the center of the
front surface of A.
aCamera->SetFocalPoint (32, 63, 46.5); <-- The center of the back surface
of A.
aCamera->ComputeViewPlaneNormal();
aCamera->ParallelProjectionOn();
Now when I perform pickings, the value of y-axis will only be 1 or 20. It
means the picking points are from either the front surface of A or the
front surface of B. That's great!
But the coordinates like (0.349618, 1, 16.0183), (53, 1, 16.8), (16.4, 20,
27.2) and(43.6565, 20, 25.5363) occur. Note the x axis value of these four
results.
In my example the x-axis range of the front surface of A shoulbe be [5,
49], and for B [20, 39]. Why some points will exceed these ranges?
The same question occurs when goes to the z-axis. That is, I will get
coordinates like -4.44537 and 95.9695. But actually, the range should be
[0, 92].
Regards,
An Jiye
> 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
_________________________________________________________________
免费下载 MSN Explorer: http://explorer.msn.com/lccn
More information about the vtkusers
mailing list