From: trillos Date: Wed, 18 Nov 2009 09:55:33 +0000 (+0000) Subject: Added PlaneReorientation (For Muller Project) X-Git-Tag: CREATOOLS.2-0-3~21 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9b89ece57878a559b17dd54f884720b6eea395ef;p=creaRigidRegistration.git Added PlaneReorientation (For Muller Project) --- diff --git a/lib/PlaneReorientation.cxx b/lib/PlaneReorientation.cxx new file mode 100644 index 0000000..df522d5 --- /dev/null +++ b/lib/PlaneReorientation.cxx @@ -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 pointsX, std::vector pointsY, std::vector pointsZ, std::vector 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() +{ + +} diff --git a/lib/PlaneReorientation.h b/lib/PlaneReorientation.h new file mode 100644 index 0000000..1c1ba6a --- /dev/null +++ b/lib/PlaneReorientation.h @@ -0,0 +1,31 @@ +#include "vtkTransform.h" +#include "vtkMath.h" +#include "vtkMatrix4x4.h" +#include +#include "vector" + +#include "iostream" + +class PlaneReorientation +{ + public: + //------------------// + //Constructors + //------------------// + PlaneReorientation(); + ~PlaneReorientation(); + + void SetVectors(std::vector pointsX, std::vector pointsY, std::vector pointsZ, std::vector labels); + void CalculateNormal(); + vtkTransform* getTransform(); + + void Run(); + + private: + vtkTransform *_transform; + double a[3]; + double b[3]; + double o[3]; + + double normal[3]; +}; \ No newline at end of file