]> Creatis software - bbtk.git/blob - packages/std/src/bbstdReadColumnsInt.cxx
e860d23383c3a667c8d75637646d3c2db8431e43
[bbtk.git] / packages / std / src / bbstdReadColumnsInt.cxx
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 //=====
29 // 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)
30 //===== 
31 #include "bbstdReadColumnsInt.h"
32 #include "bbstdPackage.h"
33 namespace bbstd
34 {
35
36 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ReadColumnsInt)
37 BBTK_BLACK_BOX_IMPLEMENTATION(ReadColumnsInt,bbtk::AtomicBlackBox);
38 //===== 
39 // 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)
40 //===== 
41 void ReadColumnsInt::Process()
42 {
43         std::vector< std::vector<int> * > tlst; 
44         int i;
45         for( i=0 ;  i<bbGetInputDimension() ; i++)
46         {
47                 tlst.push_back( new std::vector<int> );
48         }       
49         int numberOfLines = 0;
50         char tmpValue[1000];
51         std::vector<int> *vecData;
52         FILE *ff1 = fopen( bbGetInputFileName().c_str() , "r+" );
53         if (ff1!=NULL)
54         {
55                 if (!feof(ff1))
56                         fscanf(ff1,"%s",tmpValue);
57
58                 while (!feof(ff1))
59                 {
60                         for( i=0 ;  i<bbGetInputDimension() ; i++)
61                         {
62                                 vecData=tlst[i];
63                                 vecData->push_back( atoi(tmpValue) );
64                                 fscanf(ff1,"%s",tmpValue);
65                         }       
66                         numberOfLines++;                        
67                 }       
68                 fclose(ff1);
69         } else {   // else ff1
70                 printf("ReadColumnsDouble::Process  ...Error... reading file FileName <%s>\n", bbGetInputFileName().c_str() );
71         } //ff1 
72         i=1; if (i<=bbGetInputDimension()) { bbSetOutputlstData1( *(tlst[i-1]) ); }
73         i=2; if (i<=bbGetInputDimension()) { bbSetOutputlstData2( *(tlst[i-1]) ); }
74         i=3; if (i<=bbGetInputDimension()) { bbSetOutputlstData3( *(tlst[i-1]) ); }
75         i=4; if (i<=bbGetInputDimension()) { bbSetOutputlstData4( *(tlst[i-1]) ); }
76         i=5; if (i<=bbGetInputDimension()) { bbSetOutputlstData5( *(tlst[i-1]) ); }
77         i=6; if (i<=bbGetInputDimension()) { bbSetOutputlstData6( *(tlst[i-1]) ); }
78         i=7; if (i<=bbGetInputDimension()) { bbSetOutputlstData7( *(tlst[i-1]) ); }
79         i=8; if (i<=bbGetInputDimension()) { bbSetOutputlstData8( *(tlst[i-1]) ); }
80         i=9; if (i<=bbGetInputDimension()) { bbSetOutputlstData9( *(tlst[i-1]) ); }     
81 }
82 //===== 
83 // 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)
84 //===== 
85 void ReadColumnsInt::bbUserSetDefaultValues()
86 {
87
88 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
89 //    Here we initialize the input 'In' to 0
90         bbSetInputDimension(1); 
91         bbSetInputFileName(""); 
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 ReadColumnsInt::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 ReadColumnsInt::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 bbstd
121
122