]> Creatis software - bbtk.git/blobdiff - packages/vtk/src/bbvtkConcatImages.cxx
#3107 BBTK Bug New Normal - branch vtk7itk4 compilation with vtk7
[bbtk.git] / packages / vtk / src / bbvtkConcatImages.cxx
index 1367ec761bf1ad6fa23e6274539ac27d1cfde41c..cac0843f01cb91aa90a33871e55978adfb3ec9fc 100644 (file)
@@ -89,17 +89,17 @@ namespace bbvtk
  ///  - supposes *all* the images are consistent (same type, same number of components, same pixel type)
  ///  - if images in the vector are already 3D, exports only the first one. ?!?  // JPR
  ///
-   void ConcatImages::Process()
-   {
-        int dim[3];
-        int curDim[3];
+void ConcatImages::Process()
+{
+       int dim[3];
+       int curDim[3];
        int nbComponents;
        int scalarType;
        int nb = (unsigned int)bbGetInputIn().size();
 //     int consistentNb(nb);
        int newSizeZ;
 
-        if (nb == 0) {
+    if (nb == 0) {
           // ??? JPR
        } 
        
@@ -111,40 +111,36 @@ namespace bbvtk
           mConcat = bbGetInputIn()[0];
           //mConcat->PrintSelf(std::cout, vtkIndent(2));
        } else {
-          // We suppose *all* the images within the directory are consistent (same sizeS, same pixel Type?...)
-          vtkImageData * firstImage = bbGetInputIn()[0];
+               // We suppose *all* the images within the directory are consistent (same sizeS, same pixel Type?...)
+               vtkImageData * firstImage = bbGetInputIn()[0];
           
-                 //std::cout << "--------PrintSelf firstImage " << std::endl;
-                 // firstImage->PrintSelf(std::cout, vtkIndent(2));       
+               //std::cout << "--------PrintSelf firstImage " << std::endl;
+               // firstImage->PrintSelf(std::cout, vtkIndent(2));         
           
-           nbComponents = firstImage->GetNumberOfScalarComponents();
-           mConcat->SetNumberOfScalarComponents(nbComponents);
-          
-          mConcat->SetScalarType(firstImage->GetScalarType( ));
-          scalarType = firstImage->GetScalarType( );
-          mConcat->SetScalarType(scalarType);
+               nbComponents = firstImage->GetNumberOfScalarComponents();
+               scalarType = firstImage->GetScalarType( );
           
-          mConcat->SetSpacing(firstImage->GetSpacing());
+               mConcat->SetSpacing(firstImage->GetSpacing());
           
-          firstImage->GetDimensions(dim);
-          newSizeZ=0;
-          // brute way to perform an ultra-mini consistency check :
-          // First image is supposed to be the reference image,
-          // any unconsistent image is just discarted...
-          for(int i=0; i<nb; i++)
-          {
+               firstImage->GetDimensions(dim);
+               newSizeZ=0;
+               // brute way to perform an ultra-mini consistency check :
+               // First image is supposed to be the reference image,
+               // any unconsistent image is just discarted...
+               for(int i=0; i<nb; i++)
+               {
 
 //EED 2013 oct 29 
 //EED        if ( !CheckConsistency(firstImage, dim, nbComponents, scalarType))
 //EED          consistentNb--;
 
              if ( CheckConsistency(bbGetInputIn()[i], dim, nbComponents, scalarType))
-               {
-                       bbGetInputIn()[i]->GetDimensions(curDim);
-                       newSizeZ = newSizeZ + curDim[2];
-               } // if
+                       {
+                               bbGetInputIn()[i]->GetDimensions(curDim);
+                               newSizeZ = newSizeZ + curDim[2];
+                       } // if
                
-          }    // for
+               }    // for
 
           dim[2]=newSizeZ;
 
@@ -152,8 +148,17 @@ namespace bbvtk
           mConcat->SetDimensions(dim);
           mConcat->SetExtent(0, dim[0]-1, 0, dim[1]-1, 0, dim[2]-1);
                   
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
+       mConcat->SetNumberOfScalarComponents(nbComponents);
+          mConcat->SetScalarType(scalarType);
           mConcat->AllocateScalars();
           mConcat->Update();      
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+          mConcat->AllocateScalars(scalarType,nbComponents);
+#endif
                     
           int index_image;
 
@@ -195,8 +200,9 @@ namespace bbvtk
 
    // Devrait etre dans bbUserFinalizeProcessing() ? On n'y entre jamais // JPR        
    bbSetOutputOut(mConcat);    
-   }              
+}                 
 
+//---------------------------------------------------
 bool ConcatImages::CheckConsistency( vtkImageData *curImage, int dim[], int nbComponents, int scalarType )
 {
    assert (curImage);