]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkMHDFileInfo.cxx
#2960 creaVtk Bug New Normal - ElementSize = ElementSpacing in MHDFileInfo box and...
[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,14)==0)   { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &spcX,&spcY,&spcZ);    }
58                         if (strncmp("ElementSize",mystring,11)==0)              { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &spcX,&spcY,&spcZ);    }
59                 if (strncmp("Offset",mystring,6)==0)                    { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &ox, &oy, &oz);                }
60                 if (strncmp("HeaderSize",mystring,10)==0)               { sscanf(mystring,"%s %s %ld"           ,strTmp, strTmp, &headersize);                  }
61         } // while
62                 fclose(ffIn);
63         } // if
64
65         std::vector<int> LstDimSize;
66         LstDimSize.push_back(dimX);
67         LstDimSize.push_back(dimY);
68         LstDimSize.push_back(dimZ);
69
70         std::vector<double> LstSpacing;
71         LstSpacing.push_back((double)spcX);
72         LstSpacing.push_back((double)spcY);
73         LstSpacing.push_back((double)spcZ);
74
75         std::vector<double> LstOffset;
76         LstOffset.push_back((double)ox);
77         LstOffset.push_back((double)oy);
78         LstOffset.push_back((double)oz);
79
80         bbSetOutputDim( dim );
81         bbSetOutputDimSize( LstDimSize );
82         bbSetOutputElementType( formattype );
83         bbSetOutputElementSpacing( LstSpacing );
84         bbSetOutputOffset( LstOffset );
85         bbSetOutputHeaderSize( headersize );
86
87 }
88 //===== 
89 // 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)
90 //===== 
91 void MHDFileInfo::bbUserSetDefaultValues()
92 {
93
94 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
95 //    Here we initialize the input 'In' to 0
96
97   
98 }
99 //===== 
100 // 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)
101 //===== 
102 void MHDFileInfo::bbUserInitializeProcessing()
103 {
104
105 //  THE INITIALIZATION METHOD BODY :
106 //    Here does nothing 
107 //    but this is where you should allocate the internal/output pointers 
108 //    if any 
109
110   
111 }
112 //===== 
113 // 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)
114 //===== 
115 void MHDFileInfo::bbUserFinalizeProcessing()
116 {
117
118 //  THE FINALIZATION METHOD BODY :
119 //    Here does nothing 
120 //    but this is where you should desallocate the internal/output pointers 
121 //    if any
122   
123 }
124 }
125 // EO namespace bbcreaVtk
126
127