]> Creatis software - creaImageIO.git/commitdiff
Z Spacing
authorjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Tue, 8 Dec 2009 14:28:13 +0000 (14:28 +0000)
committerjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Tue, 8 Dec 2009 14:28:13 +0000 (14:28 +0000)
src2/creaImageIOGimmickView.cpp

index c2ece7433afe15826af0a878010a2f7b059c1135..6b3dfbfb2c1b72ef849075486fde73d99e556cdc 100644 (file)
@@ -2,6 +2,11 @@
 #include <creaImageIOSystem.h>
 #include "boost/filesystem.hpp"
 
+#include <gdcmSerieHelper.h>    // JPR
+#include <gdcmFile.h>           // JPR
+#include <vtkGdcmReader.h>      // JPR
+#include <gdcmDebug.h>
+
 namespace fs = boost::filesystem;
 
 namespace creaImageIO
@@ -13,20 +18,20 @@ namespace creaImageIO
   public:
     ImageExtent(const std::string& x, const std::string& y, const std::string& z, const std::string& t)
        {
-                sscanf(x.c_str(),"%d",&mExtent[0]);
-                sscanf(y.c_str(),"%d",&mExtent[1]);
-                sscanf(z.c_str(),"%d",&mExtent[2]);
-                sscanf(t.c_str(),"%d",&mExtent[3]);
-                if(x==""){mExtent[0]=1;}
-            if(y==""){mExtent[1]=1;}
-            if(z==""){mExtent[2]=1;}
-                if(t==""){mExtent[3]=1;}
-
-                if (mExtent[3]>1) mDim=4;
-                else if (mExtent[2]>1) mDim=3;
-            else if (mExtent[1]>1) mDim=2;
-            else if (mExtent[0]>1) mDim=1;
-                else mDim=0;
+          sscanf(x.c_str(),"%d",&mExtent[0]);
+          sscanf(y.c_str(),"%d",&mExtent[1]);
+          sscanf(z.c_str(),"%d",&mExtent[2]);
+          sscanf(t.c_str(),"%d",&mExtent[3]);
+          if(x==""){mExtent[0]=1;}
+          if(y==""){mExtent[1]=1;}
+          if(z==""){mExtent[2]=1;}
+          if(t==""){mExtent[3]=1;}
+
+          if (mExtent[3]>1) mDim=4;
+          else if (mExtent[2]>1) mDim=3;
+          else if (mExtent[1]>1) mDim=2;
+          else if (mExtent[0]>1) mDim=1;
+          else mDim=0;
        }
 
        ///Clears the extent
@@ -372,6 +377,57 @@ std::cout << std::endl;
                        }       
                        s.push_back(out);
                }
+/**/
+               else  // ici, on traite le cas *vraiment* n*2D as 3D  // JPR
+               {
+                       typedef std::vector<GDCM_NAME_SPACE::File* > FileList;
+                       FileList fileVector;
+                       //GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
+                       GDCM_NAME_SPACE::SerieHelper *sh = GDCM_NAME_SPACE::SerieHelper::New();
+                       std::vector<std::string>::iterator it;
+                       for (it=im.begin(); it!=im.end(); ++it)
+                       {
+                       //std::cout << "avant Load ---------" << *it << std::endl;
+                       
+                       ///\TODO liberer les GDCM_NAME_SPACE::File a la fin!  // JPR
+                               GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
+                       
+                               f->SetFileName(*it);
+                               f->Load();
+                               if (f->IsReadable())
+                                       fileVector.push_back(f);
+                               else
+                                       std::cout << "File [" <<  *it << "] not GDCM Readable; Skipped!" << std::endl;
+                       }
+                       
+                       /*
+                       for (int i=0; i<fileVector.size();i++)
+                       {
+                         std::cout << "avant tri ---------" << fileVector[i]->GetFileName() << std::endl;
+                       }
+                       */
+                       if (!sh->IsCoherent(&fileVector))
+                       {
+                               std::cout << "---------fileset is NOT coherent ?!?" << *it << std::endl;
+                               //return;
+                       }
+                       else
+                       {
+                               sh->OrderFileList(&fileVector);
+                       }
+                       /*
+                       for (int i=0; i<fileVector.size();i++)
+                       {
+                         std::cout << "apres tri ---------" << fileVector[i]->GetFileName() << std::endl;
+                       }
+                        */
+                        vtkGdcmReader *reader = vtkGdcmReader::New();
+                        reader->SetCoherentFileList(&fileVector);
+                        reader->Update();
+                        s.push_back(reader->GetOutput());
+                        reader->GetOutput()->Print(std::cout);  
+               }
+   /**/
        }
 }
   //======================================================================