[vtkusers] Converting surface/model coordinates to display coordinates

Syed Hassan Amin sha1 at doc.ic.ac.uk
Tue Sep 20 12:22:49 EDT 2005


I want to calculate p,q for the points of the face surface that are 
currently being rendered in display window. Now to calculate p,q :-
 p= Z(x,y)-Z(x-1,y)
 q=Z(x,y)-Z(x,y-1)
I need (x,y) of the screen and corresponding depth component of the 
surface.  First I determine the surface points that are on the screen. I 
do it as follows :

vtkIdFilter *ids=vtkIdFilter::New();
   vtkPolyData *model=vtkPolyData::New();
   model=lmk_reader->GetOutput();
   ids->SetInput(model);
   ids->PointIdsOn();
   vtkSelectVisiblePoints *visPtsSel=vtkSelectVisiblePoints::New();
   visPtsSel->SetInput(ids->GetOutput());
   visPtsSel->SetRenderer(ren1);
   vtkPolyData *visPoints=visPtsSel->GetOutput();
   visPoints->Update();
   int nPts=visPoints->GetNumberOfPoints();
   cout<<" Number of Points " << nPts << endl;
   //files
   fileio *fp=new fileio;
   fp->file_clear("c://xyz.txt");
   for (int i=0;i<nPts;i++)
   {
       double x[3];
       visPoints->GetPoint(i,x);
         //    cout<<" x= "<<x[0]<<"  y= "<<x[1]<<"  z= "<<x[2]<<endl;
       fp->file_writing(x,"c://xyz.txt");
   }
Now , this gives me points (x,y,z) of the face surface that are 
currently displayed in the screen window. But , I also need to determine 
which screen points(x,y) correspond to which surface points(x,y,z). In 
other words , I want to determine the screen coordinates for the choosen 
surface coordinates. Any help is most welcome.

Thanks,

Hassan Amin



More information about the vtkusers mailing list