]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkMHDFileInfo.cxx
#2913 creaVtk Feature New Normal - new box MHDFileInfo
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkMHDFileInfo.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 "bbcreaVtkMHDFileInfo.h"
5 #include "bbcreaVtkPackage.h"
6 namespace bbcreaVtk
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MHDFileInfo)
10 BBTK_BLACK_BOX_IMPLEMENTATION(MHDFileInfo,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 MHDFileInfo::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
33         std::string inputfilename;
34         inputfilename=bbGetInputFileName();
35
36
37         int dimX=-1,dimY=-1,dimZ=-1;
38         int dim=-1;
39         std::string formattype("VOID");
40         float spcX=-1,spcY=-1,spcZ=-1;
41         float ox=-1,oy=-1,oz=-1;
42         long int headersize=0;
43
44         char mystring[250];
45         char strTmp[30];
46         char strTmp2[30];
47         FILE *ffIn      = fopen(inputfilename.c_str(),"r");
48         if (ffIn!=NULL)
49         {
50                 while(!feof(ffIn))
51                 {
52             strcpy(mystring,"\n");
53                         fgets(mystring,250,ffIn);
54                 if (strncmp("NDims",mystring,5)==0)                     { sscanf(mystring,"%s %s %d"            ,strTmp, strTmp, &dim);                                 }
55                 if (strncmp("DimSize",mystring,6)==0)                   { sscanf(mystring,"%s %s %d %d %d"      ,strTmp, strTmp, &dimX, &dimY,&dimZ);   } 
56                         if (strncmp("ElementType",mystring,11)==0)              { sscanf(mystring,"%s %s %s"            ,strTmp, strTmp, strTmp2); formattype=strTmp2;                  }
57                         if (strncmp("ElementSpacing",mystring,11)==0)   { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &spcX,&spcY,&spcY);    }
58                 if (strncmp("Offset",mystring,6)==0)                    { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &ox, &oy, &oz);                }
59                 if (strncmp("HeaderSize",mystring,10)==0)               { sscanf(mystring,"%s %s %ld"           ,strTmp, strTmp, &headersize);                  }
60         } // while
61                 fclose(ffIn);
62         } // if
63
64         std::vector<int> LstDimSize;
65         LstDimSize.push_back(dimX);
66         LstDimSize.push_back(dimY);
67         LstDimSize.push_back(dimZ);
68
69         std::vector<double> LstSpacing;
70         LstSpacing.push_back((double)spcX);
71         LstSpacing.push_back((double)spcY);
72         LstSpacing.push_back((double)spcZ);
73
74         std::vector<double> LstOffset;
75         LstOffset.push_back((double)ox);
76         LstOffset.push_back((double)oy);
77         LstOffset.push_back((double)oz);
78
79         bbSetOutputDim( dim );
80         bbSetOutputDimSize( LstDimSize );
81         bbSetOutputElementType( formattype );
82         bbSetOutputElementSpacing( LstSpacing );
83         bbSetOutputOffset( LstOffset );
84         bbSetOutputHeaderSize( headersize );
85
86 }
87 //===== 
88 // 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)
89 //===== 
90 void MHDFileInfo::bbUserSetDefaultValues()
91 {
92
93 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
94 //    Here we initialize the input 'In' to 0
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 MHDFileInfo::bbUserInitializeProcessing()
102 {
103
104 //  THE INITIALIZATION METHOD BODY :
105 //    Here does nothing 
106 //    but this is where you should allocate the internal/output pointers 
107 //    if any 
108
109   
110 }
111 //===== 
112 // 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)
113 //===== 
114 void MHDFileInfo::bbUserFinalizeProcessing()
115 {
116
117 //  THE FINALIZATION METHOD BODY :
118 //    Here does nothing 
119 //    but this is where you should desallocate the internal/output pointers 
120 //    if any
121   
122 }
123 }
124 // EO namespace bbcreaVtk
125
126