]> Creatis software - creaRigidRegistration.git/blob - lib/PlaneReorientation.cxx
df522d57dae3c1c684fd532054ff66a6ff644400
[creaRigidRegistration.git] / lib / PlaneReorientation.cxx
1 #include "PlaneReorientation.h"
2
3 /*
4 * Constructor
5 */
6 //------------------------------------------------------------
7 PlaneReorientation::PlaneReorientation()
8 {
9         _transform=vtkTransform::New();
10 }
11
12 /*
13 * Destructor
14 */
15 //------------------------------------------------------------
16 PlaneReorientation::~PlaneReorientation()
17 {
18         if (_transform != NULL ) { _transform->Delete(); }
19 }
20
21 void PlaneReorientation::CalculateNormal()
22 {
23         normal[0]=(a[1]*b[2])-(a[2]*b[1]);
24         normal[1]=(a[2]*b[0])-(a[0]*b[2]);
25         normal[2]=(a[0]*b[1])-(a[1]*b[0]);
26
27         vtkMath::Normalize(normal);
28
29         std::cout << "Normal axis : " << "X: " << normal[0] << " Y: " << normal[1] << " Z: " << normal[2] << std::endl;
30 }
31
32 void PlaneReorientation::SetVectors(std::vector<int> pointsX, std::vector<int> pointsY, std::vector<int> pointsZ, std::vector<std::string> labels)
33 {
34         //This part is for head reorientation using the chiasma and optical nerves
35         if(labels[0].compare("CHIASMA") == 0 || labels[1].compare("CHIASMA") == 0 || labels[2].compare("CHIASMA") == 0)
36         {
37                 int i;
38                 for(i = 0; i < 2; i++)
39                 {
40                         //Gets the point that represents the optic chiasma and sets it as the origin point
41                         if(labels[i].compare("CHIASMA")==0)
42                         {
43                                 o[0] = pointsX[i];
44                                 o[1] = pointsY[i];
45                                 o[2] = pointsZ[i];
46                         }
47                         //The point that represents the right eye (and subsequent first vector)
48                         else if(labels[i].compare("RY")==0)
49                         {
50                                 a[0] = pointsX[i];
51                                 a[1] = pointsY[i];
52                                 a[2] = pointsZ[i];
53                         }
54                         //The point that represents the left eye (and subsequent second vector)
55                         else if(labels[i].compare("LY")==0)
56                         {
57                                 b[0] = pointsX[i];
58                                 b[1] = pointsY[i];
59                                 b[2] = pointsZ[i];
60                         }
61                 }
62
63                 //Creates the first vector
64                 a[0] = a[0] - o[0];
65                 a[1] = a[1] - o[1];
66                 a[2] = a[2] - o[2];
67
68                 //Creates the second vector
69                 b[0] = b[0] - o[0];
70                 b[1] = b[1] - o[1];
71                 b[2] = b[2] - o[2];
72         }
73         else
74         {
75                 /*First Vector*/
76                 a[0] = pointsX[1]-pointsX[0];
77                 a[1] = pointsY[1]-pointsY[0];
78                 a[2] = pointsZ[1]-pointsZ[0];
79
80                 /*Second Vector*/
81                 b[0] = pointsX[2]-pointsX[0];
82                 b[1] = pointsY[2]-pointsY[0];
83                 b[2] = pointsZ[2]-pointsZ[0];
84         }
85 }
86
87 vtkTransform* PlaneReorientation::getTransform()
88 {
89         return _transform;
90 }
91
92 void PlaneReorientation::Run()
93 {
94
95 }