]> Creatis software - creaRigidRegistration.git/blobdiff - lib/Transformer.cxx
*** empty log message ***
[creaRigidRegistration.git] / lib / Transformer.cxx
index ed1b25ba8021c4495a356b11295f03c941ccff9a..c901362cb8d3bdd50701014a36b314480b1a06aa 100644 (file)
@@ -15,10 +15,9 @@ Transformer::Transformer()
        //If the transform already exists, we delete it before we create a new transform 
        //and set the matrix with the identity matrix
        _transform= vtkTransform::New();
-       vtkMatrix4x4 *_matrix = vtkMatrix4x4::New();
+       _matrix = vtkMatrix4x4::New();
        _matrix->Identity();
-       _transform->SetMatrix(_matrix);
-       
+       _transform->SetMatrix(_matrix); 
 }
 
 /*
@@ -28,6 +27,7 @@ Transformer::~Transformer()
 {
        //We delete the existing transform
        if (_transform != NULL ) { _transform->Delete(); }
+       if (_matrix != NULL ) { _matrix->Delete(); }
 }
 
 /*
@@ -46,14 +46,6 @@ void Transformer::SetCenterPoint(std::vector<int> point)
     _centerPoint=point;
 }
 
-/*
-       SETS AXIS POINT
-*/
-void Transformer::SetAxis(std::vector<double> axis)
-{
-    _transformAxis=axis;
-}
-
 /*
        SETS THE ANGLE
 */
@@ -99,19 +91,34 @@ vtkTransform *Transformer::GetResult()
 /*
        MAKES THE TRANSFORMATIONS
 */
-void Transformer::Run(bool _3D)
-{      
+void Transformer::Run()
+{
        _transform->Identity();
-       _transform->Translate(_centerPoint[0], _centerPoint[1], _centerPoint[2]);
-       _transform->Scale(_scaleX, _scaleY,_scaleZ);
-       if(_3D)
+       _transform->PostMultiply();
+       if(_centerPoint.size() < 3)
        {
-               _transform->RotateWXYZ(_angle, _transformAxis[0], _transformAxis[1], _transformAxis[2]);                
+               _transform->Translate(-_centerPoint[0], -_centerPoint[1], 0);
+               std::cout << "NTU Transformer2D Center Points: " << _centerPoint[0] << " " << _centerPoint[1] << std::endl;
        }
        else
        {
-               _transform->RotateWXYZ(_angle, 0, 0, 1);
+               _transform->Translate(-_centerPoint[0], -_centerPoint[1], -_centerPoint[2]);
+               std::cout << "NTU Transformer2D Center Points: " << _centerPoint[0] << " " << _centerPoint[1] << " " << _centerPoint[2] << std::endl;
        }
-       
+
+       _transform->RotateWXYZ(_angle, 0, 0, 1);
+       //std::cout << "NTU Transformer2D Angle: " << _angle << std::endl;
+
+       if(_scaleX < 0 || _scaleY < 0 || _scaleZ < 0)
+       {
+               _transform->Scale(100, 100, 100);
+               //std::cout << "NTU Transformer2D Scale: " << _scaleX << " " << _scaleY << " " << _scaleZ << std::endl;
+       }
+       else
+       {
+               _transform->Scale(_scaleX, _scaleY,_scaleZ);
+               //std::cout << "NTU Transformer2D Scale: " << _scaleX << " " << _scaleY << " " << _scaleZ << std::endl;
+       }               
+       _transform->Inverse();
        _transform->Update();
 }