]> Creatis software - creaImageIO.git/blob - bbtk_Transform3Ddicom_PKG/src/bbTransform3DdicomNewDicomImaPosPat.cxx
1a56b0277932ac0182b484c5ac18c5a962b21605
[creaImageIO.git] / bbtk_Transform3Ddicom_PKG / src / bbTransform3DdicomNewDicomImaPosPat.cxx
1 #include "bbTransform3DdicomNewDicomImaPosPat.h"
2 #include "bbTransform3DdicomPackage.h"
3
4 #include "matrixRotation.h"
5
6
7 namespace bbTransform3Ddicom
8 {
9
10 BBTK_ADD_BLACK_BOX_TO_PACKAGE(Transform3Ddicom,NewDicomImaPosPat)
11 BBTK_BLACK_BOX_IMPLEMENTATION(NewDicomImaPosPat,bbtk::AtomicBlackBox);
12 void NewDicomImaPosPat::Process()
13 {
14     printf("NewDicomImaPosPat::Process Start\n");
15         if (!((bbGetInputIPP().size()!=3) ||   (bbGetInputIOP().size()!=6)  ||  (bbGetInputPixelSpacing().size()!=3)  ))
16         {
17                 matrixRotation matrixrotation;  
18                 matrixrotation.SetOrigin(  bbGetInputIPP()[0]  , bbGetInputIPP()[1] , bbGetInputIPP()[2] );
19                 matrixrotation.SetVector1( bbGetInputIOP()[0] , bbGetInputIOP()[1] , bbGetInputIOP()[2] );
20                 matrixrotation.SetVector2(  bbGetInputIOP()[3] , bbGetInputIOP()[4] , bbGetInputIOP()[5] );
21         printf("EED NewDicomImaPosPat::Process spc %f %f %f \n",  bbGetInputPixelSpacing()[0] ,  bbGetInputPixelSpacing()[1],  bbGetInputPixelSpacing()[2] );
22         matrixrotation.SetSpacing(  bbGetInputPixelSpacing()[0] ,  bbGetInputPixelSpacing()[1],  bbGetInputPixelSpacing()[2]);
23                 vtkTransform *transform = vtkTransform::New();
24                 matrixrotation.GetTransformation(transform);
25         bbSetOutputTransform( transform );
26
27         if ( (bbGetInputPoint().size()==3) )
28         {
29             double ipp[3], newIPP[3];
30             ipp[0] = bbGetInputPoint()[0];
31             ipp[1] = bbGetInputPoint()[1];
32             ipp[2] = bbGetInputPoint()[2];
33             transform->Update();
34             transform->TransformPoint(ipp, newIPP);
35             std::vector<double> vecOutIPP;
36             vecOutIPP.push_back( newIPP[0] );
37             vecOutIPP.push_back( newIPP[1] );
38             vecOutIPP.push_back( newIPP[2] );
39             bbSetOutputOut( vecOutIPP );
40         } else {
41             printf("EED NewDicomImaPosPat::Process  empty vector with input Point\n");
42         }
43         } else {
44                 printf("EED Warnning! NewDicomImaPosPat::Process Size inputs are not correct. IPP(3)=%lu  IOP(6)=%lu  Spacing(3)=%lu  Point(3)=%lu\n", bbGetInputIPP().size() , bbGetInputIOP().size() , bbGetInputPixelSpacing().size() , bbGetInputPoint().size() );
45         }
46     printf("NewDicomImaPosPat::Process End\n");
47 }
48
49 /*      
50 void NewDicomImaPosPat::bbUserConstructor()
51 {
52
53 }
54         
55 void NewDicomImaPosPat::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
56 {
57 }
58         
59 void NewDicomImaPosPat::bbUserDestructor()
60 {
61 }
62 */
63
64
65 //===== 
66 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
67 //===== 
68 void NewDicomImaPosPat::bbUserSetDefaultValues()
69 {
70 }
71
72
73 //===== 
74 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
75 //===== 
76 void NewDicomImaPosPat::bbUserInitializeProcessing()
77 {
78 //  THE INITIALIZATION METHOD BODY :
79 //    Here does nothing 
80 //    but this is where you should allocate the internal/output pointers 
81 //    if any 
82 }
83
84 //===== 
85 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
86 //===== 
87 void NewDicomImaPosPat::bbUserFinalizeProcessing()
88 {
89 //  THE FINALIZATION METHOD BODY :
90 //    Here does nothing 
91 //    but this is where you should desallocate the internal/output pointers 
92 //    if any
93 }
94
95         
96 }
97 // EO namespace bbTransform3Ddicom
98
99