Hey Henrik,<br><br>Thanks for the clarification, I understand your solution but I don't think it's approperiate for Meisam's and my situation. We, at least I (and i presume Meisam does also), use glyphs to create a certain source at each point. In effect we only have a single mapper (a glyphMapper) and a single actor (a glyphActor).
<br><br>So there is no easy way to get from picker.GetMapper() to the approperiate Actor. In fact when i try what you do I get returned an OpenGLActor... I've tried asking questions about this on the list before but I didn't get any responses. In the mean time i did find out (perphaps helpful for Meisam) that if you use a Glyph3D or Glyph2D you can GeneratePointId's which will enable you to deduct to which glyph the point you picked is contributing (if i understand correctly). I on the other hand use the ProgrammableGlyphFilter which does not have this option so i still remain clueless on how to get from a pick action to the vertex or glyph-center i want.
<br><br>Regards - Geofram<br><br><div><span class="gmail_quote">On 6/14/07, <b class="gmail_sendername">Henrik Westerberg</b> <<a href="mailto:henrik.westerberg@crg.es">henrik.westerberg@crg.es</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<br>
<br>
<p><font size="2">Hi folks,<br>
<br>
Ok, for my app I have a vtk file which consists a bunch<br>
of blobs. I find actors by first finding the number of blobs:<br>
<br>
# some vtk in python<br>
polyImg = vtkPolyDataReader())<br>
polyImg.SetFileName(name)<br>
<br>
# extract all regions for the blobs<br>
connImg = vtkPolyDataConnectivityFilter())<br>
connImg.SetExtractionModeToAllRegions()<br>
connImg.SetInput(polyImg.GetOutput())<br>
<br>
# update to get the number of blobs<br>
connImg.Update()<br>
<br>
# get the number of blobs<br>
numofblobs = connImg.GetNumberOfExtractedRegions()<br>
<br>
The blobs are then extrated into a list of mappers and actors using:<br>
<br>
# loop over the number of blobs (i)<br>
blobMappers.append(vtkPolyDataMapper())<br>
<br>
tempImg = vtkPolyDataConnectivityFilter()<br>
tempImg.SetExtractionModeToSpecifiedRegions()<br>
tempImg.SetInput(connImg.GetOutput())<br>
tempImg.AddSpecifiedRegion(i)<br>
<br>
blobMappers[i].SetInput(tempImg.GetOutput())<br>
blobActors.append(vtkActor())<br>
blobActors[i].SetMapper(blobMappers[i])<br>
<br>
ren1.AddActor(blobActors[i])<br>
<br>
I can then use vtkPicker.GetMapper() to get the mapper which was picked,<br>
and therefore the actor as they are created at the same time.<br>
<br>
# find the actor<br>
def handlePick(object, event):<br>
mapper = picker.GetMapper()<br>
for i in range(0, numofblobs 1):<br>
if mapper == blobMappers[i]: # find the mapper<br>
# do some stuff<br>
# i also indicates the correct actor<br>
<br>
Reading in all the blobs is a bit slow (100 or so blobs) but it works.<br>
<br>
hth,<br><span class="sg">
<br>
Henrik</span></font></p><div><span class="e" id="q_1132a54e2f4fd4a2_2"><font size="2"><br>
<br>
-----Original Message-----<br>
From: vtkusers-bounces+henrik.westerberg=<a href="mailto:crg.es@vtk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">crg.es@vtk.org</a> on behalf of Geoframer<br>
Sent: Thu 6/14/2007 2:00 PM<br>
To: Meisam Aliroteh<br>
Cc: <a href="mailto:vtkusers@vtk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">vtkusers@vtk.org</a><br>
Subject: Re: [vtkusers] Picking and moving a vertex<br>
<br>
I think you can at least get the starting position by using the<br>
picker.GetPickPosition() although this is not your center of the vertex but<br>
the coordinates on the glyph. It is at least in 3D coordinates. To get the<br>
real starting point you should indeed get the Actor that is picked upon and<br>
use it's GetCenter() to retrieve the center of the glyph.<br>
<br>
I haven't been able to pull this off though. When i try to get the Actor i'm<br>
picking on i seem to pick the picker's actor for my GetCenter() always<br>
returns the middle of the data instead of the middle of the vertex.<br>
<br>
In any case I'm quite curious how you can go from a cellId to the<br>
approperiate vertex... Do you just integer divide by the number of cells per<br>
glyph?<br>
<br>
Perhaps Henrik can shed some more light on how you can actually get the<br>
actor of the glyph when picking?<br>
<br>
Regards - Geofram<br>
<br>
On 6/13/07, Meisam Aliroteh <<a href="mailto:meisam.aliroteh@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">meisam.aliroteh@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I have a polydata and used a sphere source to render the polydata in<br>
> point-cloud mode (i.e only vertices are rendered, and I use spheres to<br>
> show these vertices). I want the user to be able to click on any vertex<br>
> (shpere) and move it in the 3D space (well actually it would be a motion<br>
> restricted to the current view plane). I used vtkCellPicker and know how to<br>
> figure out which vertex is picked when the user clicks on it. What I don't<br>
> know is how to figure out the motion vector when the user clicks and drags a<br>
> sphere ? I can get the old and new mouse positions from the interactor but<br>
> these are 2D coordinates.<br>
><br>
> I guess what I need is the 3D coordinates of the previous and current<br>
> mouse positions, so that when I subtract these 3D coordiantes I get a motion<br>
> vector and then I can move the picked vertex by adding this motion vector to<br>
> it. The problem is I don't know how to get the 3D coordinate of the mouse<br>
> pointer using VTK !!!<br>
><br>
> Any ideas?<br>
><br>
> _______________________________________________<br>
> This is the private VTK discussion list.<br>
> Please keep messages on-topic. Check the FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
><br>
<br>
</font></span></div><font size="2"></font>
<p></p>
</div>
</blockquote></div><br>