Hello List,

I´m trying to load an itk transform from file (e.g. coming from some 
previous registration calculation, such as itk::Translation or 
itk::ScalableAffineTransform)

I can successfully apply such transformation to a given image but when 
doing the same to a mesh, I don´t get the correct result.

I treat both, image and mesh as generic mitk::DataNode

The objective of this exercise is e.g. to transform an image and a 
segmentation (mesh) outlined on it

Find below my code.

thank you!

    // load the transformation from disk
     QString fileName = QFileDialog::getOpenFileName(NULL, "Load 
transform file...", exportDir, "PAR file (*.par)");
     if (fileName.isEmpty()) return;

     exportDir = QFileInfo(fileName).absoluteDir().path();

     // use itk transform reader (not transformation factory)
     itk::TransformFileReader::Pointer reader = 
itk::TransformFileReader::New();
     reader->SetFileName(fileName.toAscii());
     try
     {
         reader->Update();
     }
     catch (itk::ExceptionObject e)
     {
       MITK_INFO << "Caught exception: " << e.GetDescription();
       QMessageBox::information(NULL, "Reader exception", 
e.GetDescription() );
     }

     itk::Array<double> transformParams = 
reader->GetTransformList()->front()->GetParameters();

     vtkMatrix4x4* _vtkmatrix = vtkMatrix4x4::New();
     _vtkmatrix->Identity();

     if (transformParams.size() == 3)
     {
       _vtkmatrix->SetElement(0, 3, transformParams[0]);
       _vtkmatrix->SetElement(1, 3, transformParams[1]);
       _vtkmatrix->SetElement(2, 3, transformParams[2]);
     }
     else if (transformParams.size() == 12)
     {
       int m = 0;
       for (unsigned int i = 0; i < 3; i++)
       {
         for (unsigned int j = 0; j < 3; j++)
         {
           _vtkmatrix->SetElement(i, j, transformParams[m]);
           m++;
         }
       }

       _vtkmatrix->SetElement(0, 3, transformParams[9]);
       _vtkmatrix->SetElement(1, 3, transformParams[10]);
       _vtkmatrix->SetElement(2, 3, transformParams[11]);
     }

     // m_SourceNode holds the node onto which the loaded transformation 
should be applied
     mitk::Geometry3D* sourceGeometry = 
m_SourceNode->GetData()->GetGeometry();
     sourceGeometry->GetIndexToWorldTransform()->SetIdentity();
     sourceGeometry->Compose(_vtkmatrix);

     //\FIXME when geometry is substituted the matrix referenced by the 
actor created by the mapper
        //is still pointing to the old one. Workaround: delete mapper
     m_SourceNode->SetMapper(1, NULL);
       
mitk::RenderingManager::GetInstance()->RequestUpdate(m_MultiWidget->mitkWidget4->GetRenderWindow());

     m_SourceNode->GetData()->GetTimeSlicedGeometry()->UpdateInformation();

     mitk::RenderingManager::GetInstance()->RequestUpdateAll();


------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to