]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOGimmickView.cpp
Z Spacing
[creaImageIO.git] / src2 / creaImageIOGimmickView.cpp
index c7e0cf15c0f1aedb86f6ee447a76b2b70e24abae..c2ece7433afe15826af0a878010a2f7b059c1135 100644 (file)
@@ -28,7 +28,6 @@ namespace creaImageIO
             else if (mExtent[0]>1) mDim=1;
                 else mDim=0;
        }
-       
 
        ///Clears the extent
     void Clear() { mExtent[0] = mExtent[1] = mExtent[2] = mExtent[3] = 1; }
@@ -66,7 +65,6 @@ namespace creaImageIO
        // Anciently started the threads ...
     // Threads now automatically start at first image request
     //mReader.Start();
-       
   }
   //======================================================================
 
@@ -88,7 +86,7 @@ namespace creaImageIO
        mReaderStarted=false;
   }
   //======================================================================
-  
+
   //======================================================================
   /// Finalize 
   void GimmickView::Finalize()
@@ -118,7 +116,6 @@ namespace creaImageIO
      
   }
 
-
   //======================================================================
 
   //======================================================================
@@ -133,7 +130,7 @@ namespace creaImageIO
        GimmickError("INTERNAL ERROR : GimmickView::UpdateTreeView : '"
                     <<t<<"' is not in TreeViewMap");
       }
-    i->second->UpdateLevel(l);    
+    i->second->UpdateLevel(l);
   }
 
   //======================================================================
@@ -148,7 +145,7 @@ namespace creaImageIO
   }
 
   //======================================================================
-  
+
   //======================================================================
   bool ImageExtent::IsCompatible(const ImageExtent& ie)
   {
@@ -163,7 +160,7 @@ namespace creaImageIO
   }
 
   //======================================================================
-  
+
   //======================================================================
   void ImageExtent::Add(const ImageExtent& ie)
   {
@@ -283,9 +280,22 @@ namespace creaImageIO
   ///Reads Images (Non Threaded)
 void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vector<std::string> im, int dimension)
 {
+
+/* remember!
+
+#define GIMMICK_NO_IMAGE_SELECTION 0
+#define GIMMICK_2D_IMAGE_SELECTION 2
+#define GIMMICK_3D_IMAGE_SELECTION 3
+#define GIMMICK_4D_IMAGE_SELECTION 4
+
+#define NATIVE 0
+#define _2D    2
+#define _3D    3
+
+*/
        // Create the output data
        if (im.size()==1) 
-       {                 
+       {
                // Only one image : give it
                vtkImageData* out = vtkImageData::New();
                GimmickDebugMessage(3, "State Check: Full Filename: "
@@ -293,12 +303,14 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                                        <<std::endl);
                out->ShallowCopy(mReader.GetImage(im.front()));
                s.push_back( out );
-       }         
+       }
        else if (im.size()>1) // Test inutile ? JPR
        {
+               // Read the FIRST image to get info ... about all the other ones. ?!? // JPR
                vtkImageData* first = mReader.GetImage( im.front());
+
                if (dimension == 2)
-               {  
+               {
                 // n3D
                    std::vector<std::string>::iterator it;
                        for (it=im.begin(); it!=im.end(); ++it) 
@@ -308,20 +320,24 @@ void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vect
                                s.push_back(out);
                        }
                }         
-               else 
+               else if (dimension == 3)
                {
-                       // n2D to 3D
+                       // n*2D to 3D  :: --> NON ! Ca va tres bien pour du 2D+T (le ZSpacing, on s'en tape)
+                       //                      // ne convient pas pour du n*2D a  lire comme un 3D
+                       //                      // Il faut un gdcmSerieHelper !
                        vtkImageData* out = vtkImageData::New();
                        out->CopyStructure(first);      
                        out->SetScalarType(first->GetScalarType());
                        int ext[6];
-                       //first->GetExtent(ext);  // JPR
-                       first->GetWholeExtent(ext);
+                       //first->GetExtent(ext);     // JPR
+                       first->GetWholeExtent(ext);  // renvoie egalement 0,0 en Z // JPR
+                                                    // Normal :
+
 std::cout <<"in GimmickView::ReadImagesNotThreaded GetWholeExtent ext =";
 for (int jjj=0;jjj<6;jjj++)
        std:cout << "   [" << jjj << "]=" << ext[jjj];
-std::cout << endl;
-                       
+std::cout << std::endl;
+
                        if(ext[5] == 0)
                        {
                                ext[5] = im.size()-1;
@@ -331,17 +347,15 @@ std::cout << endl;
                                ext[5] = ext[5] * im.size()-1; // to deal with multiframes - JPR
                        }
                        out->SetExtent(ext);
-                       // LG : TODO : Z Spacing  ?
 
-                       out->AllocateScalars();
+                       // LG : TODO : Z Spacing  ?  // Voir + loin // JPR
 
-                       //first->Print(std::cout);
-                       //          out->Print(std::cout);
+                       out->AllocateScalars();
 
                        int dim[3];
                        first->GetDimensions(dim);
                        unsigned long imsize = dim[0] * dim[1];
-                       imsize = imsize * dim[2] ;  // deal with multiframes// JPR
+                       imsize = imsize * dim[2] ;  // deal with multiframes // JPR
 //EED 03-11-2009
                        imsize = imsize * first->GetScalarSize();
 
@@ -349,13 +363,12 @@ std::cout << endl;
                        std::vector<std::string>::iterator it;
                        for (it=im.begin(); it!=im.end(); ++it) 
                        {
-               
-                       vtkImageData* cur = mReader.GetImage( (*it));
-               //      void* src = cur->GetScalarPointer(0,0,0);
-               //      void* dst = out->GetScalarPointer(0,0,slice);
-                       memcpy(out->GetScalarPointer(0,0,slice),cur->GetScalarPointer(0,0,0),imsize);
+                               vtkImageData* cur = mReader.GetImage( (*it));
+                       //      void* src = cur->GetScalarPointer(0,0,0);
+                       //      void* dst = out->GetScalarPointer(0,0,slice);
+                               memcpy(out->GetScalarPointer(0,0,slice), cur->GetScalarPointer(0,0,0), imsize);
 
-                       slice++;
+                               slice++;
                        }       
                        s.push_back(out);
                }
@@ -382,9 +395,10 @@ void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, s
                if (dimension == 2)
                {
                 // n3D
-                 std::vector<std::string>::iterator it;
+                   std::vector<std::string>::iterator it;
                        for (it=im.begin(); it!=im.end(); ++it)
                        {
+                       std::cout << "----------------------------------------n3D" << std::endl;
                                vtkImageData* out = vtkImageData::New();
                                out->ShallowCopy(mReader.GetImage(*it));
                                s.push_back(out);
@@ -394,11 +408,15 @@ void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, s
                {
                        // n2D to 3D // NO!
                        // n *2D + T in a vector :
-                       
+                       std::cout << "---------------------------------------- n *2D + T" << std::endl;                 
                        std::vector<std::string>::iterator it;
                        for (it=im.begin(); it!=im.end(); ++it) 
                        {
-                               vtkImageData* out = mReader.GetImage( (*it));
+                       std::cout << "---------------------------------------- [" << *it << "]" << std::endl;
+                               //vtkImageData* out = mReader.GetImage( (*it));
+                               //s.push_back(out);
+                               vtkImageData* out = vtkImageData::New();
+                               out->ShallowCopy(mReader.GetImage(*it));
                                s.push_back(out);
                        }
                }
@@ -411,15 +429,15 @@ void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, s
   void GimmickView::RequestReading(tree::Node* n, 
          int prio, int selection_index, boost::shared_ptr<ImagePointerHolder> p)
   {
-         if(!mReaderStarted)
-         {
-               mReader.Start();
-               mReaderStarted=true;
-         }
-    ImageEventType t(n,selection_index);
-       t.pointerHolder = p;
-    mImageEventMap[n->GetAttribute("FullFileName")] = t;    
-    mReader.Request(this,n->GetAttribute("FullFileName"),prio);
+     if(!mReaderStarted)
+     {
+        mReader.Start();
+        mReaderStarted=true;
+      }
+      ImageEventType t(n,selection_index);
+      t.pointerHolder = p;
+      mImageEventMap[n->GetAttribute("FullFileName")] = t;
+      mReader.Request(this,n->GetAttribute("FullFileName"),prio);
   }
   //======================================================================