| 
		
			| Re: Anatomic object graphic in IDL [message #43755] | Wed, 27 April 2005 09:21  |  
			| 
				
				
					|  Rick Towler Messages: 821
 Registered: August 1998
 | Senior Member |  |  |  
	| Valentine wrote: >  Ok, what I mean is to return the
 >  coordinates (or better, their indexes) of a polygon of a
 >  polygon-model. I mean, I want to Know exactly which are the indexes
 >  (x,y,z) of the object when I push down in my model with the mouse.
 
 There is no built in function in IDL to do this that I know of...
 
 Off the top of my head you would need to select your object, cast a ray
 from your viewpoint thru that object, then perform triangle/ray
 intersection tests on that object's polys.  Selection is built into IDL.
 Polygon/ray intersection is well published on the web and there are
 many algorithms to choose from (Here is an excellent resource:
 http://www.realtimerendering.com/int/   I've used the Haines ray/poly
 code with success.  I like the Gems code since it is available online
 and it is straightforward C.  Easy to drop into a dlm.)
 
 But casting the ray will take a bit more work.
 
 Using the view parameters, I would construct the view pyramid (far clip
 plane to viewpoint). Then when you click on your window, get the X,Y
 window coordinates of the mouse click.  Assuming your view is projected
 onto the near plane, your near plane location will give you your Z.
 Then cast your ray from your viewpoint thru this X,Y,Z location.  My
 guess is that your coordinates returned from PickData will be in screen
 coords but you should be able to calculate position on the projection
 plane by normalizing the screen coordinates.
 
 This approach may not work and even if it does there probably is a
 better way to cast your ray.  I got very little sleep last night since
 my son has been fighting a cold and was up all night crying so I am not
 thinking too clearly (It was like when he was a newborn.)  But at any
 rate this should get you started. :)
 
 -Rick
 |  
	|  |  | 
	| 
		
			| Re: Anatomic object graphic in IDL [message #43774 is a reply to message #43755] | Tue, 26 April 2005 05:31   |  
			| 
				
				
					|  vaesgar Messages: 3
 Registered: April 2005
 | Junior Member |  |  |  
	| Ok, what I mean is to return the coordinates (or better, their indexes) of a polygon of a
 polygon-model. I mean, I want to Know exactly which are the indexes
 (x,y,z) of the object when I push down in my model with the mouse.I
 have used the next code to get it, but it doesn�t work.It only get me
 values that belong (I think) to the coordinates of the window.
 
 oarray = self.ocontainer->get(/ALL)
 opolygon = oarray[N_ELEMENTS(oarray)-1]
 
 oSel = self.oWindow -> Select(self.oTransparentView,[event.x,
 event.y],UNITS=[3] ); returns object array
 IF Size(oSel, /TName) EQ 'opolygon' THEN BEGIN
 pick = self.oWindow-> PickData(self.oTransparentView,
 osel,$
 [event.x, event.y], dataxyz,pick_status=tt)
 
 
 Where oTransparentView is my View.
 
 Thanks, again
 |  
	|  |  | 
	|  | 
	| 
		
			| Re: Anatomic object graphic in IDL [message #43950 is a reply to message #43755] | Tue, 10 May 2005 07:02  |  
			| 
				
				
					|  vaesgar Messages: 3
 Registered: April 2005
 | Junior Member |  |  |  
	| At first,many thanks for your information.I hope your son is bettern now, so you could better sleep.
 I am now studing the adress you gave me.But I still haven�t found the
 solution.
 Nevertheless, I am wrinting you to ask another question.Do you Know
 how to reduce the size of the triangles in an Idlgrpolygon mesh?
 Thanks again,
 Valentine
 |  
	|  |  |