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 "Transformer3D1Point.h"
30 CONSTRUCTOR: Initializes the two points with empty vectors, the angle in 0.
32 Transformer3D1Point::Transformer3D1Point()
34 std::vector<int> empty (3,0);
36 //If the transform already exists, we delete it before we create a new transform
37 //and set the matrix with the identity matrix
38 _transform= vtkTransform::New();
39 _matrix = vtkMatrix4x4::New();
41 _transform->SetMatrix(_matrix);
47 Transformer3D1Point::~Transformer3D1Point()
49 //We delete the existing transform
50 if (_transform != NULL ) { _transform->Delete(); }
51 if (_matrix != NULL ) { _matrix->Delete(); }
57 void Transformer3D1Point::SetTransform(vtkTransform *transform)
65 void Transformer3D1Point::SetCenterPoint(std::vector<int> point)
73 void Transformer3D1Point::SetAngleX(double angle)
81 void Transformer3D1Point::SetAngleY(double angle)
89 void Transformer3D1Point::SetAngleZ(double angle)
97 void Transformer3D1Point::SetScaleX(double scaleX)
105 void Transformer3D1Point::SetScaleY(double scaleY)
107 _scaleY=scaleY/100.0;
113 void Transformer3D1Point::SetScaleZ(double scaleZ)
115 _scaleZ=scaleZ/100.0;
119 GETS THE RESULTANT TRANSFORM
121 vtkTransform *Transformer3D1Point::GetResult()
127 MAKES THE TRANSFORMATIONS
129 void Transformer3D1Point::Run()
131 //Clears any old transformations in the pipeline
132 _transform->Identity();
134 //Make all transformations in post multiply mode
135 _transform->PostMultiply();
137 //Centers the image before applying the transformation
138 _transform->Translate(-_centerPoint[0], -_centerPoint[1], -_centerPoint[2]);
141 _transform->RotateWXYZ(_angleY, 0, 1, 0);
142 _transform->RotateWXYZ(_angleX, 1, 0, 0);
143 _transform->RotateWXYZ(_angleZ, 0, 0, 1);
144 _transform->Scale(_scaleX, _scaleY,_scaleZ);
146 //Returns the inverse of the transformation (NTU: Have no idea why we have to do this for the image to appear properly)
147 _transform->Inverse();
148 _transform->Update();