]> Creatis software - bbtk.git/blob - packages/std/src/bbstdReadColumnsString.cxx
#2871 BBTK Bug New Normal Windows - ExecSystemCommand not blocking
[bbtk.git] / packages / std / src / bbstdReadColumnsString.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 "bbstdReadColumnsString.h"
32 #include "bbstdPackage.h"
33
34
35 #include<vector>
36
37 namespace bbstd
38 {
39
40 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ReadColumnsString)
41 BBTK_BLACK_BOX_IMPLEMENTATION(ReadColumnsString,bbtk::AtomicBlackBox);
42 //===== 
43 // 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)
44 //===== 
45 void ReadColumnsString::Process()
46 {
47         std::vector< std::vector<std::string> * > tlst; 
48         int i;
49         for( i=0 ;  i<bbGetInputDimension() ; i++)
50         {
51                 tlst.push_back( new std::vector<std::string> );
52         }       
53         int iSkipLines;
54         int numberOfLines = 0;
55         char tmpValue[500];
56         std::vector<std::string> *vecData;
57         FILE *ff1 = fopen( bbGetInputFileName().c_str() , "r+" );
58         if (ff1!=NULL)
59         {
60                 for (iSkipLines=0;iSkipLines<bbGetInputSkipLines(); iSkipLines++ )
61       {
62          fgets( tmpValue , 500, ff1 ); 
63       }
64
65                 while (!feof(ff1))
66                 {
67                         for( i=0 ;  i<bbGetInputDimension() ; i++)
68                         {
69                                 //EED Big careful not meesing the space caracter!!!
70 //                              fscanf(ff1,"%s",tmpValue);    // this line is not working in linux!
71                                 fscanf(ff1,"%s ",tmpValue);
72                                 vecData=tlst[i];
73                                 vecData->push_back( tmpValue );
74                         }       
75                         numberOfLines++;                        
76                 }       
77                 fclose(ff1);
78         } else {   // else ff1
79                 printf("bbcreaMaracasVisuReadAxisTree3D::Process  ...Error... reading file InputFileName_Points>%s", bbGetInputFileName().c_str() );
80         } //ff1 
81         
82         i=1; if (i<=bbGetInputDimension()) { bbSetOutputlstData1( *(tlst[i-1]) ); }
83         i=2; if (i<=bbGetInputDimension()) { bbSetOutputlstData2( *(tlst[i-1]) ); }
84         i=3; if (i<=bbGetInputDimension()) { bbSetOutputlstData3( *(tlst[i-1]) ); }
85         i=4; if (i<=bbGetInputDimension()) { bbSetOutputlstData4( *(tlst[i-1]) ); }
86         i=5; if (i<=bbGetInputDimension()) { bbSetOutputlstData5( *(tlst[i-1]) ); }
87         i=6; if (i<=bbGetInputDimension()) { bbSetOutputlstData6( *(tlst[i-1]) ); }
88         i=7; if (i<=bbGetInputDimension()) { bbSetOutputlstData7( *(tlst[i-1]) ); }
89         i=8; if (i<=bbGetInputDimension()) { bbSetOutputlstData8( *(tlst[i-1]) ); }
90         i=9; if (i<=bbGetInputDimension()) { bbSetOutputlstData9( *(tlst[i-1]) ); }
91         
92 }
93 //===== 
94 // 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)
95 //===== 
96 void ReadColumnsString::bbUserSetDefaultValues()
97 {
98
99 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
100 //    Here we initialize the input 'In' to 0
101         bbSetInputSkipLines(0); 
102         bbSetInputDimension(1); 
103         bbSetInputFileName(""); 
104   
105 }
106 //===== 
107 // 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)
108 //===== 
109 void ReadColumnsString::bbUserInitializeProcessing()
110 {
111
112 //  THE INITIALIZATION METHOD BODY :
113 //    Here does nothing 
114 //    but this is where you should allocate the internal/output pointers 
115 //    if any 
116
117   
118 }
119 //===== 
120 // 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)
121 //===== 
122 void ReadColumnsString::bbUserFinalizeProcessing()
123 {
124
125 //  THE FINALIZATION METHOD BODY :
126 //    Here does nothing 
127 //    but this is where you should desallocate the internal/output pointers 
128 //    if any
129   
130 }
131 }
132 // EO namespace bbstd
133
134