[vtkusers] a problem about picking ( urgent )

lian jiang jl_vtk at yahoo.com
Fri Mar 22 20:58:27 EST 2002


      Very appreciate! 
      I have tried to associate one Actor to each of the Elliposid. But the vtkPicker and vtkCellPicker seem not be able to work yet because they alway return 0, which means no prop3D has been picked. I donot know what's the reason. 
     Here is my code: 
    1) ellipsoid definition 
           vtkUnstructuredGrid Dataset=new vtkUnstructuredGrid();
            vtkPoints    pointArray=new vtkPoints();
            vtkDoubleArray  tensorArray=new vtkDoubleArray();
            vtkSphereSource sphere = new vtkSphereSource();
            vtkTensorGlyph ellipsoids=new vtkTensorGlyph();
            vtkPolyDataMapper ellipMapper = new vtkPolyDataMapper();
            vtkPolyDataNormals ellipNormals=new vtkPolyDataNormals();
  
            tensorArray.SetNumberOfComponents(9); 
            pointArray.InsertNextPoint(objectArray[0].centroid);
            tensorArray.InsertNextTuple9(objectArray[0].tensor[0], objectArray[0].tensor[1], objectArray[0].tensor[2],
                                                       objectArray[0].tensor[3], objectArray[0].tensor[4], objectArray[0].tensor[5],
                                                       objectArray[0].tensor[6], objectArray[0].tensor[7], objectArray[0].tensor[8]);
            Dataset.SetPoints(pointArray);
            Dataset.GetPointData().SetTensors(tensorArray); 
            sphere.SetThetaResolution(20);
            sphere.SetPhiResolution(20); 
             ellipsoids.SetInput(Dataset);
             ellipsoids.SetSource(sphere.GetOutput());
             ellipsoids.ClampScalingOn(); 
             ellipNormals.SetInput(ellipsoids.GetOutput());
             ellipMapper.SetInput(ellipNormals.GetOutput());
             ellipActor.SetMapper(ellipMapper);   // I get ellipsoid actor

             ...

      2) picking ( in vtkPanel.java )

               public void mouseClicked(MouseEvent e) {
                           int i;
                           int PickX = e.getX();
                           int PickY = WindowHeight - e.getY();
 
                           Integer x = new Integer(PickX);
                           Integer y = new Integer(PickY);
 
                           i = myPicker.Pick(x.doubleValue(), y.doubleValue(), 0.0, render);

                           ....

                      }

             Then, i always equals 0;

             Please show me a way out. Maybe I should use another kind of data structure? Or vtkPicker can not pick such an actor?  I have tried some other kinds of actors such as vtkCone and some 3D polygon model actors, the code silimar to above can all work normally. 

             Thanks a lot!

 

Best Regards

 

Lian

 

          


 

  "K.R.Subramanian" <krs at cs.uncc.edu> wrote: Why is it a problem to assign an actor to each ellipsoid? This is the most
straightforward solution if you dont want to write additional code to
find the object. Else, you will need to compute the object intersected yourself
using a point picker..

-- 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/20020322/4984d3ea/attachment.htm>


More information about the vtkusers mailing list