]> Creatis software - creaMiniTools.git/blob - bbtk_package_creaMiniTools/src/bbcreaMiniToolsCreateReport01.cxx
385ac657bf7f76ee3efcbda47046db5228e6f096
[creaMiniTools.git] / bbtk_package_creaMiniTools / src / bbcreaMiniToolsCreateReport01.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 "bbcreaMiniToolsCreateReport01.h"
5 #include "bbcreaMiniToolsPackage.h"
6 namespace bbcreaMiniTools
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMiniTools,CreateReport01)
10 BBTK_BLACK_BOX_IMPLEMENTATION(CreateReport01,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 CreateReport01::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 //    bbSetOutputOut( bbGetInputIn() );
29 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
30       
31     bbSetOutputLstTitles( bbGetInputLstTitles1() );
32     
33     std::vector<std::string> lstPatients    = bbGetInputLstPatientsID();
34     std::vector<std::string> lstTitles1     = bbGetInputLstTitles1();
35     std::vector<std::string> lstTitles2     = bbGetInputLstTitles2();
36     std::vector<std::string> lstStepsPath   = bbGetInputLstStepsPath();
37     std::vector<std::string> lstCommentsPath= bbGetInputLstCommentsPath();
38
39     std::vector<std::string> lstOut00;
40     std::vector<std::string> lstOut01;
41     std::vector<std::string> lstOut02;
42     std::vector<std::string> lstOut03;
43     std::vector<std::string> lstOut04;
44     std::vector<std::string> lstOut05;
45     std::vector<std::string> lstOut06;
46     std::vector<std::string> lstOut07;
47     std::vector<std::string> lstOut08;
48     std::vector<std::string> lstOut09;
49     std::vector<std::string> lstOut10;
50
51     std::vector< std::vector<std::string>* > pLstOut;
52     
53     pLstOut.push_back( &lstOut00 );
54     pLstOut.push_back( &lstOut01 );
55     pLstOut.push_back( &lstOut02 );
56     pLstOut.push_back( &lstOut03 );
57     pLstOut.push_back( &lstOut04 );
58     pLstOut.push_back( &lstOut05 );
59     pLstOut.push_back( &lstOut06 );
60     pLstOut.push_back( &lstOut07 );
61     pLstOut.push_back( &lstOut08 );
62     pLstOut.push_back( &lstOut09 );
63     pLstOut.push_back( &lstOut10 );
64
65
66     int iTitle2,sizeTitles2     = lstTitles2.size();
67     for (iTitle2=0 ; iTitle2<sizeTitles2 ; iTitle2++ )
68     {
69         pLstOut[iTitle2]->push_back( lstTitles2[iTitle2]  );
70         pLstOut[iTitle2]->push_back( " " );
71     } // for iTitle2
72     
73
74     int id;
75     int i,sizeLstPatientsID     = lstPatients.size();
76     int j,sizeLstStepsPath      = lstStepsPath.size();
77     int jj,sizeLstCommentsPath  = lstCommentsPath.size();
78     std::string stdPATIENT("<PATIENT>");
79     std::string pathFile;
80     FILE *ff;
81     char tmpTitle[255];
82     char tmpValue[255];
83     for ( i=0 ;  i<sizeLstPatientsID ; i++ )
84     {
85         pLstOut[0]->push_back( lstPatients[i] );
86         pLstOut[0]->push_back( " " );
87         pLstOut[0]->push_back( " " );
88         pLstOut[0]->push_back( " " );
89         pLstOut[0]->push_back( " " );
90
91         for (j=0; j<sizeLstStepsPath;j++)
92         {
93             id=j+1;
94             pathFile    = lstStepsPath[j];
95             size_t pos  = 0;
96             pos         = pathFile.find( stdPATIENT , pos);
97             pathFile.replace(pos, stdPATIENT.length(), lstPatients[i] );
98             printf("CreateReport01::Process %s \n", pathFile.c_str() );
99             ff=fopen(pathFile.c_str(), "r");
100             strcpy(tmpValue,"?EED?");
101             if (ff!=NULL)
102             {
103                 fscanf(ff,"%s ",tmpTitle);                 // User
104                 fscanf(ff,"%s ",tmpValue);                 //
105                 pLstOut[id]->push_back( tmpValue );
106                 fscanf(ff,"%s ",tmpTitle);                 // State
107                 fscanf(ff,"%s ",tmpValue);                 //
108                 pLstOut[id]->push_back( tmpValue );
109                 fscanf(ff,"%s ",tmpTitle);                 // Date
110                 fscanf(ff,"%s ",tmpValue);                 //
111                 pLstOut[id]->push_back( tmpValue );
112                 fscanf(ff,"%s ",tmpTitle);                 // Time
113                 fscanf(ff,"%s ",tmpValue);                 //
114                 pLstOut[id]->push_back( tmpValue );
115                 pLstOut[id]->push_back( " " );
116                 fclose(ff);
117             } else {
118                 pLstOut[id]->push_back( " " );
119                 pLstOut[id]->push_back( " " );
120                 pLstOut[id]->push_back( " " );
121                 pLstOut[id]->push_back( " " );
122                 pLstOut[id]->push_back( " " );
123             }// if ff
124         } // for j
125
126         for ( jj=0; jj<sizeLstCommentsPath ; jj++ )
127         {
128             id=jj+1+sizeLstStepsPath;
129
130             pathFile    = lstCommentsPath[jj];
131             size_t pos  = 0;
132             pos         = pathFile.find( stdPATIENT , pos);
133             pathFile.replace(pos, stdPATIENT.length(), lstPatients[i] );
134             printf("CreateReport01::Process %s \n", pathFile.c_str() );
135             ff=fopen(pathFile.c_str(), "r");
136             strcpy(tmpValue,"?EED?");
137             if (ff!=NULL)
138             {
139                 fgets(tmpValue,255,ff);
140                 pLstOut[id]->push_back( tmpValue );
141                 pLstOut[id]->push_back( " " );
142                 pLstOut[id]->push_back( " " );
143                 pLstOut[id]->push_back( " " );
144                 pLstOut[id]->push_back( " " );
145
146                 /*
147                 fscanf(ff,"%s ",tmpTitle);                 // User
148                 fscanf(ff,"%s ",tmpValue);                 //
149                 pLstOut[id]->push_back( tmpValue );
150                 fscanf(ff,"%s ",tmpTitle);                 // State
151                 fscanf(ff,"%s ",tmpValue);                 //
152                 pLstOut[id]->push_back( tmpValue );
153                 fscanf(ff,"%s ",tmpTitle);                 // Date
154                 fscanf(ff,"%s ",tmpValue);                 //
155                 pLstOut[id]->push_back( tmpValue );
156                 fscanf(ff,"%s ",tmpTitle);                 // Time
157                 fscanf(ff,"%s ",tmpValue);                 //
158                 pLstOut[id]->push_back( tmpValue );
159                 pLstOut[id]->push_back( " " );
160                  
161                 */
162                 
163                 fclose(ff);
164             } else {
165                 pLstOut[id]->push_back( "Error file name" );
166                 pLstOut[id]->push_back( " " );
167                 pLstOut[id]->push_back( " " );
168                 pLstOut[id]->push_back( " " );
169                 pLstOut[id]->push_back( " " );
170             }// if ff
171         } // for j
172
173     } // for i
174     
175     bbSetOutputOut00( lstOut00 );
176     bbSetOutputOut01( lstOut01 );
177     bbSetOutputOut02( lstOut02 );
178     bbSetOutputOut03( lstOut03 );
179     bbSetOutputOut04( lstOut04 );
180     bbSetOutputOut05( lstOut05 );
181     bbSetOutputOut06( lstOut06 );
182     bbSetOutputOut07( lstOut07 );
183     bbSetOutputOut08( lstOut08 );
184     bbSetOutputOut09( lstOut09 );
185     bbSetOutputOut10( lstOut10 );
186 }
187 //===== 
188 // 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)
189 //===== 
190 void CreateReport01::bbUserSetDefaultValues()
191 {
192
193 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
194 //    Here we initialize the input 'In' to 0
195 //   bbSetInputIn(0);
196   
197 }
198 //===== 
199 // 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)
200 //===== 
201 void CreateReport01::bbUserInitializeProcessing()
202 {
203
204 //  THE INITIALIZATION METHOD BODY :
205 //    Here does nothing 
206 //    but this is where you should allocate the internal/output pointers 
207 //    if any 
208
209   
210 }
211 //===== 
212 // 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)
213 //===== 
214 void CreateReport01::bbUserFinalizeProcessing()
215 {
216
217 //  THE FINALIZATION METHOD BODY :
218 //    Here does nothing 
219 //    but this is where you should desallocate the internal/output pointers 
220 //    if any
221   
222 }
223 }
224 // EO namespace bbcreaMiniTools
225
226