]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx
#2711 creaVtk Feature New Normal - new Box ReadMHDPlane
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkReadMHDPlane.cxx
index 42f6292a7d8b41b46e7b2dfa2ae2711a11bc80e5..53b6691816034e4d0be558c9a6e3a5ba3251a905 100644 (file)
@@ -32,19 +32,51 @@ void ReadMHDPlane::Process()
 //    bbSetOutputOut( bbGetInputIn() );
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
 
+       std::string inputfilename;
 
+       if (bbGetInputDirectionPlane()=="XY")
+       {
+               inputfilename=bbGetInputFileName();
+       } // if XY
+
+
+       if ((bbGetInputDirectionPlane()=="YZ") || (bbGetInputDirectionPlane()=="ZX"))
+       {
+
+               //-- Split FileName
+               std::size_t found               =       bbGetInputFileName().find_last_of("/\\");
+               std::string path                =       bbGetInputFileName().substr(0,found+1);
+               std::string filename    =       bbGetInputFileName().substr(found+1);
+#ifdef _WIN32
+               path=path+"YZ_ZX\\";
+#else
+               path=path+"YZ_ZX/";
+#endif
+       
+       
+               if (bbGetInputDirectionPlane()=="YZ") 
+               { 
+                       inputfilename = path+filename+"_YZ.mhd";  
+               } // if YZ
+
+               if (bbGetInputDirectionPlane()=="ZX")
+               {
+                       inputfilename = path+filename+"_ZX.mhd";
+               } // XZ
+       } // if YZ || XZ
 
        vtkImageData *newImage;
        long int newHeaderSize;
-    std::string newFileName=bbGetInputFileName()+"-OneSlice";
+    std::string newFileName=inputfilename+"-OneSlice";
 
     int sx,sy,sz;
     char mystring[250];
     char strTmp[20];
        bool ok=true;
-    FILE *ffIn = fopen(bbGetInputFileName().c_str(),"r+");
-       if (ffIn!=NULL){
-           FILE *ffOut = fopen(newFileName.c_str(),"w+");
+    FILE *ffIn = fopen(inputfilename.c_str(),"r");
+       if (ffIn!=NULL)
+       {
+           FILE *ffOut = fopen(newFileName.c_str(),"w");
 
        while(!feof(ffIn))
        {
@@ -85,11 +117,12 @@ void ReadMHDPlane::Process()
                } // if ok
        } else {
                ok=false;
+               printf("EED ERROR: Problem openin:%s\n", inputfilename.c_str() );
        }
 
        if (ok==false)
        {
-               int i,j;
+               int i;
                int sizeX, sizeY, sizeZ;
                sizeX = 200;
                sizeY = sizeX;
@@ -125,6 +158,7 @@ void ReadMHDPlane::bbUserSetDefaultValues()
 //    Here we initialize the input 'In' to 0
    bbSetInputFileName("");
    bbSetInputSlice(0);
+   bbSetInputDirectionPlane("XY");
   
 }
 //=====