]> Creatis software - creaImageIO.git/commitdiff
#3338 gdcm1 to gdcm2 v3.3.0
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Tue, 26 May 2026 14:26:01 +0000 (16:26 +0200)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Tue, 26 May 2026 14:26:01 +0000 (16:26 +0200)
src/creaImageIODicomImageReader2.cpp
src/creaImageIOOutputModel.cpp
src/creaImageIOSimpleView.cpp
src/creaImageIOWxGimmickView.cpp

index 6220d3dedaf5209166cf3e0593e8c4f7670bae34..fb93314e8fa741526c1eed6fff24da40111afe52 100644 (file)
@@ -66,7 +66,6 @@ namespace creaImageIO
       gdcm::Reader reader;
       reader.SetFileName( filename.c_str() );
       return  reader.Read();
-        
   }
   //=====================================================================
 
@@ -74,17 +73,16 @@ namespace creaImageIO
   vtkImageData* DicomImageReader::ReadImage(const std::string& filename)
   {
     vtkImageData* im = 0;
-    try
+    try 
       {
-       mReader->SetFileName(filename.c_str());
-       mReader->Update();
-       im = vtkImageData::New();
-       im->ShallowCopy(mReader->GetOutput());
-      }
-    catch (...)
-      {
-       if (im!=0) im->Delete();
-         im = 0;
+          mReader->SetFileName(filename.c_str());
+          mReader->FileLowerLeftOn();
+          mReader->Update();
+          im = vtkImageData::New();
+          im->ShallowCopy(mReader->GetOutput());
+      } catch (...) {
+          if (im!=0) im->Delete();
+          im = 0;
       }
     return im;
     //gdcm::Tag grouplength(0x0000,0x0000);
@@ -96,7 +94,6 @@ namespace creaImageIO
 
     //std::ostream os;
     //de.Write(&os);
-
   }
 
   //=====================================================================
index 24be6c9dd7a2139ccc340d4d95935a6ebc01dc93..c17365c91c5896891b1cf5201d42b69001f9cc9a 100644 (file)
 #include "boost/algorithm/string.hpp"
 
 #if defined(USE_GDCM)
-#include <gdcmGlobal.h>
-#include <gdcmFile.h>
-#include <gdcmSerieHelper.h>
-#include <gdcmFile.h>
+   #include <gdcmGlobal.h>
+   #include <gdcmFile.h>
+   #include <gdcmSerieHelper.h>
+   #include <gdcmFile.h>
 #endif
 
 #if defined(USE_GDCM2)
-#include <gdcmDict.h>
-#include <gdcmDicts.h>
-#include <gdcmGlobal.h>
+   #include <gdcmDict.h>
+   #include <gdcmDicts.h>
+   #include <gdcmGlobal.h>
+   #include "gdcmIPPSorter.h"
 #endif
 
 #if defined(USE_XERCES)
@@ -110,8 +111,34 @@ namespace creaImageIO
 #if defined(USE_GDCM2)
        // TO DO
        double OutputModel::orderFilesWithZspacing(std::vector<std::string> &im)
-       {
-               return 1;
+{
+        //EED 2026-05-26
+        gdcm::IPPSorter s;
+        s.SetComputeZSpacing( true );
+        s.SetZSpacingTolerance( 1e-3 );
+        bool b = s.Sort( im );
+        if( !b )
+        {
+            std::cerr << "Failed to sort DICOM Files:"  << std::endl;
+            //return ;
+        }
+        //std::cout << "Sorting succeeded:" << std::endl;
+        //s.Print( std::cout );
+        
+        //std::cout << "Found z-spacing:" << std::endl;
+        //std::cout << s.GetZSpacing() << std::endl;
+        double ippzspacing = s.GetZSpacing();
+        
+        const std::vector<std::string> & sorted = s.GetFilenames();
+        
+        im.clear();
+        int iEED,sizeEED = sorted.size();
+        for (iEED = 0; iEED<sizeEED; iEED++)
+        {
+            im.push_back( sorted[iEED].c_str() );
+        }  // for
+        
+               return ippzspacing;
        }
 #endif
 
index 98321c132c24fe5f53098a125f85085640d36ec1..41341ed13bb06e9825fe58938a1ee2ca8bcf8dd7 100644 (file)
@@ -53,7 +53,8 @@ namespace creaImageIO
                        std::vector<std::string>::iterator it = i_filenames.begin();
                        for (; it != i_filenames.end(); it++)
                        {
-                               bresult = mReader->CanRead((*it).c_str());
+                printf("EED SimpleView::readFile .H.H.H  %s \n" , (*it).c_str() );
+                               bresult = mReader->CanRead( (*it).c_str() );
                                if(bresult)
                                {
                                        std::map <std::string , std::string> mapAttr;
index b12662acffb5244bcda6c4bcc01c31bfe079fff6..c1fe02cea244c37d699844159d441ca010eb0a58 100644 (file)
@@ -456,6 +456,7 @@ void WxGimmickView::AddBtnTool(wxPanel *panel, wxBoxSizer *sizerH, int id, wxStr
 
        // Next we create model and sort files
        std::vector<std::string> sort_files(files);
+      
        double zspacing = 1;
        if( !out_model.empty() )
        {
@@ -474,12 +475,6 @@ void WxGimmickView::AddBtnTool(wxPanel *panel, wxBoxSizer *sizerH, int id, wxStr
        readImages(outG, sort_files, Oattr, i_dim_out, zspacing);
     outFileNames = sort_files;
   }
-
-
-
-
-  //======================================================================
-
   //======================================================================