]> Creatis software - creaImageIO.git/blob - bbtk_Transform3Ddicom_PKG/src/bbTransform3DdicomNewDicomImaPosPat.cxx
7bc8f14092339830389997d8dec74791404bbc63
[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         if (!((bbGetInputIPP().size()!=3) ||   (bbGetInputIOP().size()!=6)  ||  (bbGetInputPixelSpacing().size()!=3)  ))
15         {
16                 matrixRotation matrixrotation;  
17                 matrixrotation.SetOrigin(  bbGetInputIPP()[0]  , bbGetInputIPP()[1] , bbGetInputIPP()[2] );
18                 matrixrotation.SetVector1( bbGetInputIOP()[0] , bbGetInputIOP()[1] , bbGetInputIOP()[2] );
19                 matrixrotation.SetVector2(  bbGetInputIOP()[3] , bbGetInputIOP()[4] , bbGetInputIOP()[5] );
20         matrixrotation.SetSpacing(  bbGetInputPixelSpacing()[0] ,  bbGetInputPixelSpacing()[1],  bbGetInputPixelSpacing()[2]);
21                 vtkTransform *transform = vtkTransform::New();
22                 matrixrotation.GetTransformation(transform);
23         bbSetOutputTransform( transform );
24
25         if ( (bbGetInputPoint().size()==3) )
26         {
27             double ipp[3], newIPP[3];
28             ipp[0] = bbGetInputPoint()[0];
29             ipp[1] = bbGetInputPoint()[1];
30             ipp[2] = bbGetInputPoint()[2];
31             transform->Update();
32             transform->TransformPoint(ipp, newIPP);
33             std::vector<double> vecOutIPP;
34             vecOutIPP.push_back( newIPP[0] );
35             vecOutIPP.push_back( newIPP[1] );
36             vecOutIPP.push_back( newIPP[2] );
37             bbSetOutputOut( vecOutIPP );
38         } else {
39             //
40         }
41         } else {
42                 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() );
43         }
44 }
45
46 /*      
47 void NewDicomImaPosPat::bbUserConstructor()
48 {
49
50 }
51         
52 void NewDicomImaPosPat::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
53 {
54 }
55         
56 void NewDicomImaPosPat::bbUserDestructor()
57 {
58 }
59 */
60
61
62 //===== 
63 // 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)
64 //===== 
65 void NewDicomImaPosPat::bbUserSetDefaultValues()
66 {
67 }
68
69
70 //===== 
71 // 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)
72 //===== 
73 void NewDicomImaPosPat::bbUserInitializeProcessing()
74 {
75 //  THE INITIALIZATION METHOD BODY :
76 //    Here does nothing 
77 //    but this is where you should allocate the internal/output pointers 
78 //    if any 
79 }
80
81 //===== 
82 // 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)
83 //===== 
84 void NewDicomImaPosPat::bbUserFinalizeProcessing()
85 {
86 //  THE FINALIZATION METHOD BODY :
87 //    Here does nothing 
88 //    but this is where you should desallocate the internal/output pointers 
89 //    if any
90 }
91
92         
93 }
94 // EO namespace bbTransform3Ddicom
95
96