]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx
#2811 creaVtk Feature New Normal - Concat Transform ImageAccumulate TransformVector
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkReadMHDPlane.cxx
index 42f6292a7d8b41b46e7b2dfa2ae2711a11bc80e5..11276096f7fadf9b99ecd1cab3ac366e67c3c672 100644 (file)
@@ -32,24 +32,61 @@ 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+");
-       if (ffIn!=NULL){
-           FILE *ffOut = fopen(newFileName.c_str(),"w+");
+    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) 
                        {
@@ -71,7 +108,9 @@ void ReadMHDPlane::Process()
                        {
                                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);
@@ -85,11 +124,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;
@@ -113,6 +153,7 @@ void ReadMHDPlane::Process()
        } // if ok
 
        bbSetOutputOut( newImage );
+printf("EED ReadMHDPlane::Process End\n");
 
 }
 //===== 
@@ -125,6 +166,7 @@ void ReadMHDPlane::bbUserSetDefaultValues()
 //    Here we initialize the input 'In' to 0
    bbSetInputFileName("");
    bbSetInputSlice(0);
+   bbSetInputDirectionPlane("XY");
   
 }
 //=====