]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkTransformVector.cxx
#2811 creaVtk Feature New Normal - Concat Transform ImageAccumulate TransformVector
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkTransformVector.cxx
1 //===== 
2 // 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)
3 //===== 
4 #include "bbcreaVtkTransformVector.h"
5 #include "bbcreaVtkPackage.h"
6 namespace bbcreaVtk
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,TransformVector)
10 BBTK_BLACK_BOX_IMPLEMENTATION(TransformVector,bbtk::AtomicBlackBox);
11 //===== 
12 // 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)
13 //===== 
14 void TransformVector::Process()
15 {
16
17 // THE MAIN PROCESSING METHOD BODY
18 //   Here we simply set the input 'In' value to the output 'Out'
19 //   And print out the output value
20 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
21 //    void bbSet{Input|Output}NAME(const TYPE&)
22 //    const TYPE& bbGet{Input|Output}NAME() const 
23 //    Where :
24 //    * NAME is the name of the input/output
25 //      (the one provided in the attribute 'name' of the tag 'input')
26 //    * TYPE is the C++ type of the input/output
27 //      (the one provided in the attribute 'type' of the tag 'input')
28
29 //    bbSetOutputOut( bbGetInputIn() );
30 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
31   
32         double tmpA[3];
33         double *tmpB;
34         unsigned int i;
35         unsigned int XSize=bbGetInputInX().size();
36         unsigned int YSize=bbGetInputInY().size();
37         unsigned int ZSize=bbGetInputInZ().size();
38
39         std::vector<double> xVec;
40         std::vector<double> yVec;
41         std::vector<double> zVec;
42
43 printf("TransformVector::Process  START\n" );
44         
45         bool ok=true;
46         if ((XSize!=YSize) || (XSize!=ZSize) )
47         {
48                 ok=false;
49                 printf("ERROR. TransformVector: The size of the tree vectors are not the same!\n");
50         }
51
52
53         if (ok==true)
54         {       
55                 if (bbGetInputTransform()!=NULL) { bbGetInputTransform()->Update(); }
56                 for(i=0;i<XSize;i++)
57                 {
58                         tmpA[0]=bbGetInputInX()[i];
59                         tmpA[1]=bbGetInputInY()[i];
60                         tmpA[2]=bbGetInputInZ()[i];
61
62                         if (bbGetInputTransform()!=NULL)
63                         {
64                                 tmpB=bbGetInputTransform()->TransformDoublePoint(tmpA);                 
65                                 xVec.push_back( tmpB[0] );
66                                 yVec.push_back( tmpB[1] );
67                                 zVec.push_back( tmpB[2] );
68                         } else {
69                                 printf("WARNNIG. TransformVector: The Transform is not set!\n");
70                                 xVec.push_back( tmpA[0] );
71                                 yVec.push_back( tmpA[1] );
72                                 zVec.push_back( tmpA[2] );
73                         } // if Transform
74                 }// for i
75         } // if ok
76         bbSetOutputOutX(xVec);
77         bbSetOutputOutY(yVec);
78         bbSetOutputOutZ(zVec);
79
80 printf("TransformVector::Process  END\n" );
81
82 }
83 //===== 
84 // 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)
85 //===== 
86 void TransformVector::bbUserSetDefaultValues()
87 {
88
89 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
90 //    Here we initialize the input 'In' to 0
91    bbSetInputTransform(NULL);
92   
93 }
94 //===== 
95 // 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)
96 //===== 
97 void TransformVector::bbUserInitializeProcessing()
98 {
99
100 //  THE INITIALIZATION METHOD BODY :
101 //    Here does nothing 
102 //    but this is where you should allocate the internal/output pointers 
103 //    if any 
104
105   
106 }
107 //===== 
108 // 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)
109 //===== 
110 void TransformVector::bbUserFinalizeProcessing()
111 {
112
113 //  THE FINALIZATION METHOD BODY :
114 //    Here does nothing 
115 //    but this is where you should desallocate the internal/output pointers 
116 //    if any
117   
118 }
119 }
120 // EO namespace bbcreaVtk
121
122