]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOGimmickView.cpp
#3264 creaImageIO Feature New Normal - Add Dicom Tags to the DB sqlite
[creaImageIO.git] / src / creaImageIOGimmickView.cpp
index 672f9224b9874b4a8297f9904bb023f2fd331ad9..2ff7855fdb30222137cfbde27148fe8bba39f624 100644 (file)
 #include <gdcmFileHelper.h>
 #include <gdcmUtil.h>
 #include <vtkGdcmReader.h>
+
 #endif
 
+#include <vtkMetaImageWriter.h>
+
 /*#if defined(USE_GDCM2)
 #include <vtkGDCMImageReader.h>
 #include "gdcmSystem.h"
@@ -140,6 +143,7 @@ namespace creaImageIO
   /// Finalize 
   void GimmickView::Finalize()
   {
+         printf("EED GimmickView::Finalize  \n");
   }
 
   //======================================================================
@@ -376,11 +380,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 +403,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
@@ -450,8 +464,10 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
        //////////////////////////////////////////////////////////
        bool GimmickView::isSingle(const std::string i_file)
        {
+printf("EED GimmickView::isSingle Start %s\n" , i_file.c_str() );
                bool bres = true;
                vtkImageData* first = mReader.GetImage( i_file);
+printf("EED GimmickView::isSingle 1\n"  );
                int dim[3];
                first->GetDimensions(dim);
                if (dim[2] > 1)
@@ -461,6 +477,8 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                else
                {
                }
+printf("EED GimmickView::isSingle end\n");
+
                return bres;
        }
 
@@ -486,9 +504,7 @@ 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
-
                std::vector<std::string>::iterator it;
                for (it=im.begin(); it!=im.end(); ++it)
                {
@@ -516,12 +532,15 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                         OutputAttr i_attr, double i_zspc)
        {
                OutStrGimmick out;
-               vtkImageData* first = mReader.GetImage( im.front());
+               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;
@@ -535,8 +554,19 @@ 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...
@@ -546,12 +576,14 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                //!!!!out.img->SetSpacing(i_zspc);
                int slice = 0;
                std::vector<std::string>::iterator it;
+               
                for (it=im.begin(); it!=im.end(); ++it) 
                {
                        vtkImageData* cur = mReader.GetImage( (*it) );
                        memcpy(out.img->GetScalarPointer(0,0,slice), cur->GetScalarPointer(0,0,0), imsize);
                        slice++;
-               }       
+               } // for it     
+               
                getAttributes(im.front(),out.infos, i_attr);
                o_output.push_back(out);
        }
@@ -585,17 +617,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);
                        }
@@ -625,19 +669,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;
@@ -713,7 +771,6 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
 
 //EED UnMosaic step...  
 //How to verifie if is a mosaic file , with how many images inside??
-
        }