[vtkusers] a problem about picking ( urgent )
lian jiang
jl_vtk at yahoo.com
Sat Mar 23 09:44:15 EST 2002
Hi, Krs:
Because I use java and vtkPanel, I need not associate a vtkPicker with an interactor, in fact, there is no interactor in java-vtk program at all. I have tried picking other normal actors such as cone or sphere in the same way, it works well. So I think there is no any problem with vtkPicker. One possible reason maybe vtkTensorGlyph ( or even vtkGlyph2D and vtkGlyph3D ) is incomptible with vtkPicker.( ? ) However, I know from the mail list that some people can pick objects of glyph, and there is also a possible way to figure out which glyph object I have picked even if all of the glyph objects are rendered with only one actor.
So have you any idea ? Thanks a lot.
Below are some abstract of the relative mail list:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
" Hi Jiaye-
Pick the point with the point picker, get a point id.
Use this point id to get the value of input point id, something like:
vtkDataArray *inputIds =
glyph->GetOutput()->GetPointData()->GetArray("InputPointIds");
inputId = inputIds->GetTuple1(pickedId);
You have to have the latest vtk4.0 for this to work.
Will "
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
"
>There is a method in vtkGlyph3D and vtkGlyph2D (very recently added) called
>GeneratePointIdsOn/Off. This causes the glyphers to generate a field of ids
>associated with each output point. Then if you use a pointpicker or
>cellpicker to pick a point (from the output of the glyph), you can then use
>the picked point id to index into the generated point ids. You'll have to
>get the nightly release or use CVS to get this feature.
>
>Will
"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
"Hi Malcolm,
Thanks for the reply. I looked at vtkProgrammableGlyphFilter. I think I
understand what's going on. Following the tcl example included in the
distribution, I used vtkTransform, vtkTransformPolyDataFilter, and
vtkProgrammableGlyphFilter. I am using Java, so when it comes to setting the
GlyphMethod, I am lost at mapping to Java code. (I'm not sure how I can pass
the address of a method, since in C++ I could use &proc_name, but I don't
have an & in Java)
Anyway, leaving implementation issue behind, do I seem to be on the right
track though? Back to the implementation issue, would you happen to be using
Java, or something other than tcl? If so, would you have any suggestions on
how this can be approached? Thank you for your help.
jiaye
"
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
"Hi Jiaye
I use spheres to represent multiple seismic events with one actor. I get =
around picking by using a programmable glyph filter and building a =
lookup-table based on cell-ids on each iteration of the GlyphMethod. =
When you do a pick on the actor you can then get the id of your input =
point from the id of the picked cell.
=20
I hope this helps
"
Best Wishes
Lian
"K.R.Subramanian" <krs at cs.uncc.edu> wrote: Lian:
You create a vtkPointPicker and then assign it to the interactor. Then you write
a callback function. As I have done in one of my applications which is
reproduced below; here
I am determining the position of the picked point. There should be a method
to also return the actor that was picked.
Hope that helps.
-- krs
void ivus3dPick (void *arg)
{
vtkXRenderWindowInteractor
*interactor = (vtkXRenderWindowInteractor *) arg;
vtkPointPicker *picker = (vtkPointPicker *) interactor->GetPicker();
if (picker->GetPointId() >= 0)
{
cout << "Point id: " << picker->GetPointId() << "\n" << flush;
float *a = picker->GetPickPosition();
cout << "Pick Position: " << a[0] <<"," << a[1] <<"," << a[2]
<< endl << flush;
}
interactor->GetRenderWindow()->Render();
}
*************
What you are doing is call the Pick method directly - this should also do
something similar - what I show above is interactive picking using the mouse
(in the default bindings, placing the mouse over the object and hitting the key 'p'
should call the above function and output the position coordinates.) Of course,
if the ray doesnt hit anything, then you will return a negative value..
Hope that helps.
-- krs
--
K.R.Subramanian Phone: (704) 687-4872
Department of Computer Science FAX: (704) 687-4893
UNC Charlotte, CARC 311 Email: krs at cs.uncc.edu
Charlotte, NC 28223-0001 Web: http://www.cs.uncc.edu/~krs
---------------------------------
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020323/7775f608/attachment.htm>
More information about the vtkusers
mailing list