2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 #include "Transformer.h"
29 #include "vtkMatrix4x4.h"
32 CONSTRUCTOR: Initializes the two points with empty vectors, the angle in 0.
34 Transformer::Transformer()
36 std::vector<int> empty (3,0);
41 //If the transform already exists, we delete it before we create a new transform
42 //and set the matrix with the identity matrix
43 _transform= vtkTransform::New();
44 _matrix = vtkMatrix4x4::New();
46 _transform->SetMatrix(_matrix);
52 Transformer::~Transformer()
54 //We delete the existing transform
55 if (_transform != NULL ) { _transform->Delete(); }
56 if (_matrix != NULL ) { _matrix->Delete(); }
62 void Transformer::SetTransform(vtkTransform *transform)
70 void Transformer::SetCenterPoint(std::vector<int> point)
78 void Transformer::SetAngle(double angle)
86 void Transformer::SetScaleX(double scaleX)
94 void Transformer::SetScaleY(double scaleY)
102 void Transformer::SetScaleZ(double scaleZ)
104 _scaleZ=scaleZ/100.0;
110 GETS THE RESULTANT TRANSFORM
112 vtkTransform *Transformer::GetResult()
118 MAKES THE TRANSFORMATIONS
120 void Transformer::Run()
122 _transform->Identity();
123 _transform->PostMultiply();
124 if(_centerPoint.size() < 3)
126 _transform->Translate(-_centerPoint[0], -_centerPoint[1], 0);
127 std::cout << "NTU Transformer2D Center Points: " << _centerPoint[0] << " " << _centerPoint[1] << std::endl;
131 _transform->Translate(-_centerPoint[0], -_centerPoint[1], -_centerPoint[2]);
132 std::cout << "NTU Transformer2D Center Points: " << _centerPoint[0] << " " << _centerPoint[1] << " " << _centerPoint[2] << std::endl;
135 _transform->RotateWXYZ(_angle, 0, 0, 1);
136 //std::cout << "NTU Transformer2D Angle: " << _angle << std::endl;
138 if(_scaleX < 0 || _scaleY < 0 || _scaleZ < 0)
140 _transform->Scale(100, 100, 100);
141 //std::cout << "NTU Transformer2D Scale: " << _scaleX << " " << _scaleY << " " << _scaleZ << std::endl;
145 _transform->Scale(_scaleX, _scaleY,_scaleZ);
146 //std::cout << "NTU Transformer2D Scale: " << _scaleX << " " << _scaleY << " " << _scaleZ << std::endl;
148 _transform->Inverse();
149 _transform->Update();