]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOGimmickView.cpp
#3111 creaImageIO Bug New Normal - branch vtk7itk4 compilation with vtk7
[creaImageIO.git] / src / creaImageIOGimmickView.cpp
index 245b0b563c829ad96d34abb6fd28bfce268a37d6..c9965637106f259cf1e00d943f5508248b711077 100644 (file)
@@ -376,11 +376,14 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                        // n*2D to 3D
                        vtkImageData* out = vtkImageData::New();
 //                     out->CopyStructure(first);      
-                       out->SetScalarType(first->GetScalarType());
-                       out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
                        int ext[6];
                        //first->GetExtent(ext);  // JPR
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                        first->GetWholeExtent(ext);  // renvoie egalement 0,0 en Z // JPR
+#else
+                       first->GetExtent(ext);  // renvoie egalement 0,0 en Z // JPR
+#endif
 
                        if(ext[5] == 0)
                        {
@@ -396,10 +399,17 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
 
                        int dim[3];
                        first->GetDimensions(dim);
-
                        out->SetDimensions(dim[0], dim[1], (int)im.size() );
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+                       out->SetScalarType(first->GetScalarType());
+                       out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
                        out->AllocateScalars();
                        out->Update();
+#else
+                       out->AllocateScalars(first->GetScalarType(),first->GetNumberOfScalarComponents());
+#endif
 
                        unsigned long imsize = dim[0] * dim[1];
                        imsize = imsize * dim[2] ;  // deal with multiframes // JPR
@@ -486,20 +496,37 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
        void GimmickView::readImages1(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
                         OutputAttr i_attr)
        {
+
+               i_attr.outside.push_back("D0019_100a");  // simens Number Of Images In Mosaic
+
+//EED Borrame
+               int i,isize=i_attr.outside.size();
+               for (i=0;i<isize;i++)
+               {
+               printf("EED GimmickView::readImages1 A  i_attr out %s \n", i_attr.outside[i].c_str());
+               }
+
+
+
                std::vector<std::string>::iterator it;
                for (it=im.begin(); it!=im.end(); ++it)
                {
                        OutStrGimmick out;
                        out.img = vtkImageData::New();
                        out.img->ShallowCopy(mReader.GetImage(*it));
-                       if(i_attr.mult)
+printf("EED GimmickView::readImages1 A\n ");
+                       if(i_attr.mult) 
+                       {
                                getAttributes((*it),out.infos,i_attr);
+printf("EED GimmickView::readImages1 B   %s \n ", out.infos.find("D0019_100a")->second.c_str() );                              
+                       }
                        o_output.push_back(out);
                }
                // If we want only one output information structure, we set it outside the loop
                if(!i_attr.mult)
                {
                        getAttributes(im.front(), o_output.front().infos, i_attr);
+printf("EED GimmickView::readImages1 C   %s \n ", o_output.front().infos.find("D0019_100a")->second.c_str() );
                }
                
        }
@@ -513,16 +540,17 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                OutStrGimmick out;
                vtkImageData* first = mReader.GetImage( im.front());
                out.img  = vtkImageData::New();
-               out.img->SetScalarType(first->GetScalarType());
-               out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
                int ext[6];
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                first->GetWholeExtent(ext);  // send also 0,0 in Z 
+#else
+               first->GetExtent(ext);  // send also 0,0 in Z 
+#endif
                if(ext[5] == 0)
                {
                        ext[5] = (int)im.size()-1;
-               }
-               else
-               {
+               } else {
                        ext[5] = ext[5] * (int)im.size()-1; // to deal with multiframes 
                }
                out.img->SetExtent(ext);
@@ -532,8 +560,20 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                first->GetSpacing(spac);
                out.img->SetSpacing(spac);
                out.img->SetDimensions(dim[0], dim[1], (int)im.size() );
+
+
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               out.img->SetScalarType(first->GetScalarType());
+               out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
                out.img->AllocateScalars();
                out.img->Update();
+#else
+               out.img->AllocateScalars(first->GetScalarType(), first->GetNumberOfScalarComponents());
+#endif
+
+
                unsigned long imsize = dim[0] * dim[1];
                imsize = imsize * dim[2] ;  // deal with multiframes here
                // differents formats char , short, etc...
@@ -582,17 +622,29 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                        {
                                OutStrGimmick out;
                                out.img = vtkImageData::New();
-                               out.img->SetScalarType(first->GetScalarType());
                                out.img->SetSpacing(spac);
-                               out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
                                int ext[6];
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                                first->GetWholeExtent(ext);  // send also 0,0 in Z 
+#else
+                               first->GetExtent(ext);  // send also 0,0 in Z 
+#endif
                                ext[5] = 0;
                                out.img->SetExtent(ext);
-
                                out.img->SetDimensions(dim[0], dim[1], 1 );
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+                               out.img->SetScalarType(first->GetScalarType());
+                               out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
                                out.img->AllocateScalars();
                                out.img->Update();
+#else
+                               out.img->AllocateScalars(first->GetScalarType(),first->GetNumberOfScalarComponents());
+#endif
+
+
                                memcpy(out.img->GetScalarPointer(0,0,0), cur->GetScalarPointer(0,0,slice), imsize);
                                o_output.push_back(out);
                        }
@@ -622,19 +674,33 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                {
                        OutStrGimmick out;
                        out.img = vtkImageData::New();
-                       out.img->SetScalarType(first->GetScalarType());
-                       out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
                        
                        int ext[6];
-                       double spac[6];
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                        first->GetWholeExtent(ext);  // send also 0,0 in Z 
+#else
+                       first->GetExtent(ext);  // send also 0,0 in Z 
+#endif
+
+                       double spac[6];
                        ext[5] = 0;
                        out.img->SetExtent(ext);
                        first->GetSpacing(spac);
                        out.img->SetSpacing(spac);
                        out.img->SetDimensions(dim[0], dim[1], (int)im.size() );
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+                       out.img->SetScalarType(first->GetScalarType());
+                       out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
                        out.img->AllocateScalars();
                        out.img->Update();
+#else
+                       out.img->AllocateScalars(first->GetScalarType(), first->GetNumberOfScalarComponents());
+#endif
+
                        unsigned long imsize = dim[0] * dim[1];
                        imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
                        int index = 0;
@@ -665,24 +731,17 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                if ( size == 0)
                {
                        return;
-               }
-               else if (size == 1)
-               {
+               } else if (size == 1) {
                        // Simplest case
                        // Only one image : give it
                        // But take in count multiframe possibility
                        if ( isSingle(im.front()) || i_dim != 1)
                        {
                                 readImages1(o_output,im, i_attr);
-                       }
-                       else
-                       {
-                               readImages2(o_output,im, i_attr,i_zspc);
-                       }
-                       
-               }
-               else
-               {
+                       } else {
+                                readImages2(o_output,im, i_attr,i_zspc);
+                       }                       
+               } else {
                        // multiple or single frame
                        if ( isSingle(im.front()) )
                        {
@@ -691,40 +750,33 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                                {
                                        // 2D to 3D
                                        readImages3(o_output,im, i_attr,i_zspc);
-                               }
-                               else
-                               {
+                               } else {
                                        readImages1(o_output,im, i_attr);
                                }
-                       }
-                       else
-                       {
+                       } else {
                                // we deal with multiple frames n x (2D x T)
                                // Differents outputs are avaialable
                                if(i_dim == 1)
                                {
                                        // put all in one output
                                        readImages3(o_output,im, i_attr,i_zspc);
-
-                               }
-                               else if( i_dim == 2)
-                               {
+                               } else if( i_dim == 2) {
                                        // put in a vector of n x T (2D)
                                        readImages2(o_output,im, i_attr,i_zspc);
-                               }
-                               else if( i_dim == 3)
-                               {
+                               } else if( i_dim == 3) {
                                        // put in a vector of n (2D x T)
                                        // No transformations.
                                        readImages1(o_output,im, i_attr);
-                               }
-                               else
-                               {
+                               } else {
                                        // put in a vector of T (2D x n)
                                        readImages4(o_output,im, i_attr);
-                               }
-                       }
-               }
+                               } // i_dim
+                       } //isSingle(im.front())
+               } // if size
+
+//EED UnMosaic step...  
+//How to verifie if is a mosaic file , with how many images inside??
+
        }
 
 
@@ -745,7 +797,7 @@ void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, s
        else if (im.size()>1) // Test inutile ? JPR
        {
                /// \TODO fix unused variable 'first'
-               vtkImageData* first = mReader.GetImage( im.front());
+//             vtkImageData* first = mReader.GetImage( im.front());
                if (dimension == 2)
                {
                 // n3D
@@ -755,10 +807,8 @@ void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, s
                                vtkImageData* out = vtkImageData::New();
                                out->ShallowCopy(mReader.GetImage(*it));
                                s.push_back(out);
-                       }
-               }
-               else
-               {
+                       } // for
+               } else {
                        // n2D to 3D // NO!
                        // n *2D + T in a vector :
                        
@@ -767,9 +817,9 @@ void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, s
                        {
                                vtkImageData* out = mReader.GetImage( (*it));
                                s.push_back(out);
-                       }
-               }
-       }
+                       } // for
+               } // if dimension
+       } // if im.size
 }
   //======================================================================
 
@@ -900,8 +950,9 @@ void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
                
                // We need a gdcm::FileHelper, since we want to load the pixels        
                GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(file);
-       
-   uint8_t *imageData = fh->GetImageData();
+
+//Borrame
+//EED   uint8_t *imageData = fh->GetImageData();
 
           // Institution name 
           file->AddAnonymizeElement(0x0008, 0x0080, "*"); 
@@ -925,7 +976,7 @@ void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
           fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
    
           fh->WriteDcmExplVR(file->GetFileName() +".ano1" );
-          std::cout << i <<"  End Anonymize" << std::cout;  
+          std::cout << i <<"  End Anonymize" << std::endl;  
           file->ClearAnonymizeList();
           file->Delete();
           fh->Delete();