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