]> Creatis software - bbtk.git/blobdiff - packages/vtk/src/bbvtkCreateImage.cxx
#3212 BBTK Feature New Normal - vtk8itk4wx3-mingw64
[bbtk.git] / packages / vtk / src / bbvtkCreateImage.cxx
index cb9d77bf0d920e156f4de703db005274e643e7f3..007c34718cc779e17897a44f3ddd81ec35f4dddc 100644 (file)
@@ -53,7 +53,7 @@ void CreateImage::Process()
 //    * TYPE is the C++ type of the input/output
 //      (the one provided in the attribute 'type' of the tag 'input')
 
-       double  spc[6];
+       double  spc[3];
        int             dim[3]; 
        int             outputformat = VTK_UNSIGNED_SHORT;
        
@@ -80,15 +80,30 @@ void CreateImage::Process()
        else if (bbGetInputOutputFormat()=="VTK_DOUBLE")                        outputformat = VTK_DOUBLE;              // 11           
        else if (bbGetInputOutputFormat()=="MET_DOUBLE")                        outputformat = VTK_DOUBLE;              // 11  
 
-
        spc[0] = bbGetInputSpacing()[0];
        spc[1] = bbGetInputSpacing()[1];
        spc[2] = bbGetInputSpacing()[2];
-       
        dim[0] =  bbGetInputDimensions()[0];
        dim[1] =  bbGetInputDimensions()[1];
        dim[2] =  bbGetInputDimensions()[2];
-       
+       if ((dim[0]<=0)||(dim[1]<=0)||(dim[2]<=0))
+       {
+               dim[0]=1;
+               dim[1]=1;
+               dim[2]=1;
+       }
+       if ((spc[0]<=0)||(spc[1]<=0)||(spc[2]<=0))
+       {
+               spc[0]=1;
+               spc[1]=1;
+               spc[2]=1;
+       }
+//EED 2017-12-7
+       if (imageoutput!=NULL) 
+       {
+               imageoutput->Delete();
+       }       
+       imageoutput = vtkImageData::New();
        imageoutput->Initialize();
        imageoutput->SetSpacing( spc );
        imageoutput->SetDimensions(  dim[0], dim[1], dim[2] );
@@ -102,7 +117,6 @@ void CreateImage::Process()
        imageoutput->AllocateScalars( outputformat,1 );
 #endif
        
-
        int i,j,k;
        long sizeBlock; 
 
@@ -122,7 +136,7 @@ void CreateImage::Process()
        {
                memcpy(  imageoutput->GetScalarPointer(0,0,k) ,imageoutput->GetScalarPointer()  , sizeBlock );
        } // for k
-
+       
 
 //EED 2017-01-01 Migration VTK7
 #if (VTK_MAJOR_VERSION <= 5) 
@@ -170,7 +184,7 @@ void CreateImage::bbUserInitializeProcessing()
 //    but this is where you should allocate the internal/output pointers 
 //    if any 
 
-       imageoutput = vtkImageData::New();
+//EED 2017-12-7        imageoutput = vtkImageData::New();
 
 }