]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkTransformVector.cxx
Clean code
[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         bool ok=true;
44         if ((XSize!=YSize) || (XSize!=ZSize) )
45         {
46                 ok=false;
47                 printf("ERROR. TransformVector: The size of the tree vectors are not the same!\n");
48         }
49
50
51         if (ok==true)
52         {       
53                 if (bbGetInputTransform()!=NULL) { bbGetInputTransform()->Update(); }
54                 for(i=0;i<XSize;i++)
55                 {
56                         tmpA[0]=bbGetInputInX()[i];
57                         tmpA[1]=bbGetInputInY()[i];
58                         tmpA[2]=bbGetInputInZ()[i];
59
60                         if (bbGetInputTransform()!=NULL)
61                         {
62                                 tmpB=bbGetInputTransform()->TransformDoublePoint(tmpA);                 
63                                 xVec.push_back( tmpB[0] );
64                                 yVec.push_back( tmpB[1] );
65                                 zVec.push_back( tmpB[2] );
66                         } else {
67                                 printf("WARNNIG. TransformVector: The Transform is not set!\n");
68                                 xVec.push_back( tmpA[0] );
69                                 yVec.push_back( tmpA[1] );
70                                 zVec.push_back( tmpA[2] );
71                         } // if Transform
72                 }// for i
73         } // if ok
74         bbSetOutputOutX(xVec);
75         bbSetOutputOutY(yVec);
76         bbSetOutputOutZ(zVec);
77 }
78 //===== 
79 // 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)
80 //===== 
81 void TransformVector::bbUserSetDefaultValues()
82 {
83
84 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
85 //    Here we initialize the input 'In' to 0
86    bbSetInputTransform(NULL);
87   
88 }
89 //===== 
90 // 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)
91 //===== 
92 void TransformVector::bbUserInitializeProcessing()
93 {
94
95 //  THE INITIALIZATION METHOD BODY :
96 //    Here does nothing 
97 //    but this is where you should allocate the internal/output pointers 
98 //    if any 
99
100   
101 }
102 //===== 
103 // 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)
104 //===== 
105 void TransformVector::bbUserFinalizeProcessing()
106 {
107
108 //  THE FINALIZATION METHOD BODY :
109 //    Here does nothing 
110 //    but this is where you should desallocate the internal/output pointers 
111 //    if any
112   
113 }
114 }
115 // EO namespace bbcreaVtk
116
117