]> Creatis software - creaRigidRegistration.git/blobdiff - PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx
*** empty log message ***
[creaRigidRegistration.git] / PackRecalage / src / bbPackRecalagePlaneReorientationBox.cxx
index ea921adc6d0531f194802701e5d83065a7e086b7..1e867901decbb200b1c1631cf6eadf4d7a4315a0 100644 (file)
@@ -9,6 +9,30 @@ void PlaneReorientationBox::Process()
 {
        if(!bbGetInputInX().empty() && bbGetInputInX().size() == 3 && !bbGetInputInY().empty() && bbGetInputInY().size() == 3 && !bbGetInputInZ().empty() && bbGetInputInZ().size() == 3)
        {
+               double a[3];            
+               
+               /*First Vector*/
+               a[0] = bbGetInputInX()[1]-bbGetInputInX()[0];
+               a[1] = bbGetInputInY()[1]-bbGetInputInY()[0];
+               a[2] = bbGetInputInZ()[1]-bbGetInputInZ()[0];
+
+               double b[3];
+
+               /*Second Vector*/
+               b[0] = bbGetInputInX()[2]-bbGetInputInX()[0];
+               b[1] = bbGetInputInY()[2]-bbGetInputInY()[0];
+               b[2] = bbGetInputInZ()[2]-bbGetInputInZ()[0];
+
+               double normal[3];
+
+               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;
+               
                /*Unitary Vector in Y*/
                double y[3];
                y[0] = 0;
@@ -19,9 +43,7 @@ void PlaneReorientationBox::Process()
                double x[3];
                x[0] = 1;
                x[1] = 0;
-               x[2] = 0;
-
-               double normal[3];
+               x[2] = 0;               
 
                /*Normal vector without its z factor*/
                double normalZ[3];
@@ -47,7 +69,6 @@ void PlaneReorientationBox::Process()
                std::cout << "Angle for Z: " << angleZ << std::endl;
                std::cout << "Angle for Y: " << angleY << std::endl;
 
-               vtkTransform *transform = vtkTransform::New();
                transform->Identity();
                if(normal[0] < 0)
                {
@@ -71,6 +92,12 @@ void PlaneReorientationBox::Process()
                /*Set output and pray to god that it works :P*/
                bbSetOutputOut(transform);
        }
+       else
+       {
+               transform->Identity();
+               transform->Update();
+               bbSetOutputOut(transform);
+       }
 }
 void PlaneReorientationBox::bbUserSetDefaultValues()
 {
@@ -81,22 +108,11 @@ void PlaneReorientationBox::bbUserSetDefaultValues()
 }
 void PlaneReorientationBox::bbUserInitializeProcessing()
 {
-//  THE INITIALIZATION METHOD BODY : 
-//    Here does nothing  
-//    but this is where you should allocate the internal/output pointers  
-//    if any  
-  
+       transform = vtkTransform::New();
 }
 void PlaneReorientationBox::bbUserFinalizeProcessing()
 {
-//  THE FINALIZATION METHOD BODY : 
-//    Here does nothing  
-//    but this is where you should desallocate the internal/output pointers  
-//    if any 
-  
+       transform->Delete(); 
 }
 }
 // EO namespace bbPackRecalage