]> Creatis software - creaRigidRegistration.git/blobdiff - PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx
Feature #1766 Add licence terms for all files.
[creaRigidRegistration.git] / PackRecalage / src / bbPackRecalagePlaneReorientationBox.cxx
index ea921adc6d0531f194802701e5d83065a7e086b7..03e7474cc7647d3b6e48b046821e7388799fe7d8 100644 (file)
@@ -1,3 +1,29 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
+#                        pour la Santé)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+#
+#  This software is governed by the CeCILL-B license under French law and 
+#  abiding by the rules of distribution of free software. You can  use, 
+#  modify and/ or redistribute the software under the terms of the CeCILL-B 
+#  license as circulated by CEA, CNRS and INRIA at the following URL 
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability. 
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------   
+*/
+
+
 #include "bbPackRecalagePlaneReorientationBox.h"
 #include "bbPackRecalagePackage.h"
 namespace bbPackRecalage
@@ -9,6 +35,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 +69,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 +95,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 +118,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 +134,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