]> Creatis software - creaRigidRegistration.git/blobdiff - lib/PlaneReorientation.cxx
Added PlaneReorientation (For Muller Project)
[creaRigidRegistration.git] / lib / PlaneReorientation.cxx
diff --git a/lib/PlaneReorientation.cxx b/lib/PlaneReorientation.cxx
new file mode 100644 (file)
index 0000000..df522d5
--- /dev/null
@@ -0,0 +1,95 @@
+#include "PlaneReorientation.h"
+
+/*
+* Constructor
+*/
+//------------------------------------------------------------
+PlaneReorientation::PlaneReorientation()
+{
+       _transform=vtkTransform::New();
+}
+
+/*
+* Destructor
+*/
+//------------------------------------------------------------
+PlaneReorientation::~PlaneReorientation()
+{
+       if (_transform != NULL ) { _transform->Delete(); }
+}
+
+void PlaneReorientation::CalculateNormal()
+{
+       normal[0]=(a[1]*b[2])-(a[2]*b[1]);
+       normal[1]=(a[2]*b[0])-(a[0]*b[2]);
+       normal[2]=(a[0]*b[1])-(a[1]*b[0]);
+
+       vtkMath::Normalize(normal);
+
+       std::cout << "Normal axis : " << "X: " << normal[0] << " Y: " << normal[1] << " Z: " << normal[2] << std::endl;
+}
+
+void PlaneReorientation::SetVectors(std::vector<int> pointsX, std::vector<int> pointsY, std::vector<int> pointsZ, std::vector<std::string> labels)
+{
+       //This part is for head reorientation using the chiasma and optical nerves
+       if(labels[0].compare("CHIASMA") == 0 || labels[1].compare("CHIASMA") == 0 || labels[2].compare("CHIASMA") == 0)
+       {
+               int i;
+               for(i = 0; i < 2; i++)
+               {
+                       //Gets the point that represents the optic chiasma and sets it as the origin point
+                       if(labels[i].compare("CHIASMA")==0)
+                       {
+                               o[0] = pointsX[i];
+                               o[1] = pointsY[i];
+                               o[2] = pointsZ[i];
+                       }
+                       //The point that represents the right eye (and subsequent first vector)
+                       else if(labels[i].compare("RY")==0)
+                       {
+                               a[0] = pointsX[i];
+                               a[1] = pointsY[i];
+                               a[2] = pointsZ[i];
+                       }
+                       //The point that represents the left eye (and subsequent second vector)
+                       else if(labels[i].compare("LY")==0)
+                       {
+                               b[0] = pointsX[i];
+                               b[1] = pointsY[i];
+                               b[2] = pointsZ[i];
+                       }
+               }
+
+               //Creates the first vector
+               a[0] = a[0] - o[0];
+               a[1] = a[1] - o[1];
+               a[2] = a[2] - o[2];
+
+               //Creates the second vector
+               b[0] = b[0] - o[0];
+               b[1] = b[1] - o[1];
+               b[2] = b[2] - o[2];
+       }
+       else
+       {
+               /*First Vector*/
+               a[0] = pointsX[1]-pointsX[0];
+               a[1] = pointsY[1]-pointsY[0];
+               a[2] = pointsZ[1]-pointsZ[0];
+
+               /*Second Vector*/
+               b[0] = pointsX[2]-pointsX[0];
+               b[1] = pointsY[2]-pointsY[0];
+               b[2] = pointsZ[2]-pointsZ[0];
+       }
+}
+
+vtkTransform* PlaneReorientation::getTransform()
+{
+       return _transform;
+}
+
+void PlaneReorientation::Run()
+{
+
+}