]> Creatis software - creaVtk.git/commitdiff
#2711 creaVtk Feature New Normal - new Box ReadMHDPlane
authorEduardo DAVILA <davila@localhost.localdomain>
Mon, 4 Dec 2017 21:33:32 +0000 (22:33 +0100)
committerEduardo DAVILA <davila@localhost.localdomain>
Mon, 4 Dec 2017 21:33:32 +0000 (22:33 +0100)
bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.h

index 223fe7e590c57219a95c349e9aca5c81ef77469e..4364ec6ee0f914a9ab2a270c179348bc6f8719bd 100644 (file)
@@ -59,7 +59,7 @@ vtkImageData* ReadMHDPlane::CreateDefaultImage()
        return newImage;
 } 
 
-
+/* EED Borrame
 void ReadMHDPlane::ReadNormalMHD()
 {
 // THE MAIN PROCESSING METHOD BODY
@@ -82,13 +82,11 @@ void ReadMHDPlane::ReadNormalMHD()
        int width;
        long long dataSize;
 
-
        if (bbGetInputDirectionPlane()=="XY")
        {
                inputfilename=bbGetInputFileName();
        } // if XY
 
-
        if ((bbGetInputDirectionPlane()=="YZ") || (bbGetInputDirectionPlane()=="ZX"))
        {
                //-- Split FileName
@@ -129,7 +127,6 @@ void ReadMHDPlane::ReadNormalMHD()
        if (ffIn!=NULL)
        {
            FILE *ffOut = fopen(newFileName.c_str(),"w");
-
        while(!feof(ffIn))
        {
            strcpy(mystring,"\n");
@@ -146,14 +143,12 @@ void ReadMHDPlane::ReadNormalMHD()
                if (strncmp("DimSize",mystring,6)==0) 
                        {
                                sscanf(mystring,"%s %s %d %d %d",strTmp, strTmp, &sx, &sy,&sz);
-
                                if (width==1) 
                                { 
                                        sprintf(mystring,"DimSize = %d %d\n",sx,sy);
                                } else {
                                        sprintf(mystring,"DimSize = %d %d %d\n",sx,sy,width);
                                }
-
                        newHeaderSize = (long long int)sx*(long long int)sy*(long long int)slice;
                                if (bbGetInputSlice()>=sz) {ok=false;}
                        } // if
@@ -176,7 +171,6 @@ void ReadMHDPlane::ReadNormalMHD()
                if (strncmp("ElementType = MET_DOUBLE",mystring,24)==0)                 { dataSize=sizeof(double);                      }
                if (strncmp("ElementType = VTK_DOUBLE",mystring,24)==0)                 { dataSize=sizeof(double);                      }
                        newHeaderSize=newHeaderSize*dataSize;
-
                if (strncmp("Offset",mystring,6)==0) {strcpy(mystring,"Offset = 0 0 0\n");}
                if (strncmp("HeaderSize",mystring,10)==0) {strcpy(mystring,"");}
                if (strncmp("ElementDataFile",mystring,15)==0) 
@@ -187,7 +181,6 @@ void ReadMHDPlane::ReadNormalMHD()
        } // while
                fclose(ffIn);
                fclose(ffOut);
-
                if (ok==true)
                {
                        vtkMetaImageReader * reader = vtkMetaImageReader::New();
@@ -198,31 +191,81 @@ void ReadMHDPlane::ReadNormalMHD()
        } else {
                ok=false;
                printf("EED ERROR: Problem openin:%s\n", inputfilename.c_str() );
-       }
-
+       }// if ffIn
        if (ok==false)
        {
                newImage=CreateDefaultImage();
        } // if ok
 
        bbSetOutputOut( newImage );
+       bbSetOutputOut2( ChangeOrientation(newImage) );
 }
+*/
 
+vtkImageData* ReadMHDPlane::ChangeOrientation(vtkImageData* img)
+{
+       int ext[6];
+       int sizeX, sizeY,sizeZ;
+       img->GetWholeExtent(ext);
+       int sizeLine;
+       if (bbGetInputDirectionPlane()=="XY")
+       {
+               sizeX           = ext[1]-ext[0]+1;
+               sizeY           = ext[3]-ext[2]+1;
+               sizeZ           = 1;
+       } // XY 
+       if (bbGetInputDirectionPlane()=="YZ") 
+       {
+               sizeX           = 1;
+               sizeY           = ext[1]-ext[0]+1;
+               sizeZ           = ext[3]-ext[2]+1;
+               sizeLine        = sizeY;
+       } // YZ
+       if (bbGetInputDirectionPlane()=="ZX")
+       {
+               sizeX           = ext[1]-ext[0]+1;
+               sizeY           = 1;
+               sizeZ           = ext[3]-ext[2]+1;
+               sizeLine        = sizeX;
+       } // ZX
+       vtkImageData *newImageOrinted  = vtkImageData::New();
+       newImageOrinted->Initialize();
+       newImageOrinted->SetScalarType( img->GetScalarType() );
+       newImageOrinted->SetSpacing( img->GetSpacing() );
+       newImageOrinted->SetDimensions( sizeX,sizeY,sizeZ );
+       newImageOrinted->SetWholeExtent(0,sizeX-1,0,sizeY-1,0,sizeZ-1 );
+       newImageOrinted->SetExtent(0,sizeX-1,0,sizeY-1,0,sizeZ-1 );
+       newImageOrinted->SetNumberOfScalarComponents(1);
+       newImageOrinted->AllocateScalars();
+       newImageOrinted->Update();
+       if (bbGetInputDirectionPlane()=="XY")
+       {
+               memcpy ( newImageOrinted->GetScalarPointer(), img->GetScalarPointer(), sizeX*sizeY*sizeZ*img->GetScalarSize() );
+       } else  {
+               int yy;
+               int dimY=ext[3]-ext[2]+1;
+               int sizeByte=sizeLine*img->GetScalarSize();             
+               void *ptrDst=newImageOrinted->GetScalarPointer() + sizeByte*dimY;
+               void *ptrOrg=img->GetScalarPointer();
+               for (yy=0 ; yy<dimY; yy++)
+               {
+                       ptrDst=ptrDst-sizeByte;
+                       memcpy ( ptrDst, ptrOrg , sizeByte );
+                       ptrOrg=ptrOrg+sizeByte;
+               }// for
+       }
+       return newImageOrinted;
+}
 
-
-
-
+/* EED Borrame
 void ReadMHDPlane::Read64lseek()
 {
        int             slice;
        int             width;
-
        width = bbGetInputWidth();
        if (width<=0 ) { width=1; }
-
        slice = bbGetInputSlice();
        if (slice<0 ) { slice=0; }
-
        int             dimX=-1,dimY=-1,dimZ=-1;
        int             dim=-1;
        std::string formattype("VOID");
@@ -230,32 +273,27 @@ void ReadMHDPlane::Read64lseek()
        float           spcX=-1,spcY=-1,spcZ=-1;
        float           ox=-1,oy=-1,oz=-1;
        long int        headersize=0;
-
        vtkImageData *newImage=NULL;
-
        char mystring[250];
        char strTmp[30];
        char strTmp2[30];
        FILE *ffIn      = fopen(bbGetInputFileName().c_str(),"r");
        long long dataSize;
-
        if (ffIn!=NULL)
        {
                newImage = vtkImageData::New();
-
                while(!feof(ffIn))
                {
            strcpy(mystring,"\n");
                        fgets(mystring,250,ffIn);
-               if (strncmp("NDims",mystring,5)==0)                     { sscanf(mystring,"%s %s %d"            ,strTmp, strTmp, &dim);                                 }
-               if (strncmp("DimSize",mystring,6)==0)                   { sscanf(mystring,"%s %s %d %d %d"      ,strTmp, strTmp, &dimX, &dimY,&dimZ);   } 
+               if (strncmp("NDims",mystring,5)==0)                     { sscanf(mystring,"%s %s %d"            ,strTmp, strTmp, &dim);                                                                 }
+               if (strncmp("DimSize",mystring,6)==0)                   { sscanf(mystring,"%s %s %d %d %d"      ,strTmp, strTmp, &dimX, &dimY,&dimZ);                                   
                        if (strncmp("ElementType",mystring,11)==0)              { sscanf(mystring,"%s %s %s"            ,strTmp, strTmp, strTmp2); formattype=strTmp2;                  }
-                       if (strncmp("ElementSpacing",mystring,14)==0)   { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &spcX,&spcY,&spcZ);    }
-                       if (strncmp("ElementSize",mystring,11)==0)              { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &spcX,&spcY,&spcZ);    }
-               if (strncmp("Offset",mystring,6)==0)                    { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &ox, &oy, &oz);                }
-               if (strncmp("HeaderSize",mystring,10)==0)               { sscanf(mystring,"%s %s %ld"           ,strTmp, strTmp, &headersize);                  }
+                       if (strncmp("ElementSpacing",mystring,14)==0)   { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &spcX,&spcY,&spcZ);                                    }
+                       if (strncmp("ElementSize",mystring,11)==0)              { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &spcX,&spcY,&spcZ);                                    }
+               if (strncmp("Offset",mystring,6)==0)                    { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &ox, &oy, &oz);                                                }
+               if (strncmp("HeaderSize",mystring,10)==0)               { sscanf(mystring,"%s %s %ld"           ,strTmp, strTmp, &headersize);                                                  }
                        if (strncmp("ElementDataFile",mystring,15)==0)  { sscanf(mystring,"%s %s %s"            ,strTmp, strTmp, strTmp2); elementdatafile=strTmp2;             }
-
                if (strncmp("ElementType = MET_CHAR",mystring,22)==0)                   { newImage->SetScalarTypeToChar();                      dataSize=sizeof(char);                  }
                if (strncmp("ElementType = VTK_CHAR",mystring,22)==0)                   { newImage->SetScalarTypeToChar();                      dataSize=sizeof(char);                  }
                if (strncmp("ElementType = MET_UCHAR",mystring,23)==0)                  { newImage->SetScalarTypeToUnsignedChar();      dataSize=sizeof(unsigned char); }
@@ -274,13 +312,9 @@ void ReadMHDPlane::Read64lseek()
                if (strncmp("ElementType = VTK_LONG",mystring,22)==0)                   { newImage->SetScalarTypeToLong();                      dataSize=sizeof(long);                  }
                if (strncmp("ElementType = MET_DOUBLE",mystring,24)==0)                 { newImage->SetScalarTypeToDouble();            dataSize=sizeof(double);                }
                if (strncmp("ElementType = VTK_DOUBLE",mystring,24)==0)                 { newImage->SetScalarTypeToDouble();            dataSize=sizeof(double);                }
-
        } // while
                fclose(ffIn);
-
                newImage->Initialize();
-
-
                int             fd;
                long long       ret;
                std::size_t found;
@@ -288,17 +322,12 @@ void ReadMHDPlane::Read64lseek()
                found                                   = bbGetInputFileName().find_last_of("/\\");
                filename                                = bbGetInputFileName().substr(0,found+1) + elementdatafile ;
                long long       pos;
-
                long long lsize                 = dimX*dimY*width *dataSize;
-
-
 #if defined(_WIN32)
                   _sopen_s( &fd, filename.c_str(), _O_RDONLY, _SH_DENYNO, 0 );
 #else
                fd = open ( filename.c_str() ,  O_RDONLY|O_LARGEFILE );
 #endif // defined(_WIN32)
-
-
                if (fd < 0)
                {
                        printf("EED ReadMHDPlane::Read64lseek   WARNNING! raw file not exist\n");
@@ -306,8 +335,6 @@ void ReadMHDPlane::Read64lseek()
                        newImage=CreateDefaultImage();
 //                     exit(1);
                }       
-               
-
                if ((bbGetInputDirectionPlane()=="XY") && (fd>=0)) 
                { 
                        newImage->SetSpacing( spcX,spcY,spcZ );
@@ -328,15 +355,13 @@ void ReadMHDPlane::Read64lseek()
                                fprintf(stderr, "Failed seeking to %lld, %s\n", pos, strerror(errno));
                                exit(1);
                        }
-
                        if ((ret = read(fd, newImage->GetScalarPointer() , lsize)) < 0) 
                        {
                                fprintf(stderr, "Failed reading: %s\n", strerror(errno));
                                exit(1);
                        }
                }  // if PLANE XY
-
-               if ((bbGetInputDirectionPlane()=="XZ") && (fd>=0))
+               if ((bbGetInputDirectionPlane()=="ZX") && (fd>=0))
                { 
                        newImage->SetSpacing( spcX,spcZ,spcY );
                        newImage->SetDimensions(  dimX,dimZ,width );
@@ -348,10 +373,9 @@ void ReadMHDPlane::Read64lseek()
                        int iWidth;
                        for (iWidth=0;iWidth<width;iWidth++)
                        {
-                               copy_XZ_plane(fd,newImage,slice+iWidth,iWidth,dimX,dimY,dimZ,dataSize);
+                               copy_ZX_plane(fd,newImage,slice+iWidth,iWidth,dimX,dimY,dimZ,dataSize);
                        }
                }  // if PLANE XZ
-
                if ((bbGetInputDirectionPlane()=="YZ") && (fd>=0))
                { 
                        newImage->SetSpacing( spcY,spcZ,spcX );
@@ -366,7 +390,6 @@ void ReadMHDPlane::Read64lseek()
                        {
                                copy_YZ_plane(fd,newImage,slice+iWidth,iWidth,dimX,dimY,dimZ,dataSize);
                        }
-
                }  // if PLANE YZ       
 #if defined(_WIN32)
                _close (fd);
@@ -376,8 +399,154 @@ void ReadMHDPlane::Read64lseek()
        } else {
                newImage=CreateDefaultImage();
        } // if  ffIn
+       bbSetOutputOut( newImage );
+       bbSetOutputOut2( ChangeOrientation(newImage) );
+}
+*/
 
+void ReadMHDPlane::Read64lseek(std::string fileNameIn, std::string plane)
+{
+       int             slice;
+       int             width;
+       width = bbGetInputWidth();
+       if (width<=0 ) { width=1; }
+       slice = bbGetInputSlice();
+       if (slice<0 ) { slice=0; }
+       int             dimX=-1,dimY=-1,dimZ=-1;
+       int             dim=-1;
+       std::string formattype("VOID");
+       std::string elementdatafile("VOID");
+       float           spcX=-1,spcY=-1,spcZ=-1;
+       float           ox=-1,oy=-1,oz=-1;
+       long int        headersize=0;
+       vtkImageData *newImage=NULL;
+       char mystring[250];
+       char strTmp[30];
+       char strTmp2[30];
+       FILE *ffIn      = fopen( fileNameIn.c_str() , "r");
+       long long dataSize;
+       if (ffIn!=NULL)
+       {
+               newImage = vtkImageData::New();
+               while(!feof(ffIn))
+               {
+           strcpy(mystring,"\n");
+                       fgets(mystring,250,ffIn);
+               if (strncmp("NDims",mystring,5)==0)                     { sscanf(mystring,"%s %s %d"            ,strTmp, strTmp, &dim);                                                                 }
+               if (strncmp("DimSize",mystring,6)==0)                   { sscanf(mystring,"%s %s %d %d %d"      ,strTmp, strTmp, &dimX, &dimY,&dimZ);                                   } 
+                       if (strncmp("ElementType",mystring,11)==0)              { sscanf(mystring,"%s %s %s"            ,strTmp, strTmp, strTmp2); formattype=strTmp2;                  }
+                       if (strncmp("ElementSpacing",mystring,14)==0)   { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &spcX,&spcY,&spcZ);                                    }
+                       if (strncmp("ElementSize",mystring,11)==0)              { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &spcX,&spcY,&spcZ);                                    }
+               if (strncmp("Offset",mystring,6)==0)                    { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &ox, &oy, &oz);                                                }
+               if (strncmp("HeaderSize",mystring,10)==0)               { sscanf(mystring,"%s %s %ld"           ,strTmp, strTmp, &headersize);                                                  }
+                       if (strncmp("ElementDataFile",mystring,15)==0)  { sscanf(mystring,"%s %s %s"            ,strTmp, strTmp, strTmp2); elementdatafile=strTmp2;             }
+               if (strncmp("ElementType = MET_CHAR",mystring,22)==0)                   { newImage->SetScalarTypeToChar();                      dataSize=sizeof(char);                  }
+               if (strncmp("ElementType = VTK_CHAR",mystring,22)==0)                   { newImage->SetScalarTypeToChar();                      dataSize=sizeof(char);                  }
+               if (strncmp("ElementType = MET_UCHAR",mystring,23)==0)                  { newImage->SetScalarTypeToUnsignedChar();      dataSize=sizeof(unsigned char); }
+               if (strncmp("ElementType = VTK_UNSIGNED_CHAR",mystring,31)==0)  { newImage->SetScalarTypeToUnsignedChar();      dataSize=sizeof(unsigned char); }
+               if (strncmp("ElementType = MET_USHORT",mystring,24)==0)                 { newImage->SetScalarTypeToUnsignedShort();     dataSize=sizeof(unsigned short);}
+               if (strncmp("ElementType = VTK_UNSIGNED_SHORT",mystring,32)==0) { newImage->SetScalarTypeToUnsignedShort();     dataSize=sizeof(unsigned short);}
+               if (strncmp("ElementType = MET_SHORT",mystring,23)==0)                  { newImage->SetScalarTypeToShort();                     dataSize=sizeof(short);                 }
+               if (strncmp("ElementType = VTK_SHORT",mystring,23)==0)                  { newImage->SetScalarTypeToShort();                     dataSize=sizeof(short);                 }
+               if (strncmp("ElementType = MET_UINT",mystring,22)==0)                   { newImage->SetScalarTypeToUnsignedInt();       dataSize=sizeof(unsigned int);  }
+               if (strncmp("ElementType = VTK_UNSIGNED_INT",mystring,30)==0)   { newImage->SetScalarTypeToUnsignedInt();       dataSize=sizeof(unsigned int);  }
+               if (strncmp("ElementType = MET_INT",mystring,21)==0)                    { newImage->SetScalarTypeToInt();                       dataSize=sizeof(int);                   }
+               if (strncmp("ElementType = VTK_INT",mystring,21)==0)                    { newImage->SetScalarTypeToInt();                       dataSize=sizeof(int);                   }
+               if (strncmp("ElementType = MET_FLOAT",mystring,23)==0)                  { newImage->SetScalarTypeToFloat();                     dataSize=sizeof(float);                 }
+               if (strncmp("ElementType = VTK_FLOAT",mystring,23)==0)                  { newImage->SetScalarTypeToFloat();                     dataSize=sizeof(float);                 }
+               if (strncmp("ElementType = MET_LONG",mystring,22)==0)                   { newImage->SetScalarTypeToLong();                      dataSize=sizeof(long);                  }
+               if (strncmp("ElementType = VTK_LONG",mystring,22)==0)                   { newImage->SetScalarTypeToLong();                      dataSize=sizeof(long);                  }
+               if (strncmp("ElementType = MET_DOUBLE",mystring,24)==0)                 { newImage->SetScalarTypeToDouble();            dataSize=sizeof(double);                }
+               if (strncmp("ElementType = VTK_DOUBLE",mystring,24)==0)                 { newImage->SetScalarTypeToDouble();            dataSize=sizeof(double);                }
+       } // while
+               fclose(ffIn);
+               newImage->Initialize();
+               int             fd;
+               long long       ret;
+               std::size_t found;
+               std::string filename;
+               found                                   = fileNameIn.find_last_of("/\\");
+               filename                                = fileNameIn.substr(0,found+1) + elementdatafile ;
+               long long       pos;
+               long long lsize                 = dimX*dimY*width *dataSize;
+#if defined(_WIN32)
+                  _sopen_s( &fd, filename.c_str(), _O_RDONLY, _SH_DENYNO, 0 );
+#else
+               fd = open ( filename.c_str() ,  O_RDONLY|O_LARGEFILE );
+#endif // defined(_WIN32)
+               if (fd < 0)
+               {
+                       printf("EED ReadMHDPlane::Read64lseek   WARNNING! raw file not exist\n");
+                       fprintf(stderr, "%s\n", strerror(errno));
+                       newImage=CreateDefaultImage();
+//                     exit(1);
+               }       
+               if ((plane=="XY") && (fd>=0)) 
+               { 
+                       newImage->SetSpacing( spcX,spcY,spcZ );
+                       newImage->SetDimensions(  dimX,dimY,width );
+                       newImage->SetWholeExtent(0,  dimX-1,0,dimY-1,0,width-1 );
+                       newImage->SetExtent(0,  dimX-1,0,dimY-1,0,width-1 );
+                       newImage->SetNumberOfScalarComponents(1);
+                       newImage->AllocateScalars();
+                       newImage->Update();
+                       pos = dimX*dimY*(long long)slice*dataSize;
+#if defined(_WIN32)
+                       if (_lseeki64( fd, pos, SEEK_SET ) < 0)
+#else
+                       if (lseek64(fd, pos, SEEK_SET) < 0) 
+#endif // defined(_WIN32)
+                       {
+                               printf("EED ReadMHDPlane::Read64lseek \n");
+                               fprintf(stderr, "Failed seeking to %lld, %s\n", pos, strerror(errno));
+                               exit(1);
+                       }
+                       if ((ret = read(fd, newImage->GetScalarPointer() , lsize)) < 0) 
+                       {
+                               fprintf(stderr, "Failed reading: %s\n", strerror(errno));
+                               exit(1);
+                       }
+               }  // if PLANE XY
+               if ((plane=="ZX") && (fd>=0))
+               { 
+                       newImage->SetSpacing( spcX,spcZ,spcY );
+                       newImage->SetDimensions(  dimX,dimZ,width );
+                       newImage->SetWholeExtent(0,  dimX-1,0,dimZ-1,0,width-1 );
+                       newImage->SetExtent(0,  dimX-1,0,dimZ-1,0,width-1 );
+                       newImage->SetNumberOfScalarComponents(1);
+                       newImage->AllocateScalars();
+                       newImage->Update();
+                       int iWidth;
+                       for (iWidth=0;iWidth<width;iWidth++)
+                       {
+                               copy_ZX_plane(fd,newImage,slice+iWidth,iWidth,dimX,dimY,dimZ,dataSize);
+                       }
+               }  // if PLANE XZ
+               if ((plane=="YZ") && (fd>=0))
+               { 
+                       newImage->SetSpacing( spcY,spcZ,spcX );
+                       newImage->SetDimensions(  dimY,dimZ,width );
+                       newImage->SetWholeExtent(0,  dimY-1,0,dimZ-1,0,width-1 );
+                       newImage->SetExtent(0,  dimY-1,0,dimZ-1,0,width-1 );
+                       newImage->SetNumberOfScalarComponents(1);
+                       newImage->AllocateScalars();
+                       newImage->Update();
+                       int iWidth;
+                       for (iWidth=0;iWidth<width;iWidth++)
+                       {
+                               copy_YZ_plane(fd,newImage,slice+iWidth,iWidth,dimX,dimY,dimZ,dataSize);
+                       }
+               }  // if PLANE YZ       
+#if defined(_WIN32)
+               _close (fd);
+#else
+               close (fd);
+#endif // defined(_WIN32)
+       } else {
+               newImage=CreateDefaultImage();
+       } // if  ffIn
        bbSetOutputOut( newImage );
+       bbSetOutputOut2( ChangeOrientation(newImage) );
 }
 
 
@@ -416,7 +585,7 @@ void ReadMHDPlane::copy_YZ_plane(int fd,vtkImageData *newImage,int slice,int iWi
 }
 
 
-void ReadMHDPlane::copy_XZ_plane(int fd,vtkImageData *newImage,int slice,int iWidth,int dimX,int dimY,int dimZ,int dataSize)
+void ReadMHDPlane::copy_ZX_plane(int fd,vtkImageData *newImage,int slice,int iWidth,int dimX,int dimY,int dimZ,int dataSize)
 {
        long long int j;
        long long       ret;
@@ -452,12 +621,25 @@ void ReadMHDPlane::Process()
 {
        if (bbGetInputType()==0)
        {
-               ReadNormalMHD();
+               //-- Split FileName
+               std::string inputfilename;
+               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()=="XY") { inputfilename = bbGetInputFileName();           } // if XY
+               if (bbGetInputDirectionPlane()=="YZ") { inputfilename = path+filename+"_YZ.mhd";        } // if YZ
+               if (bbGetInputDirectionPlane()=="ZX") { inputfilename = path+filename+"_ZX.mhd";        } // if XZ
+               Read64lseek( inputfilename ,"XY");
        }       
 
        if (bbGetInputType()==1)
        {
-               Read64lseek();
+               Read64lseek( bbGetInputFileName(), bbGetInputDirectionPlane() );
        }       
 
 }
index 5b94b9554b7586236ab678af29d5c49b70c81815..fb0080ac157b19c9d12d5223c0ab0fc8dbce98fc 100644 (file)
@@ -33,13 +33,16 @@ class bbcreaVtk_EXPORT ReadMHDPlane
   BBTK_DECLARE_INPUT(DirectionPlane,std::string);
   BBTK_DECLARE_INPUT(Type,int);
   BBTK_DECLARE_OUTPUT(Out,vtkImageData*); 
+  BBTK_DECLARE_OUTPUT(Out2,vtkImageData*); 
   BBTK_PROCESS(Process);
        
   vtkImageData* CreateDefaultImage();
-  void ReadNormalMHD();
-  void Read64lseek();
-  void copy_XZ_plane(int fd,vtkImageData *newImage,int slice,int iWidth,int dimX,int dimY,int dimZ,int dataSize);
+// EED Borrame  void ReadNormalMHD();
+// EED Borrame  void Read64lseek();
+  void Read64lseek(std::string,std::string plane);
+  void copy_ZX_plane(int fd,vtkImageData *newImage,int slice,int iWidth,int dimX,int dimY,int dimZ,int dataSize);
   void copy_YZ_plane(int fd,vtkImageData *newImage,int slice,int iWidth,int dimX,int dimY,int dimZ,int dataSize);
+  vtkImageData* ChangeOrientation(vtkImageData* img);
 
 
   void Process();
@@ -59,6 +62,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ReadMHDPlane,bbtk::AtomicBlackBox);
  BBTK_INPUT(ReadMHDPlane,DirectionPlane,"Direction plane: XY (default), YZ , XZ",std::string,"");
  BBTK_INPUT(ReadMHDPlane,Type,"(1 default) 0 = Normal mhd,  1 = lseek64",int,"");
  BBTK_OUTPUT(ReadMHDPlane,Out,"Image 2D",vtkImageData*,"");
+ BBTK_OUTPUT(ReadMHDPlane,Out2,"Image 2D in the good orientation",vtkImageData*,"");
 BBTK_END_DESCRIBE_BLACK_BOX(ReadMHDPlane);
 //===== 
 // 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)