]> Creatis software - creaRigidRegistration.git/blob - lib/PlaneReorientation.cxx
Feature #1766 Add licence terms for all files.
[creaRigidRegistration.git] / lib / PlaneReorientation.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
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
9 #
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.
16 #
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
21 #  liability. 
22 #
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 # ------------------------------------------------------------------------      */                                                                    
26
27 #include "PlaneReorientation.h"
28
29 /*
30 * Constructor
31 */
32 //------------------------------------------------------------
33 PlaneReorientation::PlaneReorientation()
34 {
35         _transform=vtkTransform::New();
36 }
37
38 /*
39 * Destructor
40 */
41 //------------------------------------------------------------
42 PlaneReorientation::~PlaneReorientation()
43 {
44         if (_transform != NULL ) { _transform->Delete(); }
45 }
46
47 void PlaneReorientation::CalculateNormal()
48 {
49         normal[0]=(a[1]*b[2])-(a[2]*b[1]);
50         normal[1]=(a[2]*b[0])-(a[0]*b[2]);
51         normal[2]=(a[0]*b[1])-(a[1]*b[0]);
52
53         vtkMath::Normalize(normal);
54
55         std::cout << "Normal axis : " << "X: " << normal[0] << " Y: " << normal[1] << " Z: " << normal[2] << std::endl;
56 }
57
58 void PlaneReorientation::SetVectors(std::vector<int> pointsX, std::vector<int> pointsY, std::vector<int> pointsZ, std::vector<std::string> labels)
59 {
60         //This part is for head reorientation using the chiasma and optical nerves
61         if(labels[0].compare("CHIASMA") == 0 || labels[1].compare("CHIASMA") == 0 || labels[2].compare("CHIASMA") == 0)
62         {
63                 int i;
64                 for(i = 0; i < 2; i++)
65                 {
66                         //Gets the point that represents the optic chiasma and sets it as the origin point
67                         if(labels[i].compare("CHIASMA")==0)
68                         {
69                                 o[0] = pointsX[i];
70                                 o[1] = pointsY[i];
71                                 o[2] = pointsZ[i];
72                         }
73                         //The point that represents the right eye (and subsequent first vector)
74                         else if(labels[i].compare("RY")==0)
75                         {
76                                 a[0] = pointsX[i];
77                                 a[1] = pointsY[i];
78                                 a[2] = pointsZ[i];
79                         }
80                         //The point that represents the left eye (and subsequent second vector)
81                         else if(labels[i].compare("LY")==0)
82                         {
83                                 b[0] = pointsX[i];
84                                 b[1] = pointsY[i];
85                                 b[2] = pointsZ[i];
86                         }
87                 }
88
89                 //Creates the first vector
90                 a[0] = a[0] - o[0];
91                 a[1] = a[1] - o[1];
92                 a[2] = a[2] - o[2];
93
94                 //Creates the second vector
95                 b[0] = b[0] - o[0];
96                 b[1] = b[1] - o[1];
97                 b[2] = b[2] - o[2];
98         }
99         else
100         {
101                 /*First Vector*/
102                 a[0] = pointsX[1]-pointsX[0];
103                 a[1] = pointsY[1]-pointsY[0];
104                 a[2] = pointsZ[1]-pointsZ[0];
105
106                 /*Second Vector*/
107                 b[0] = pointsX[2]-pointsX[0];
108                 b[1] = pointsY[2]-pointsY[0];
109                 b[2] = pointsZ[2]-pointsZ[0];
110         }
111 }
112
113 vtkTransform* PlaneReorientation::getTransform()
114 {
115         return _transform;
116 }
117
118 void PlaneReorientation::Run()
119 {
120
121 }