X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk_creaVtk_PKG%2Fsrc%2FbbcreaVtkReadMHDPlane.cxx;h=58486f2bbfa4cbcb6a0712d47dcb02209348bbc9;hb=b5336cb50d214351673b863554714c5b2fa728a1;hp=d6818392ee6566160afc72b6f71da87257fe5e43;hpb=4b79238a4a0c468f952d781f7cf7c3c2bb95029f;p=creaVtk.git diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx index d681839..58486f2 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx @@ -136,7 +136,8 @@ void ReadMHDPlane::ReadNormalMHD() { strcpy(mystring,"\n"); fgets(mystring,250,ffIn); - if (strncmp("NDims",mystring,5)==0) { + if (strncmp("NDims",mystring,5)==0) + { if (width==1) { strcpy(mystring,"NDims = 2\n"); @@ -224,6 +225,7 @@ void ReadMHDPlane::Read64lseek() char strTmp[30]; char strTmp2[30]; FILE *ffIn = fopen(bbGetInputFileName().c_str(),"r"); +printf("EED ReadMHDPlane::Read64lseek filename %s %p\n", bbGetInputFileName().c_str(), ffIn ); long long dataSize; if (ffIn!=NULL) @@ -237,7 +239,8 @@ void ReadMHDPlane::Read64lseek() 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,11)==0) { sscanf(mystring,"%s %s %f %f %f" ,strTmp, strTmp, &spcX,&spcY,&spcZ); } + 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; } @@ -250,8 +253,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_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_DOUBLE",mystring,24)==0) { newImage->SetScalarTypeToDouble(); dataSize=sizeof(double); } if (strncmp("ElementType = VTK_DOUBLE",mystring,24)==0) { newImage->SetScalarTypeToDouble(); dataSize=sizeof(double); } @@ -279,15 +288,16 @@ void ReadMHDPlane::Read64lseek() #endif // defined(_WIN32) - if (fd < 0) { - printf("EED ReadMHDPlane::Read64lseek \n"); + printf("EED ReadMHDPlane::Read64lseek WARNNING! raw file not exist\n"); fprintf(stderr, "%s\n", strerror(errno)); - exit(1); - } + newImage=CreateDefaultImage(); +// exit(1); + } + - if (bbGetInputDirectionPlane()=="XY") + if ((bbGetInputDirectionPlane()=="XY") && (fd>=0)) { newImage->SetSpacing( spcX,spcY,spcZ ); newImage->SetDimensions( dimX,dimY,width ); @@ -315,7 +325,7 @@ void ReadMHDPlane::Read64lseek() } } // if PLANE XY - if (bbGetInputDirectionPlane()=="XZ") + if ((bbGetInputDirectionPlane()=="XZ") && (fd>=0)) { newImage->SetSpacing( spcX,spcZ,spcY ); newImage->SetDimensions( dimX,dimZ,width ); @@ -331,8 +341,7 @@ void ReadMHDPlane::Read64lseek() } } // if PLANE XZ - - if (bbGetInputDirectionPlane()=="YZ") + if ((bbGetInputDirectionPlane()=="YZ") && (fd>=0)) { newImage->SetSpacing( spcY,spcZ,spcX ); newImage->SetDimensions( dimY,dimZ,width ); @@ -385,7 +394,7 @@ void ReadMHDPlane::copy_YZ_plane(int fd,vtkImageData *newImage,int slice,int iWi exit(1); } - pImage=(char*)(newImage->GetScalarPointer(i, j,iWidth )); + pImage=(char*)(newImage->GetScalarPointer(i, dimZ-1-j,iWidth )); if ((ret = read(fd, pImage , dataSize)) < 0) { fprintf(stderr, "Failed reading: %s\n", strerror(errno)); @@ -404,7 +413,7 @@ void ReadMHDPlane::copy_XZ_plane(int fd,vtkImageData *newImage,int slice,int iWi pos = dimX*(long long int)slice*dataSize; long long sizeBytesPlane = dimX*dimY*dataSize; char *pImage = (char*)( newImage->GetScalarPointer(0,0,iWidth) ); - for (j=0;j=0;j--) { #if defined(_WIN32) if (_lseeki64( fd, pos + j*sizeBytesPlane , SEEK_SET ) < 0)