[vtkusers] about the picking of vtkTensorGlyph

Malcolm Drummond malcolm at geovision.co.za
Thu Mar 28 04:28:24 EST 2002


Hi Lian

I hope I'm not misunderstanding what you're trying to do.

If you insert the following line at the end of the TenEllip.tcl script you get the answer 96 216 20736 ...

tk_messageBox -message "[[ellipsoids GetSource] GetNumberOfCells] [[ellipsoids GetInput] GetNumberOfPoints] [[ellipsoids GetOutput] GetNumberOfCells]"

... so that works. Make sure that you're only querying after everything has been set and executed. The glyph filter copies and transforms the source dataset for every point in the input dataset - so in the case of TenEllip.tcl there will be 96*216 = 20736 cells in the output dataset. If your cell-picker returns 56, integer division by 96 gives 0 - so cell 56 in the output dataset corresponds to point 0 in the input dataset. Similarly cell-id 18921 in the output dataset corresponds to point 197 in the input dataset. Now that you have a point id corresponding to the input dataset you can use it to look up and display any values from the input datset.   

Malcolm

  ----- Original Message ----- 
  From: lian jiang 
  To: Malcolm Drummond 
  Cc: vtkusers 
  Sent: Thursday, March 28, 2002 8:52 AM
  Subject: Re: [vtkusers] about the picking of vtkTensorGlyph


  Hi, Malcolm: 

          Thank you for your answer. 

          I tried to use ellipsoids.GetSource() to get the vtkPolyData first. Then I use GetNumberOfCells() to get the number of cells. But I always got 0 as the number. 

          I also tried to use GetCellType() to verify whether I had gotten the correct vtkPolyData, but it also always was 0. 

          What's the matter,  please? 

           If I get the right cell set, could you please tell me which method of vtkPolyData should be used to get Point Id from the Cell Id?  Thank you again. 

   

  Regards 

   

  Lian 

    Malcolm Drummond <malcolm at geovision.co.za> wrote: 

    Hi Lian

    If you use cell-picker you can integer-divide the cell-id by the number of cells in the source (use GetNumberOfCells). You'll then have the id of the point & scalar in Dataset associated with the picked glyph.
     
    Malcolm 
      ----- Original Message ----- 
      From: lian jiang 
      To: vtkusers at public.kitware.com 
      Sent: Wednesday, March 27, 2002 4:35 PM
      Subject: [vtkusers] about the picking of vtkTensorGlyph


      Hi, all:

              For picking a object in a vtkTensorGlyph, I have gotten the non-zero return value with vtkPointPicker and vtkCellPicker. Which picker should I use to figure out which object I have picked? 

              vtkTensorGlyph seems to be different from Glyph3D, so the methods disscussed before couldn't be used here. How can I export the vtkTensorGlyph to an indexed cell set or point set?  How can I associate a cell or a point with some specific object in the vtkTensorGlyph?  Thanks a lot!

      Below is the code building the vtkTensorGlyph.

      vtkUnstructuredGrid Dataset=new vtkUnstructuredGrid();
        vtkPoints    pointArray=new vtkPoints();
        vtkDoubleArray  colorArray=new vtkDoubleArray();
        vtkDoubleArray  tensorArray=new vtkDoubleArray();
        vtkSphereSource sphere = new vtkSphereSource();
        vtkTensorGlyph ellipsoids=new vtkTensorGlyph();
        vtkPolyDataMapper ellipMapper = new vtkPolyDataMapper();
        vtkPolyDataNormals ellipNormals=new vtkPolyDataNormals();

        vtkActor    ellipActor=new vtkActor();
        
        tensorArray.SetNumberOfComponents(9);

        for(i=0; i<numObjects; i++)
        {
          pointArray.InsertNextPoint(objectArray[i].centroid);
          tensorArray.InsertNextTuple9(objectArray[i].tensor[0], objectArray[i].tensor[1], objectArray[i].tensor[2],
               objectArray[i].tensor[3], objectArray[i].tensor[4], objectArray[i].tensor[5],
               objectArray[i].tensor[6], objectArray[i].tensor[7], objectArray[i].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
      ////////////////////////////////////////////////////////////////////////////



      BEST REGARDS



      Lian





--------------------------------------------------------------------------
      Do You Yahoo!?
      Yahoo! Movies - coverage of the 74th Academy Awards®




------------------------------------------------------------------------------
  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/20020328/0fdcd742/attachment.htm>


More information about the vtkusers mailing list