[vtkusers] how to get the world coordinates of a point?

Michael Knopke Michael.Knopke at gmx.de
Tue Jul 10 03:57:23 EDT 2007


Hi Lin Zhang,

 

I had the same "problem" as you before. The reason is, that when applying
any transformation/rotation matrix to a dataset (e.g. with vtkTransform) it
will not change the position of the original points. (It changes only the
position of actors but you can't querry their WorldCoordinates)

You will have to use vtkTransformPolyDataFilter on the dataset to really
transform it.

 

Here is an example (translating one point only):

 

    vtkPoints *inputPoints2 = vtkPoints::New();   

                    inputPoints2->SetDataTypeToDouble();

                    inputPoints2->SetNumberOfPoints(1);

                    inputPoints2->SetPoint(0,corPos);

 

 

   vtkPolyData *poly2 = vtkPolyData::New();

                      poly2->SetPoints(inputPoints1);               

 

   vtkTransformPolyDataFilter *transPolyData2 =
vtkTransformPolyDataFilter::New();

                      transPolyData2->SetInput(poly2);

                      transPolyData2->SetTransform(sag_mprTransform);     

                      transPolyData2->Update();

 

                      vtkPoints *outputPoints2
=transPolyData2->GetOutput()->GetPoints();

                      double TranslatedPoint2[3];

                      TranslatedPoint2 = outputPoints2->GetPoint(0);    

 

   transPolyData->Delete();

   poly2->Delete();

   inputPoints2->Delete();

   outputPoints2->Delete();

 

Better to look for vtkTransformPolyDataFilter to get better examples.

 

Regards

 

Michael

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070710/f4495bdc/attachment.htm>


More information about the vtkusers mailing list