[vtkusers] Re: casting one ray

John Biddiscombe john.biddiscombe at mirada-solutions.com
Wed Aug 27 06:07:34 EDT 2003


Set the start and end point to the nearest and farthest points of the volume (as viweed by the ray). Set the resolution of the linesource to be as high as the pixel size so that you sample each voxel as you pass through,

then 

probe->update();
vtkPolyData *vals = probe->GetOutput() (assum,ing probe output is float data, which may not be correct if the volume has unsigned short or somthig)

vtkFloatArray *scalars = vals->GetScalars();
for (int i=0; i<scalars->GetNumberOfTuples(); i++) {
  float val = scalars->GetTuple(i);
}

you'll need to play around with what I've typed as I've just done it quickly from memory and it's probably wrong, but that's the general idea. For faster iteration you can

vtkFloatArray *scalars = vals->GetScalars();
float *floatdat = (float*)scalars->GetVoidPointer();
or getPointer if it's a vtkfloatarray

etc
etc

JB

RPD : A drag drop front end for vtk 
www.skippingmouse.co.uk


> -----Original Message-----
> From: Nico Vermaas [mailto:vermaas at astron.nl]
> Sent: 27 August 2003 10:04
> To: John Biddiscombe; vtkusers at vtk.org
> Subject: RE: [vtkusers] Re: casting one ray
> 
> 
> Hi John,
> 
> That is what I tried also. In fact I take a line from the 
> camera worldcoords to the picked point worldcoords. I do get 
> some good results when I display that probe in a xyplot, I 
> can see the values on the ray then (and I can see that the 
> pick indeed does not stop at the max pixel, but goes right through).
> 
> But.. how do I loop over those values? How do I get to that 
> data in the probe?
> 
> Nico
> 
> ====================================================
> Nico Vermaas
> ASTRON - Westerbork Synthesis Radio Telescope
> Schattenberg 1 - 9433 TA Zwiggelte - The Netherlands
> 
> tel: +31 593 598710                 
> vermaas at astron.nl 
> ====================================================
> 
> >>> "John Biddiscombe" 
> <john.biddiscombe at mirada-solutions.com> 08/27/03 10:53 AM >>>
> Just use a probefilter and a linesource with plenty of 
> samples on it, then loop over each probed value to find the 
> max. You can set the line source based on camera view 
> direction and pixel location of screen pixel in world space.
> 
> JB
> 
> 
> > -----Original Message-----
> > From: Nico Vermaas [mailto:vermaas at astron.nl]
> > Sent: 27 August 2003 08:37
> > To: vtkusers at vtk.org
> > Subject: [vtkusers] Re: casting one ray
> > 
> > 
> > Hi,
> > 
> > But then I am back to square 1 with my original problem for 
> > which I am trying to find a solution. 
> > Let me explain.
> > 
> > I am picking on a MIP raycasted volume, but the result is not 
> > the maximum pixel along the ray, but a pixel somewhere in the 
> > middle of the volume. I don't know where and why the ray 
> > stops or why it takes that particular pixel.
> > 
> > Is there some way to configure the pick? To tell it to go on 
> > until it finds some threshhold? Or to return the pixel with 
> > the maximum/minimum/average value along the ray?
> > 
> > Or is there another way to cast one ray and get back the MIP result?
> > 
> > Nico
> > 
> > 
> > -------------
> > Date: Tue, 26 Aug 2003 17:49:22 +0200
> > From: "Jean M. Favre" <jfavre at cscs.ch>
> > Organization: CSCS
> > To: Nico Vermaas <vermaas at astron.nl>
> > Cc: vtkusers at public.kitware.com
> > Subject: Re: [vtkusers] casting one ray?
> > 
> > Nico Vermaas wrote:
> > > 
> > > How can I cast one ray from one screen location?
> > > 
> > 
> > How about the following manual page:
> > 
> > virtual int vtkPicker::Pick(float selectionX, 
> >                             float selectionY, 
> >                             float selectionZ, 
> >                             vtkRenderer *renderer) 
> >        
> >       Perform pick operation with selection point provided. 
> > Normally the
> > first two values for the selection point are x-y pixel 
> coordinate, and
> > the third value is =0. Return non-zero if something was successfully
> > picked.
> >  
> > -- 
> > Dr. Jean M. Favre,                            email:favre at cscs.ch
> > http://www.cscs.ch/people/Favre.html
> > CSCS, Swiss Center for Scientific Computing | Tel:  +41 
> (91) 610.82.40
> > Via Cantonale, 6928 Manno, Switzerland      | Fax:  +41 
> (91) 610.82.82
> > 
> > --__--__--
> > 
> > _______________________________________________
> > This is the private VTK discussion list. 
> > Please keep messages on-topic. Check the FAQ at: 
> > <http://public.kitware.com/cgi-bin/vtkfaq>
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> > 
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: 
> <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 



More information about the vtkusers mailing list