]> Creatis software - creaVtk.git/commitdiff
#3061 creaVtk Bug New Immediate - ReadMHDPlane box not reading MET_INT types files
authorEduardo DAVILA <davila@localhost.localdomain>
Tue, 31 Jan 2017 20:45:29 +0000 (21:45 +0100)
committerEduardo DAVILA <davila@localhost.localdomain>
Tue, 31 Jan 2017 20:45:29 +0000 (21:45 +0100)
bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx

index f17bc9d78508517d268af61637717001ccb5cb8d..223fe7e590c57219a95c349e9aca5c81ef77469e 100644 (file)
@@ -80,6 +80,8 @@ void ReadMHDPlane::ReadNormalMHD()
        std::string inputfilename;
        int slice;
        int width;
+       long long dataSize;
+
 
        if (bbGetInputDirectionPlane()=="XY")
        {
@@ -89,7 +91,6 @@ void ReadMHDPlane::ReadNormalMHD()
 
        if ((bbGetInputDirectionPlane()=="YZ") || (bbGetInputDirectionPlane()=="ZX"))
        {
-
                //-- Split FileName
                std::size_t found               =       bbGetInputFileName().find_last_of("/\\");
                std::string path                =       bbGetInputFileName().substr(0,found+1);
@@ -99,8 +100,6 @@ void ReadMHDPlane::ReadNormalMHD()
 #else
                path=path+"YZ_ZX/";
 #endif
-       
-       
                if (bbGetInputDirectionPlane()=="YZ") 
                { 
                        inputfilename = path+filename+"_YZ.mhd";  
@@ -118,9 +117,8 @@ void ReadMHDPlane::ReadNormalMHD()
        slice = bbGetInputSlice();
        if (slice<0 ) { slice=0; }
 
-
        vtkImageData *newImage;
-       long long int newHeaderSize;
+       long long newHeaderSize;
     std::string newFileName=inputfilename+"-OneSlice";
 
     int sx,sy,sz;
@@ -159,12 +157,26 @@ void ReadMHDPlane::ReadNormalMHD()
                        newHeaderSize = (long long int)sx*(long long int)sy*(long long int)slice;
                                if (bbGetInputSlice()>=sz) {ok=false;}
                        } // if
-               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_SHORT",mystring,23)==0)  { newHeaderSize=newHeaderSize*2; }
-               if (strncmp("ElementType = MET_FLOAT",mystring,23)==0)  { newHeaderSize=newHeaderSize*4; }
-               if (strncmp("ElementType = VTK_FLOAT",mystring,23)==0)  { newHeaderSize=newHeaderSize*4; }
+               if (strncmp("ElementType = MET_CHAR",mystring,22)==0)                   { dataSize=sizeof(char);                        }
+               if (strncmp("ElementType = VTK_CHAR",mystring,22)==0)                   { dataSize=sizeof(char);                        }
+               if (strncmp("ElementType = MET_UCHAR",mystring,23)==0)                  { dataSize=sizeof(unsigned char);       }
+               if (strncmp("ElementType = VTK_UNSIGNED_CHAR",mystring,31)==0)  { dataSize=sizeof(unsigned char);       }
+               if (strncmp("ElementType = MET_USHORT",mystring,24)==0)                 { dataSize=sizeof(unsigned short);      }
+               if (strncmp("ElementType = VTK_UNSIGNED_SHORT",mystring,32)==0) { dataSize=sizeof(unsigned short);      }
+               if (strncmp("ElementType = MET_SHORT",mystring,23)==0)                  { dataSize=sizeof(short);                       }
+               if (strncmp("ElementType = VTK_SHORT",mystring,23)==0)                  { dataSize=sizeof(short);                       }
+               if (strncmp("ElementType = MET_UINT",mystring,22)==0)                   { dataSize=sizeof(unsigned int);        }
+               if (strncmp("ElementType = VTK_UNSIGNED_INT",mystring,30)==0)   { dataSize=sizeof(unsigned int);        }
+               if (strncmp("ElementType = MET_INT",mystring,21)==0)                    { dataSize=sizeof(int);                         }
+               if (strncmp("ElementType = VTK_INT",mystring,21)==0)                    { dataSize=sizeof(int);                         }
+               if (strncmp("ElementType = MET_FLOAT",mystring,23)==0)                  { dataSize=sizeof(float);                       }
+               if (strncmp("ElementType = VTK_FLOAT",mystring,23)==0)                  { dataSize=sizeof(float);                       }
+               if (strncmp("ElementType = MET_LONG",mystring,22)==0)                   { dataSize=sizeof(long);                        }
+               if (strncmp("ElementType = VTK_LONG",mystring,22)==0)                   { dataSize=sizeof(long);                        }
+               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) 
@@ -252,14 +264,14 @@ void ReadMHDPlane::Read64lseek()
                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,24)==0)                   { newImage->SetScalarTypeToUnsignedInt();       dataSize=sizeof(unsigned int);  }
-               if (strncmp("ElementType = VTK_UNSIGNED_INT",mystring,32)==0)   { newImage->SetScalarTypeToUnsignedInt();       dataSize=sizeof(unsigned int);  }
-               if (strncmp("ElementType = MET_INT",mystring,24)==0)                    { newImage->SetScalarTypeToInt();                       dataSize=sizeof(int);                   }
-               if (strncmp("ElementType = VTK_INT",mystring,32)==0)                    { newImage->SetScalarTypeToInt();                       dataSize=sizeof(int);                   }
+               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,23)==0)                   { newImage->SetScalarTypeToLong();                      dataSize=sizeof(long);                  }
-               if (strncmp("ElementType = VTK_LONG",mystring,23)==0)                   { newImage->SetScalarTypeToLong();                      dataSize=sizeof(long);                  }
+               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);                }