[vtkusers] Transformation of vtkPolyData with an itk::Transform

Lodron, Gerald Gerald.Lodron at joanneum.at
Thu Dec 17 05:27:49 EST 2009


Hello

I currently made a point selector which stores it's points into a vtkPolyData structure.

Now I successfully made a image registration which converted the vtk image into itk, registered (transformed with itk::ResampleImageFilter) it and converted it back to vtk for visualization. Now the points of the vtkPolyData object are misaligned and I need to transform them. My point transformation implementation looks like this:


Input:

vtkPolyData poly;                       //Point cloud
Itk::Transformation<> transf;           //itk Transformation result of registration process

Code:
vtkSmartPointer<vtkPolyData> transformedpoly = vtkPolyData::New();      //new transformed polydata
Transformedpoly->DeepCopy(poly);

for(int j=0; j<poly->GetNumberOfPoints();j++)
{
        Itk::Transformation<> ::InputPointType point;
        for(int k=0; k < Transform33Type::InputPointType::PointDimension; k++)
        {
                point[k] = poly->GetPoint(j)[k];
        }
        Itk::Transformation<> ::OutputPointType transformedPoint = transform->TransformPoint(point);

        float afTransfPoint[Transform33Type::OutputPointType::PointDimension];

        for(int k=0; k < Transform33Type::OutputPointType::PointDimension; k++)
        {
                afTransfPoint[k] = transformedPoint[k];
        }
        Transformedpoly->GetPoints()->SetPoint(j,afTransfPoint);
}

The problem is that the points does not fit to their old position, so there must be something wrong with the transformPoint operation?

Best regards




More information about the vtkusers mailing list