From: Eduardo DAVILA Date: Mon, 2 May 2016 08:40:13 +0000 (+0200) Subject: #2711 creaVtk Feature New Normal - new Box ReadMHDPlane X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=510a35c78a4b9fbc75f98f286aedac1b640904b4;p=creaVtk.git #2711 creaVtk Feature New Normal - new Box ReadMHDPlane --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx index b842e8d..f7a1d10 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx @@ -32,6 +32,34 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ReadMHDPlane,bbtk::AtomicBlackBox); // 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) //===== + +vtkImageData* ReadMHDPlane::CreateDefaultImage() +{ + int i; + int sizeX, sizeY, sizeZ; + sizeX = 200; + sizeY = sizeX; + sizeZ = 1; + vtkImageData *newImage = vtkImageData::New(); + newImage->Initialize(); + newImage->SetScalarTypeToUnsignedChar(); + newImage->SetSpacing( 1,1,1 ); + newImage->SetDimensions( sizeX,sizeY,sizeZ ); + newImage->SetWholeExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 ); + newImage->SetExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 ); + newImage->SetNumberOfScalarComponents(1); + newImage->AllocateScalars(); + newImage->Update(); + memset ( (void*)newImage->GetScalarPointer(), 0, sizeX*sizeY*1 ); + for (i=0; iSetScalarComponentFromDouble(i,i,0, 0, 255 ); + newImage->SetScalarComponentFromDouble(i,sizeY-1-i,0, 0, 255 ); + } // for i + return newImage; +} + + void ReadMHDPlane::ReadNormalMHD() { // THE MAIN PROCESSING METHOD BODY @@ -138,27 +166,7 @@ void ReadMHDPlane::ReadNormalMHD() if (ok==false) { - int i; - int sizeX, sizeY, sizeZ; - sizeX = 200; - sizeY = sizeX; - sizeZ = 1; - newImage = vtkImageData::New(); - newImage->Initialize(); - newImage->SetScalarTypeToUnsignedChar(); - newImage->SetSpacing( 1,1,1 ); - newImage->SetDimensions( sizeX,sizeY,sizeZ ); - newImage->SetWholeExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 ); - newImage->SetExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 ); - newImage->SetNumberOfScalarComponents(1); - newImage->AllocateScalars(); - newImage->Update(); - memset ( (void*)newImage->GetScalarPointer(), 0, sizeX*sizeY*1 ); - for (i=0; iSetScalarComponentFromDouble(i,i,0, 0, 255 ); - newImage->SetScalarComponentFromDouble(i,sizeY-1-i,0, 0, 255 ); - } // for i + newImage=CreateDefaultImage(); } // if ok bbSetOutputOut( newImage ); @@ -176,7 +184,7 @@ void ReadMHDPlane::Read64lseek() float ox=-1,oy=-1,oz=-1; long int headersize=0; - vtkImageData *newImage; + vtkImageData *newImage=NULL; char mystring[250]; char strTmp[30]; @@ -184,8 +192,6 @@ void ReadMHDPlane::Read64lseek() FILE *ffIn = fopen(bbGetInputFileName().c_str(),"r"); long long dataSize; - - if (ffIn!=NULL) { newImage = vtkImageData::New(); @@ -348,18 +354,17 @@ void ReadMHDPlane::Read64lseek() } } } // for j - } // if PLANE YZ - - + } // if PLANE YZ #if defined(_WIN32) _close (fd); #else close (fd); #endif // defined(_WIN32) + } else { + newImage=CreateDefaultImage(); + } // if ffIn - bbSetOutputOut( newImage ); - } // if - + bbSetOutputOut( newImage ); } diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.h b/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.h index 8dfd228..33a96eb 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.h @@ -34,6 +34,7 @@ class bbcreaVtk_EXPORT ReadMHDPlane BBTK_DECLARE_OUTPUT(Out,vtkImageData*); BBTK_PROCESS(Process); + vtkImageData* CreateDefaultImage(); void ReadNormalMHD(); void Read64lseek();