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