]> Creatis software - creaVtk.git/commitdiff
#2711 creaVtk Feature New Normal - new Box ReadMHDPlane
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 2 May 2016 08:40:13 +0000 (10:40 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 2 May 2016 08:40:13 +0000 (10:40 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.h

index b842e8dca42f643bc2cdfdd9d4deae1fc212e86d..f7a1d106928f6fd5d8cf0231025acda495676914 100644 (file)
@@ -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; i<sizeX; i++)
+       {
+               newImage->SetScalarComponentFromDouble(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; i<sizeX; i++)
-               {
-                       newImage->SetScalarComponentFromDouble(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 );
 
 }
 
index 8dfd228a0f42e86dcb0f7072b83bf54c009f1d00..33a96eb9540be0bbab6dde018b8b79b42ebc43cd 100644 (file)
@@ -34,6 +34,7 @@ class bbcreaVtk_EXPORT ReadMHDPlane
   BBTK_DECLARE_OUTPUT(Out,vtkImageData*); 
   BBTK_PROCESS(Process);
        
+  vtkImageData* CreateDefaultImage();
   void ReadNormalMHD();
   void Read64lseek();