]> Creatis software - creaRigidRegistration.git/commitdiff
*** empty log message ***
authortrillos <trillos>
Wed, 18 Nov 2009 09:56:20 +0000 (09:56 +0000)
committertrillos <trillos>
Wed, 18 Nov 2009 09:56:20 +0000 (09:56 +0000)
PackRecalage/src/bbPackRecalageImageRecalageProperties.cxx
PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx
PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx [new file with mode: 0644]
PackRecalage/src/bbPackRecalagePlaneReorientationBox.h [new file with mode: 0644]

index a5781fca0067ba3e249b7ebba3bae2ce22ee8947..e5863e5811e69eb9df9f740cf88238c36b3b99d2 100644 (file)
@@ -11,6 +11,10 @@ void ImageRecalageProperties::Process()
        if(image != NULL)
        {
                bbSetOutputLengthZ((int)image->GetDimensions()[2] - 1);
+               std::cout << "image scalar size: " << image->GetScalarSize() << std::endl;
+               std::cout << "image scalar max: " << image->GetScalarTypeMax() << std::endl;
+               std::cout << "image scalar min: " << image->GetScalarTypeMin() << std::endl;
+               std::cout << "image scalar type: " << image->GetScalarType() << std::endl;
                if(image->GetScalarType() == VTK_DOUBLE)
                {
                                bbSetOutputColorLevel(50);
@@ -18,8 +22,8 @@ void ImageRecalageProperties::Process()
                }
                else if(image->GetScalarType() == VTK_UNSIGNED_SHORT)
                {
-                               bbSetOutputColorLevel(25000);
-                               bbSetOutputMidColorLevel(12500);
+                               bbSetOutputColorLevel(500);
+                               bbSetOutputMidColorLevel(250);
                }
                else
                {
index bf4afe9c36f04ff79c5f6ba47b3e538de4034c8e..65696f6904dc6c60cc190565ed2d6dfd91107c38 100644 (file)
@@ -14,6 +14,7 @@ namespace bbPackRecalage
 
        void MyTimer::Notify()
        {
+               //This will be called each time the timer finishes a countdown
                _box->Change();
                _box->bbSignalOutputModification(std::string("Out")); 
        }       
@@ -23,6 +24,8 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ImageSwitcherBox,bbtk::WxBlackBox);
 
 void ImageSwitcherBox::Change()
 {
+       //Just changes the images each time the timer finishes a countdown
+       
        if(change == false)
        {
                bbSetOutputOut(bbGetInputIn2());                
@@ -60,14 +63,7 @@ void ImageSwitcherBox::Process()
                myTimer->Start(time);
                oldTime = time;
        }
-       /*
-       if(oldTime != time && myTimer !=NULL)
-       {
-               myTimer->Stop();
-               myTimer->Start(time);
-               oldTime = time;
-       }*/
-
+       
        if(!_on)
        {
                myTimer->Stop();
@@ -86,6 +82,7 @@ void ImageSwitcherBox::Process()
 }
 void ImageSwitcherBox::CreateWidget(wxWindow* parent)
 {
+       //Creates a simple text widget because it is necesary that a non-empty widget exists for creatingh the thread of the timer.
        bbSetOutputWidget( new wxStaticText(parent, -1, _T("Image Switcher")) );        
 }
 void ImageSwitcherBox::bbUserSetDefaultValues()
diff --git a/PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx b/PackRecalage/src/bbPackRecalagePlaneReorientationBox.cxx
new file mode 100644 (file)
index 0000000..ea921ad
--- /dev/null
@@ -0,0 +1,104 @@
+#include "bbPackRecalagePlaneReorientationBox.h"
+#include "bbPackRecalagePackage.h"
+namespace bbPackRecalage
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,PlaneReorientationBox)
+BBTK_BLACK_BOX_IMPLEMENTATION(PlaneReorientationBox,bbtk::AtomicBlackBox);
+void PlaneReorientationBox::Process()
+{
+       if(!bbGetInputInX().empty() && bbGetInputInX().size() == 3 && !bbGetInputInY().empty() && bbGetInputInY().size() == 3 && !bbGetInputInZ().empty() && bbGetInputInZ().size() == 3)
+       {
+               /*Unitary Vector in Y*/
+               double y[3];
+               y[0] = 0;
+               y[1] = 1;
+               y[2] = 0;
+
+               /*Unitary Vector in X*/
+               double x[3];
+               x[0] = 1;
+               x[1] = 0;
+               x[2] = 0;
+
+               double normal[3];
+
+               /*Normal vector without its z factor*/
+               double normalZ[3];
+               normalZ[0] = normal[0];
+               normalZ[1] = normal[1];
+               normalZ[2] = 0;
+
+               /*Normal vector without its y factor*/
+               double normalY[3];
+               normalY[0] = normal[0];
+               normalY[1] = 0;
+               normalY[2] = normal[2];
+
+               /*Angle for the rotation in Z*/
+               double angleZ = acos(vtkMath::Dot(normalZ,y)/vtkMath::Norm(normalZ));           
+
+               /*Angle for the rotation in Y*/
+               double angleY = acos(vtkMath::Dot(x,normalY)/vtkMath::Norm(normalY));
+
+               /*Convert from Radians to Degrees*/
+               angleZ = vtkMath::DegreesFromRadians(angleZ);
+               angleY = vtkMath::DegreesFromRadians(angleY);
+               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)
+               {
+                       transform->RotateWXYZ(angleZ,0,0,1);
+               }
+               else
+               {
+                       transform->RotateWXYZ(angleZ,0,0,-1);
+               }
+               if(normal[1]<0)
+               {
+                       transform->RotateWXYZ(angleY,0,1,0);
+               }
+               else
+               {
+                       if(angleY != 180){transform->RotateWXYZ(angleY,0,-1,0);}
+               }
+               //transform->Translate(bbGetInputCenterPoint()[0],bbGetInputCenterPoint()[1],bbGetInputCenterPoint()[2]);
+               transform->Update();
+
+               /*Set output and pray to god that it works :P*/
+               bbSetOutputOut(transform);
+       }
+}
+void PlaneReorientationBox::bbUserSetDefaultValues()
+{
+       std::vector<int> nullVector;
+       bbSetInputInX(nullVector);
+       bbSetInputInY(nullVector);
+       bbSetInputInZ(nullVector);
+}
+void PlaneReorientationBox::bbUserInitializeProcessing()
+{
+//  THE INITIALIZATION METHOD BODY : 
+//    Here does nothing  
+//    but this is where you should allocate the internal/output pointers  
+//    if any  
+  
+}
+void PlaneReorientationBox::bbUserFinalizeProcessing()
+{
+//  THE FINALIZATION METHOD BODY : 
+//    Here does nothing  
+//    but this is where you should desallocate the internal/output pointers  
+//    if any 
+  
+}
+}
+// EO namespace bbPackRecalage
+
+
diff --git a/PackRecalage/src/bbPackRecalagePlaneReorientationBox.h b/PackRecalage/src/bbPackRecalagePlaneReorientationBox.h
new file mode 100644 (file)
index 0000000..d81c4d8
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef __bbPackRecalagePlaneReorientationBox_h_INCLUDED__
+#define __bbPackRecalagePlaneReorientationBox_h_INCLUDED__
+#include "bbPackRecalage_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "vtkTransform.h"
+#include "vtkMath.h"
+#include "vtkMatrix4x4.h"
+#include "PlaneReorientation.h"
+#include <string>
+
+#include "iostream"
+
+namespace bbPackRecalage
+{
+
+class bbPackRecalage_EXPORT PlaneReorientationBox
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(PlaneReorientationBox,bbtk::AtomicBlackBox);
+  BBTK_DECLARE_INPUT(InX,std::vector<int>);
+  BBTK_DECLARE_INPUT(InY,std::vector<int>);
+  BBTK_DECLARE_INPUT(InZ,std::vector<int>);
+  BBTK_DECLARE_INPUT(labels,std::vector<std::string>);
+  BBTK_DECLARE_INPUT(CenterPoint,std::vector<int>);
+  BBTK_DECLARE_OUTPUT(Out,vtkTransform*);
+  BBTK_PROCESS(Process);
+  void Process();
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(PlaneReorientationBox,bbtk::AtomicBlackBox);
+BBTK_NAME("PlaneReorientationBox");
+BBTK_AUTHOR("jn.trillos44@uniandes.edu.co");
+BBTK_DESCRIPTION("Reorientates an image by use of a plane");
+BBTK_CATEGORY("filter");
+BBTK_INPUT(PlaneReorientationBox,InX,"Points in X (for all the three points)",std::vector<int>,"");
+BBTK_INPUT(PlaneReorientationBox,InY,"Points in Y (for all the three points)",std::vector<int>,"");
+BBTK_INPUT(PlaneReorientationBox,InZ,"Points in Z (for all the three points)",std::vector<int>,"");
+BBTK_INPUT(PlaneReorientationBox,labels,"Labels of the points",std::vector<std::string>,"");
+BBTK_INPUT(PlaneReorientationBox,CenterPoint,"CenterPoint",std::vector<int>,"");
+BBTK_OUTPUT(PlaneReorientationBox,Out,"Transformation ",vtkTransform*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(PlaneReorientationBox);
+}
+// EO namespace bbPackRecalage
+
+#endif // __bbPackRecalagePlaneNormalBox_h_INCLUDED__
+