]> Creatis software - creaImageIO.git/commitdiff
#3111 creaImageIO Bug New Normal - branch vtk7itk4 compilation with vtk7 vtk7itk4
authorEduardo DAVILA <davila@localhost.localdomain>
Fri, 4 Aug 2017 14:28:10 +0000 (16:28 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Fri, 4 Aug 2017 14:28:10 +0000 (16:28 +0200)
src/creaImageIOGimmickView.cpp
src/creaImageIOImageReader.cpp
src/creaImageIOMultiThreadImageReader.cpp
src/creaImageIOUnMosaicVtkImageData.cpp
src/creaImageIOWxAnySimpleDlg.h
src/creaImageIOWxSimpleDlg.cpp
src/creaImageIOWxViewer.cpp

index 4ada3a9c54277a33230e0bee464de9bc514f3f3f..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
@@ -530,10 +540,13 @@ printf("EED GimmickView::readImages1 C   %s \n ", o_output.front().infos.find("D
                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;
@@ -547,8 +560,20 @@ printf("EED GimmickView::readImages1 C   %s \n ", o_output.front().infos.find("D
                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...
@@ -597,17 +622,29 @@ printf("EED GimmickView::readImages1 C   %s \n ", o_output.front().infos.find("D
                        {
                                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);
                        }
@@ -637,19 +674,33 @@ printf("EED GimmickView::readImages1 C   %s \n ", o_output.front().infos.find("D
                {
                        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;
index 4220fb1f85c7371f809f015b087c49b1e2b7f005..cdb6cb568c15a3cce4174f2b5522fa94f936d1b7 100644 (file)
@@ -78,8 +78,15 @@ namespace creaImageIO
     dim[0] = dim[1] = 128; 
     dim[2] = 1; 
     mUnreadableImage->SetDimensions ( dim );
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
     mUnreadableImage->SetScalarTypeToUnsignedChar();
-    mUnreadableImage->AllocateScalars();    
+    mUnreadableImage->AllocateScalars();   
+#else
+    mUnreadableImage->AllocateScalars(VTK_UNSIGNED_CHAR,1);
+#endif
     for (int i=0;i<dim[0];i++) 
       for (int j=0;j<dim[1];j++) 
        mUnreadableImage->SetScalarComponentFromFloat(i,j,0,0,0);
index c4056b0e82206f6cb334a53eb8753ab8e8986e34..96ba90b4a03afcbc9c8822e01a39339c5caa92a3 100644 (file)
@@ -463,7 +463,9 @@ namespace creaImageIO
     //    std::cout << "user="<<p->GetUser() <<std::endl;
 
     if ( p->GetUser() == this ) 
+       {
       GetMultiThreadImageReaderUserMutex().Unlock();
+       }
 
     p->GetUser()->MultiThreadImageReaderSendEvent
       (p->GetFilename(),
@@ -480,9 +482,22 @@ namespace creaImageIO
     //    wxMutexLocker lock(GetMultiThreadImageReaderUserMutex());
           
     mUnloadQueue.insert(p);
+
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
     p->GetImage()->UpdateInformation();
     p->GetImage()->PropagateUpdateExtent();
     long ImMem = p->GetImage()->GetEstimatedMemorySize();
+#else
+       int ext[6];
+       int dim[3];
+       p->GetImage()->GetExtent(ext);
+       dim[0]          = ext[1]-ext[0]+1;
+       dim[1]          = ext[3]-ext[2]+1;
+       dim[2]          = ext[5]-ext[4]+1;
+    long ImMem         = dim[0]*dim[1]*dim[2]*p->GetImage()->GetScalarSize();;
+#endif
     mTotalMem += ImMem;
 
     GimmickMessage(5,"==> Image in memory = "<<mUnloadQueue.size()<<std::endl);
@@ -517,7 +532,19 @@ namespace creaImageIO
        std::string filename = unload->GetFilename();
 
        GimmickMessage(5,"'" << filename << "'" << std::endl);
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        mTotalMem -= unload->GetImage()->GetEstimatedMemorySize();
+#else
+       int ext[6];
+       int dim[3];
+       unload->GetImage()->GetExtent(ext);
+       dim[0]          = ext[1]-ext[0]+1;
+       dim[1]          = ext[3]-ext[2]+1;
+       dim[2]          = ext[5]-ext[4]+1;
+       mTotalMem -= dim[0]*dim[1]*dim[2]*unload->GetImage()->GetScalarSize();
+#endif
 
        GimmickMessage(5," ==> Total mem = "<<mTotalMem<<" Ko "<<std::endl);
 
index 7b0064676555edc1c7551165c6175087030c792c..753691375284437a4715dbfa540eb12efd9973f0 100644 (file)
@@ -85,7 +85,13 @@ vtkImageData * creaImageIOUnMosaicVtkImageData::unMosaic(vtkImageData *imageIn,
    int outputdims[3];
    imageIn->GetDimensions (inputdims);
    unsigned short *input = (unsigned short *)(imageIn->GetScalarPointer());
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
    imageIn->Update();
+#else
+       // ..
+#endif
+
      
    unsigned int div = (unsigned int)ceil(sqrt( (double)numberOfImagesInMosaic ) );
    outputdims[0] = inputdims[0] / div;
@@ -96,12 +102,18 @@ vtkImageData * creaImageIOUnMosaicVtkImageData::unMosaic(vtkImageData *imageIn,
     vtkImageOut = vtkImageData::New();
     vtkImageOut->SetDimensions( outputdims );
     vtkImageOut->SetExtent(0,outputdims[0]-1,0,outputdims[1]-1,0,outputdims[2]-1);
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
     vtkImageOut->SetWholeExtent(0,outputdims[0]-1,0,outputdims[1]-1,0,outputdims[2]-1);
     vtkImageOut->SetNumberOfScalarComponents(1);
 //vtkImageOut->SetSpacing( blabla );
     vtkImageOut->SetScalarType( VTK_UNSIGNED_SHORT );
     vtkImageOut->AllocateScalars();
     vtkImageOut->Update();
+#else
+    vtkImageOut->AllocateScalars(VTK_UNSIGNED_SHORT,1);
+#endif
     
     unsigned short *output =(unsigned short *)(vtkImageOut->GetScalarPointer());
 
index 51674d3f6ac4b5136f0e919ee2327ea2793e942f..df248194e422405edfd7a69d4515ae6bfd69194a 100644 (file)
@@ -116,7 +116,15 @@ namespace creaImageIO
                        connector->Update();
                        vtkImageData *im = vtkImageData::New();
                        im->ShallowCopy(connector->GetOutput());
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                        im->Update();
+#else
+                       im->Modified();
+#endif
+
+
                        m_Vresults.push_back(im);
                 }
 
index ca984309b7eaf5d5e5cb27d8f3110c929317dd28..2e9a9c557993b0057c846e250ac8c97cbe82736f 100644 (file)
@@ -232,12 +232,14 @@ namespace creaImageIO
                                first->GetDimensions(dim);
                                if (dim[2]==1)
                                {
-                                       vtkImageData *out;
-                                       out  = vtkImageData::New();
-                                       out->SetScalarType(first->GetScalarType());
-                                       out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+                                       vtkImageData *out = vtkImageData::New();
                                        int ext[6];
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                                        first->GetWholeExtent(ext); 
+#else
+                                       first->GetExtent(ext); 
+#endif
                                        if(ext[5] == 0)
                                        {
                                           ext[5] = getImagesSelected().size()-1;
@@ -254,8 +256,18 @@ namespace creaImageIO
                                }
                                        out->SetSpacing(spac);
                                        out->SetDimensions(dim[0], dim[1], getImagesSelected().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 here
                                        // differents formats char , short, etc...
index 7f15e403fd55e8ff1537fa555fc3b8515156924c..a6e3d98ff7d003ec6adb43e8041286b3ba355bf1 100644 (file)
@@ -207,20 +207,40 @@ namespace creaImageIO
                        <<std::endl);
     if (im==0) return;
 
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
     mViewer->SetInput(im);
+#else
+    mViewer->SetInputData(im);
+#endif
 
     mViewer->SetSlice( 0 );
 
     int x1,x2,y1,y2,z1,z2;
     double spx,spy,spz;
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
     im->Update();
+#else
+       // ...
+#endif
+
 
 //std::cout << "in WxViewer::ShowImage PrintSelf() =";
 //im->PrintSelf(std::cout, vtkIndent(2));
 
     im->GetSpacing(spx,spy,spz);
     //im->GetExtent (x1,x2,y1,y2,z1,z2);  // JPR
+
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
     im->GetWholeExtent (x1,x2,y1,y2,z1,z2); 
+#else
+    im->GetExtent (x1,x2,y1,y2,z1,z2); 
+#endif
+
+
 /*       
 std::cout << "in WxViewer::ShowImage GetWholeExtent ext =";
        std::cout << "   [x1]=" << x1;