]> Creatis software - gdcm.git/blobdiff - src/gdcmDicomDir.cxx
- now Write drops LUT Descriptors and LUTs (if any) when SamplesPerPixel =3
[gdcm.git] / src / gdcmDicomDir.cxx
index a542b0b4ca61b26e6feed6bc50957fa077d23f7f..7a18df16f7d28230eda48d4c2e06238e89678b5a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/19 23:51:03 $
-  Version:   $Revision: 1.48 $
+  Date:      $Date: 2004/06/28 09:30:58 $
+  Version:   $Revision: 1.53 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -133,7 +133,9 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
 gdcmDicomDir::gdcmDicomDir(bool exception_on_error):                           
    gdcmDocument(exception_on_error)
 { 
+
    Initialize();
+
    std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ...
    SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements
    AddDicomDirMeta();
@@ -341,7 +343,7 @@ bool gdcmDicomDir::Write(std::string fileName)
  * @param   _fp already open file pointer
  */
 
-void gdcmDicomDir::WriteEntries(FILE *_fp)
+void gdcmDicomDir::WriteEntries(FILE *) //_fp
 {   
    /// \todo (?) tester les echecs en ecriture 
    ///          (apres chaque fwrite, dans le WriteEntry)
@@ -366,8 +368,8 @@ void gdcmDicomDir::WriteEntries(FILE *_fp)
       for(i=(*itPatient)->debut();i!=(*itPatient)->fin();++i) {
          WriteEntry(*i,_fp, gdcmExplicitVR);
       }
-      itStudy = ((*itPatient)->GetDicomDirStudies()).begin();        
-      while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {   
+      itStudy = ((*itPatient)->GetDicomDirStudies()).begin();     
+      while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
          for(i=(*itStudy)->debut();i!=(*itStudy)->fin();++i) {
             WriteEntry(*i,_fp, gdcmExplicitVR);
          } 
@@ -381,11 +383,11 @@ void gdcmDicomDir::WriteEntries(FILE *_fp)
                for(i=(*itImage)->debut();i!=(*itImage)->fin();++i) {
                   WriteEntry(*i,_fp, gdcmExplicitVR);
                }
-               ++itImage;                  
-           }
-           ++itSerie;                                
+               ++itImage;
+            }
+            ++itSerie;
          }
-        ++itStudy;            
+         ++itStudy;
       } 
       ++itPatient;     
    }
@@ -403,7 +405,6 @@ void gdcmDicomDir::WriteEntries(FILE *_fp)
 void gdcmDicomDir::CreateDicomDirChainedList(std::string path)
 {
    CallStartMethod();
-
    gdcmDirList fileList(path,1); // gets recursively the file list
    unsigned int count=0;
    VectDocument list;
@@ -416,18 +417,26 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string path)
                              it!=fileList.end(); 
                              ++it) 
    {
+      std::cout << "nom fichier " << it->c_str() << std::endl; //JPR
+
       progress=(float)(count+1)/(float)fileList.size();
       CallProgressMethod();
       if(abort)
-         break;
+          break;
 
       header=new gdcmHeader(it->c_str());
-      if(header->IsReadable())
+      if(!header) {
+         std::cout << "echec new Header " << it->c_str() << std::endl; // JPR
+      }
+      if(header->IsReadable()) {
          list.push_back(header);  // adds the file header to the chained list
+         std::cout << "readable : " <<it->c_str() << std::endl;
+       }
       else
          delete header;
 
       count++;
+
    }
    // sorts Patient/Study/Serie/
    std::sort(list.begin(),list.end(),gdcmDicomDir::HeaderLessThan);
@@ -533,8 +542,7 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,
    gdcmValEntry *entry;
    std::string val;
 
-   switch(type)
-   {
+   switch(type){
       case GDCM_DICOMDIR_PATIENT:
          elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
          break;
@@ -554,12 +562,12 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,
          return;
    }
 
-   for(it=elemList.begin();it!=elemList.end();++it)
-   {
+   for(it=elemList.begin();it!=elemList.end();++it) {
       tmpGr=it->group;
       tmpEl=it->elem;
       dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
-      entry=new gdcmValEntry(dictEntry);
+      entry=new gdcmValEntry(dictEntry); // Be sure it's never a BinEntry !
+
       entry->SetOffset(0); // just to avoid further missprinting
 
       if(header)
@@ -602,23 +610,22 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,
 
       if(dictEntry)
       {
-         if(dictEntry->GetGroup()==0xfffe) 
-         {
+         if(dictEntry->GetGroup()==0xfffe)  {
             entry->SetLength(entry->GetValue().length());
-         }
-         else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) 
+      }
+     else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) 
          {
             entry->SetLength(4);
          } 
-         else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") ) 
+      else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") ) 
          {
             entry->SetLength(2); 
          } 
-         else if(dictEntry->GetVR()=="SQ") 
+      else if(dictEntry->GetVR()=="SQ") 
          {
             entry->SetLength(0xffffffff);
          }
-         else
+      else
          {
             entry->SetLength(entry->GetValue().length());
          }
@@ -695,6 +702,7 @@ void gdcmDicomDir::CreateDicomDir()
 
    ListSQItem listItems = s->GetSQItems();
    gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT);
+   (void)m; //??
    
    gdcmDocEntry * d;   
    std::string v;
@@ -778,7 +786,7 @@ void gdcmDicomDir::CreateDicomDir()
          AddDicomDirImageToEnd(s);
          break;
       case gdcmDicomDir::GDCM_DICOMDIR_NONE:
-         AddDicomDirImageToEnd(s);     //FIXME
+         AddDicomDirImageToEnd(s);        //FIXME
          break;
    }
 }
@@ -957,7 +965,7 @@ void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() {
       }            
    }   
    //bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
-        SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
+    SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
    return;
    */
 }