]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx
#2913 creaVtk Feature New Normal - new box MHDFileInfo
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkReadMHDPlane.cxx
index 60b4aa1fdd4186783f6c52b46b9848df5383f59b..6bb42f73c63da4b3eef6c1ea599c9d0cc0c0f968 100644 (file)
@@ -32,28 +32,56 @@ void ReadMHDPlane::Process()
 //    bbSetOutputOut( bbGetInputIn() );
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
 
-printf("EED ReadMHDPlane::Process Start\n");
+       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");
+    FILE *ffIn = fopen(inputfilename.c_str(),"r");
        if (ffIn!=NULL)
        {
-printf("EED ReadMHDPlane::Process 1\n");
            FILE *ffOut = fopen(newFileName.c_str(),"w");
-printf("EED ReadMHDPlane::Process 2 %p  %s\n",ffOut, newFileName.c_str() );
 
        while(!feof(ffIn))
        {
            strcpy(mystring,"\n");
                        fgets(mystring,250,ffIn);
-printf("EED ReadMHDPlane::Process MHD:%s\n", mystring);
                if (strncmp("NDims",mystring,5)==0) {strcpy(mystring,"NDims = 2\n");}
                if (strncmp("DimSize",mystring,6)==0) 
                        {
@@ -62,8 +90,8 @@ printf("EED ReadMHDPlane::Process MHD:%s\n", mystring);
                        newHeaderSize = sx*sy*bbGetInputSlice();
                                if (bbGetInputSlice()>=sz) {ok=false;}
                        } // if
-               if (strncmp("ElementType = MET_CHAR",mystring,24)==0)   { newHeaderSize=newHeaderSize*1; }
-               if (strncmp("ElementType = MET_UCHAR",mystring,24)==0)  { newHeaderSize=newHeaderSize*1; }
+               if (strncmp("ElementType = MET_CHAR",mystring,22)==0)   { newHeaderSize=newHeaderSize*1; }
+               if (strncmp("ElementType = MET_UCHAR",mystring,23)==0)  { newHeaderSize=newHeaderSize*1; }
                if (strncmp("ElementType = MET_USHORT",mystring,24)==0) { newHeaderSize=newHeaderSize*2; }
                if (strncmp("ElementType = MET_USHORT",mystring,24)==0) { newHeaderSize=newHeaderSize*2; }
                if (strncmp("ElementType = MET_SHORT",mystring,23)==0)  { newHeaderSize=newHeaderSize*2; }
@@ -75,9 +103,7 @@ printf("EED ReadMHDPlane::Process MHD:%s\n", mystring);
                        {
                                fprintf(ffOut,"HeaderSize = %ld\n\n", newHeaderSize );
                        } // if
-printf("EED ReadMHDPlane::Process 3\n");
                fprintf(ffOut,mystring); 
-printf("EED ReadMHDPlane::Process 4\n");
        } // while
                fclose(ffIn);
                fclose(ffOut);
@@ -91,7 +117,7 @@ printf("EED ReadMHDPlane::Process 4\n");
                } // if ok
        } else {
                ok=false;
-               printf("EED ERROR: Problem openin:%s\n", bbGetInputFileName().c_str() );
+               printf("EED ERROR: Problem openin:%s\n", inputfilename.c_str() );
        }
 
        if (ok==false)
@@ -120,7 +146,6 @@ printf("EED ReadMHDPlane::Process 4\n");
        } // if ok
 
        bbSetOutputOut( newImage );
-printf("EED ReadMHDPlane::Process End\n");
 
 }
 //===== 
@@ -133,6 +158,7 @@ void ReadMHDPlane::bbUserSetDefaultValues()
 //    Here we initialize the input 'In' to 0
    bbSetInputFileName("");
    bbSetInputSlice(0);
+   bbSetInputDirectionPlane("XY");
   
 }
 //=====