]> Creatis software - gdcm.git/commitdiff
moved from gdcmParser to gdcmDocument.
authorjpr <jpr>
Tue, 8 Jun 2004 09:15:17 +0000 (09:15 +0000)
committerjpr <jpr>
Tue, 8 Jun 2004 09:15:17 +0000 (09:15 +0000)
Please wait a little more before using

18 files changed:
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDicomDirImage.cxx
src/gdcmDicomDirImage.h
src/gdcmDicomDirMeta.cxx
src/gdcmDicomDirMeta.h
src/gdcmDicomDirPatient.cxx
src/gdcmDicomDirPatient.h
src/gdcmDicomDirSerie.cxx
src/gdcmDicomDirSerie.h
src/gdcmDicomDirStudy.cxx
src/gdcmDicomDirStudy.h
src/gdcmDirList.cxx
src/gdcmFile.cxx
src/gdcmHeader.cxx
src/gdcmHeader.h
src/gdcmObject.cxx
src/gdcmObject.h

index 20d81973fbdab959aabef1076f546bc53a66e5ff..f4dc21dc2dc2715957d4002909ea57dc88dc03ee 100644 (file)
 #include "gdcmDebug.h"
 #include "gdcmGlobal.h"
 
+#include "gdcmSeqEntry.h"
+#include "gdcmSQItem.h"
+#include "gdcmValEntry.h"
+
 //-----------------------------------------------------------------------------
 //  For full DICOMDIR description, see:
 //  PS 3.3-2003, pages 731-750
  */
 gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
                            bool exception_on_error):
-   gdcmParser(FileName,exception_on_error,true) // true : enable SeQuences
+   gdcmDocument(FileName,exception_on_error,true) // true : enable SeQuences
 {
  // que l'on ai passe un root directory ou un DICOMDIR
  // et quelle que soit la valeur de parseDir,
- // on a lance gdcmParser 
+ // on a lance gdcmDocument 
       
    startMethod=            NULL;
    progressMethod=         NULL;
@@ -62,22 +66,22 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
    progress=0.0;
    abort=false;
 
-   metaElems=NULL;
+   metaElems=NULL;   
 
-// gdcmParser already executed
+// gdcmDocument already executed
 // if user passed a root directory, sure we didn't get anything
 
-   if( GetListEntry().begin()==GetListEntry().end() ) 
+   if( GetEntry().begin()==GetEntry().end() ) 
    {
      // if parseDir == false, it should be tagged as an error
-      dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry list empty");
+      dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry HT empty");
 
       if(strlen(FileName)==1 && FileName[0]=='.') { // user passed '.' as Name
                                             // we get current directory name
          char* dummy= new char[1000];
          getcwd(dummy, (size_t)1000);
          SetFileName(dummy); // will be converted into a string
-         delete[] dummy;        // no longer needed   
+         delete[] dummy;     // no longer needed   
       }
 
       if(parseDir)
@@ -88,10 +92,13 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
       }
    }
    else {
+      gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); // Directory record sequence
+      if (e==NULL) {
+         dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record sequence (0x0004,0x1220)"
+                     );
+         // FIXME : what to do when the parsed file IS NOT a DICOMDIR file ?         
+      }      
       CreateDicomDir();
-      CheckBoundaries(); // to maintain consistency between 
-                         // home-made gdcmDicomDir 
-                         // and the ones comming from a DICOMDIR file
    } 
 }
 
@@ -101,7 +108,7 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
  * @param   exception_on_error whether we want to throw an exception or not
  */
 gdcmDicomDir::gdcmDicomDir(bool exception_on_error):                           
-   gdcmParser(exception_on_error)
+   gdcmDocument(exception_on_error)
 { 
    startMethod=            NULL;
    progressMethod=         NULL;
@@ -118,7 +125,7 @@ gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
    std::string pathBidon = ""; // Sorry, NULL not allowed ...
    SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements
    
-   AddDicomDirMetaToEnd(listEntries.begin(),--listEntries.end());
+   AddDicomDirMeta();
 }
 
 
@@ -169,12 +176,12 @@ void gdcmDicomDir::Print(std::ostream &os)
  *         decides whether or not the current header was properly parsed
  *         and contains the mandatory information for being considered as
  *         a well formed and usable DicomDir.
- * @return true when gdcmParser is the one of a reasonable DicomDir,
+ * @return true when gdcmDocument is the one of a reasonable DicomDir,
  *         false otherwise. 
  */
 bool gdcmDicomDir::IsReadable(void)
 {
-   if(!gdcmParser::IsReadable())
+   if(!gdcmDocument::IsReadable())
       return(false);
    if(!metaElems)
       return(false);
@@ -328,6 +335,9 @@ void gdcmDicomDir::WriteEntries(FILE *_fp)
    /// \todo (?) tester les echecs en ecriture 
    ///          (apres chaque fwrite, dans le WriteEntry)
 
+
+/* TODO : to go on compiling
+
    gdcmDicomDirMeta *ptrMeta;
    ListDicomDirPatient::iterator  itPatient;
    ListDicomDirStudy::iterator    itStudy;
@@ -368,6 +378,7 @@ void gdcmDicomDir::WriteEntries(FILE *_fp)
       } 
       ++itPatient;     
    }
+   */
 }   
    
 //-----------------------------------------------------------------------------
@@ -375,7 +386,7 @@ void gdcmDicomDir::WriteEntries(FILE *_fp)
 
 /**
  * \ingroup gdcmDicomDir
- * \brief create a gdcmHeader-like chained list from a root Directory 
+ * \brief create a gdcmDocument-like chained list from a root Directory 
  * @param path entry point of the tree-like structure
  */
 void gdcmDicomDir::CreateDicomDirChainedList(std::string path)
@@ -387,7 +398,7 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string path)
    ListHeader list;
    gdcmHeader *header;
 
-   listEntries.clear();
+   tagHT.clear();
    patients.clear();
 
    for(gdcmDirList::iterator it=fileList.begin(); 
@@ -420,74 +431,55 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string path)
 
 /**
  * \ingroup gdcmDicomDir
- * \brief modifies the limits of a gdcmObject, created from a DICOMDIR file  
+ * \brief   adds *the* Meta to a partially created DICOMDIR
  */
-
-void gdcmDicomDir::CheckBoundaries()
-{   
-   ListDicomDirPatient::iterator  itPatient;
-   ListDicomDirStudy::iterator    itStudy;
-   ListDicomDirSerie::iterator    itSerie;
-   ListDicomDirImage::iterator    itImage; 
-   ListTag::iterator i,j; 
-   
-   GetDicomDirMeta()->ResetBoundaries(0);   
-
-   itPatient = GetDicomDirPatients().begin(); 
-   while ( itPatient != GetDicomDirPatients().end() ) {
-      (*itPatient)->ResetBoundaries(1);            
-      itStudy = ((*itPatient)->GetDicomDirStudies()).begin();        
-      while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {   
-         (*itStudy)->ResetBoundaries(1); 
-         itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
-         while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) {
-            (*itSerie)->ResetBoundaries(1);
-            itImage = ((*itSerie)->GetDicomDirImages()).begin();
-            while (itImage != (*itSerie)->GetDicomDirImages().end() ) {
-               (*itImage)->ResetBoundaries(1);
-              ++itImage;
-            }
-            ++itSerie;
-        }
-        ++itStudy;
-     } 
-     ++itPatient;     
+ // FIXME : Heuuuuu ! Il prend les Entries du Document deja parse,
+ //                   il ne fabrique rien !
+  
+gdcmDicomDirMeta * gdcmDicomDir::NewMeta(void) {
+   gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT);   
+   for (TagDocEntryHT::iterator cc = tagHT.begin();cc != tagHT.end();++cc) {
+      m->AddDocEntry(cc->second);
    }
-} 
+   return m;  
+}
 
 
 /**
  * \ingroup gdcmDicomDir
- * \brief   adds a new Patient to a partially created DICOMDIR
+ * \brief   adds a new Patient (with the basic elements) to a partially created DICOMDIR
  */
 gdcmDicomDirPatient * gdcmDicomDir::NewPatient(void) {
    std::list<gdcmElement> elemList;
    std::list<gdcmElement>::iterator it;
    guint16 tmpGr,tmpEl;
    gdcmDictEntry *dictEntry;
-   gdcmHeaderEntry *entry;
+   gdcmValEntry *entry;
+   
+   gdcmSQItem *s = new gdcmSQItem(0);
    
    elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();  
-   std::list<gdcmHeaderEntry *>::iterator debInsertion, finInsertion, i,j; 
-         
-   debInsertion = metaElems->fin(); 
-   ++debInsertion;
-   finInsertion=debInsertion;
+   
+   // TODO : use FillObject !!!
 
-   // for all the DicomDirPatient Elements   
+   // for all the DicomDirPatient Elements 
+     
    for(it=elemList.begin();it!=elemList.end();++it) 
    {
       tmpGr=it->group;
       tmpEl=it->elem;
       dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);      
-      entry=new gdcmHeaderEntry(dictEntry);
-      entry->SetOffset(0); // just to avoid missprinting
-      entry->SetValue(it->value);
+      entry=new gdcmValEntry(dictEntry);
+      entry->SetOffset(0); // just to avoid further missprinting
+      entry->SetValue(it->value); 
 
+      // dealing with value length ...
+      
       if(dictEntry->GetGroup()==0xfffe) 
-      {
+         { 
             entry->SetLength(entry->GetValue().length());
-      }
+         }
       else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) 
          {
             entry->SetLength(4);
@@ -504,21 +496,124 @@ gdcmDicomDirPatient * gdcmDicomDir::NewPatient(void) {
          {
             entry->SetLength(entry->GetValue().length());       
          } 
-                                             
-      tagHT.insert( PairHT(entry->GetKey(),entry) ); // add in the (multimap) H Table
-      listEntries.insert(debInsertion ,entry);       // en tete de liste des Patients                                           
-      ++finInsertion;
+      s->AddDocEntry(entry);
    }
 
-   i=metaElems->fin();
-   i++;
-
-   gdcmDicomDirPatient *p = new gdcmDicomDirPatient(i, --debInsertion,
-                                                    &tagHT, &listEntries);
+   gdcmDicomDirPatient *p = new gdcmDicomDirPatient(s, &tagHT);
    patients.push_front(p);
    return p;   
 }
 
+
+/**
+ * \ingroup gdcmDicomDir
+ * \brief   adds to the HTable 
+ *          the gdcmEntries (Dicom Elements) corresponding to the given type
+ * @param   path full path file name (only used when type = GDCM_DICOMDIR_IMAGE
+ * @param   type gdcmObject type to create (GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
+ * @param   header gdcmHeader of the current file
+ */
+void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader *header)
+{
+   std::list<gdcmElement> elemList;
+   std::list<gdcmElement>::iterator it;
+   guint16 tmpGr, tmpEl;
+   gdcmDictEntry *dictEntry;
+   gdcmDocEntry *entry;
+   std::string val;
+
+   switch(type)
+   {
+      case GDCM_DICOMDIR_PATIENT:
+         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
+         break;
+      case GDCM_DICOMDIR_STUDY:
+         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
+         break;
+      case GDCM_DICOMDIR_SERIE:
+         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
+         break;
+      case GDCM_DICOMDIR_IMAGE:
+         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
+         break;
+      case GDCM_DICOMDIR_META:
+         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
+         break;
+      default:
+         return;
+   }
+
+   for(it=elemList.begin();it!=elemList.end();++it)
+   {
+      tmpGr=it->group;
+      tmpEl=it->elem;
+      dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
+      entry=new gdcmDocEntry(dictEntry);
+      entry->SetOffset(0); // just to avoid further missprinting
+
+      if(header)
+         val=header->GetEntryByNumber(tmpGr,tmpEl);
+      else
+         val=GDCM_UNFOUND;
+
+      if(val==GDCM_UNFOUND) 
+      {
+         if((tmpGr==0x0004) &&(tmpEl==0x1130) ) // File-set ID
+         {      
+          // force to the *end* File Name
+           val=GetName(path);              
+         }
+         else if( (tmpGr==0x0004) && (tmpEl==0x1500) ) // Only used for image
+         {
+            if(header->GetFileName().substr(0,path.length())!=path)
+            {
+               dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path of file name is incorrect");
+               val=header->GetFileName();
+            }
+            else {
+               val=&(header->GetFileName().c_str()[path.length()]);
+           }   
+         }
+         else
+         {
+            val=it->value;
+         }
+      } 
+      else
+      {
+         if (header->GetEntryLengthByNumber(tmpGr,tmpEl)== 0)
+           val=it->value;
+      }
+            
+      ((gdcmValEntry *)entry)->SetValue(val);
+
+      if(dictEntry)
+      {
+         if(dictEntry->GetGroup()==0xfffe) 
+        {
+            entry->SetLength(((gdcmValEntry *)entry)->GetValue().length());     
+        }
+        else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) 
+         {
+            entry->SetLength(4);
+         } 
+         else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") ) 
+         {
+            entry->SetLength(2); 
+         } 
+         else if(dictEntry->GetVR()=="SQ") 
+         {
+            entry->SetLength(0xffffffff);
+         }
+         else
+         {
+            entry->SetLength(((gdcmValEntry *)entry)->GetValue().length());     
+         }
+      }
+      //AddDocEntry(entry); // both in H Table and in chained list
+      tagHT[entry->GetKey()] = entry;          // FIXME : use a SEQUENCE !
+   }     
+}
 /**
  * \ingroup gdcmDicomDir
  * \brief   CallStartMethod
@@ -567,132 +662,139 @@ void gdcmDicomDir::CreateDicomDir()
    //       + loop to 1 -
 
    gdcmDicomDirType type=gdcmDicomDir::GDCM_DICOMDIR_META;
-   ListTag::iterator begin;
-   ListTag::iterator end, end2;
-
-   begin=listEntries.begin();
-   end=begin;
-   for(ListTag::iterator i=end;i !=listEntries.end();++i) 
-   {
-      std::string v=(*i)->GetValue();
+   
+   gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); // Directory record sequence
+   if (e==NULL) {
+      dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record sequence (0x0004,0x1220)"
+                  );
+         // FIXME : what to do when the parsed file IS NOT a DICOMDIR file ? 
+      return;         
+   }
+   
+   gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT);
+   
+   gdcmSeqEntry *s = (gdcmSeqEntry *)e;  // FIXME : It is allowed ???  
+   ListSQItem listItems = s->GetSQItems();
+   
+   gdcmDocEntry * d;   
+   for(ListSQItem::iterator i=listItems.begin(); i !=listItems.end();++i) 
+   {  
+      d=(*i)->GetDocEntryByNumber(0x0004, 0x1430); // Directory Record Type   
+      std::string v=((gdcmValEntry *)d)->GetValue();
+      
       if(v=="PATIENT ") 
-      {
-         end=end2=i;
-         AddObjectToEnd(type,begin,--end2);
+      {  
+         AddDicomDirPatientToEnd(*i);
+         //AddObjectToEnd(type,*i);
          type=gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
-         begin=end;
       }        
 
-      if(v=="STUDY ")
+      else if(v=="STUDY ")
       {
-         end=end2=i;
-         AddObjectToEnd(type,begin,--end2);
+         AddDicomDirStudyToEnd(*i);
+        // AddObjectToEnd(type,*i);
          type=gdcmDicomDir::GDCM_DICOMDIR_STUDY;
-         begin=end;
       }
 
-      if(v=="SERIES") 
+      else if(v=="SERIES") 
       {
-         end=end2=i;
-         AddObjectToEnd(type,begin,--end2);
+         AddDicomDirSerieToEnd(*i);
+       //  AddObjectToEnd(type,*i);
          type=gdcmDicomDir::GDCM_DICOMDIR_SERIE;
-         begin=end;
       }
 
-      if(v=="IMAGE ") 
+      else if(v=="IMAGE ") 
       {
-         end=end2=i;
-         AddObjectToEnd(type,begin,--end2);
+         AddDicomDirImageToEnd(*i);
+      //   AddObjectToEnd(type,*i);
          type=gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
-         begin=end;
       }
+      
+      else
+         continue ;  // It was 'non PATIENT', 'non STUDY', 'non SERIE', 'non IMAGE' SQItem      
    }
-
-   end=end2=listEntries.end();
-   if(begin!=end)
-      AddObjectToEnd(type,begin,--end2);
 }
 /**
  * \ingroup gdcmDicomDir
  * \brief   AddObjectToEnd
  * @param   type
- * @param   begin iterator on the first HeaderEntry within the chained List
- * @param   end iterator on the last HeaderEntry within the chained List
+ * @param   begin iterator on the first DocEntry within the chained List
+ * @param   end iterator on the last DocEntry within the chained List
  */
-void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,ListTag::iterator end)
+// now  useless ?
+
+/*void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,gdcmSQItem *s)
 {
-   if(begin==end)
+   if(s==NULL) // ??
       return;
 
    switch(type)
    {
       case gdcmDicomDir::GDCM_DICOMDIR_META:
-         AddDicomDirMetaToEnd(begin,end);
+         AddDicomDirMeta();
          break;      
       case gdcmDicomDir::GDCM_DICOMDIR_PATIENT:
-         AddDicomDirPatientToEnd(begin,end);
+         AddDicomDirPatientToEnd(s);
          break;
       case gdcmDicomDir::GDCM_DICOMDIR_STUDY:
-         AddDicomDirStudyToEnd(begin,end);
+         AddDicomDirStudyToEnd(s);
          break;
       case gdcmDicomDir::GDCM_DICOMDIR_SERIE:
-         AddDicomDirSerieToEnd(begin,end);
+         AddDicomDirSerieToEnd(s);
          break;
       case gdcmDicomDir::GDCM_DICOMDIR_IMAGE:
-         AddDicomDirImageToEnd(begin,end);
+         AddDicomDirImageToEnd(s);
+         break;
+      case gdcmDicomDir::GDCM_DICOMDIR_NONE:
+         AddDicomDirImageToEnd(s);     //FIXME
          break;
-                       case gdcmDicomDir::GDCM_DICOMDIR_NONE:
-                                AddDicomDirImageToEnd(begin,end);      //FIXME
-                                break;
    }
 }
 
+*/
+
 /**
  * \ingroup gdcmDicomDir
- * \brief Well ... Not realy to end, there is only one occurence  
- * @param   begin iterator on the first HeaderEntry within the chained List
- * @param   end iterator on the last HeaderEntry within the chained List
+ * \brief Well ... there is only one occurence  
 */
-void gdcmDicomDir::AddDicomDirMetaToEnd(ListTag::iterator begin,ListTag::iterator end)
+void gdcmDicomDir::AddDicomDirMeta()
 {
    if(metaElems)
       delete metaElems;
-   metaElems = new gdcmDicomDirMeta(begin,end,&tagHT,&listEntries);
+   metaElems = new gdcmDicomDirMeta(&tagHT);
 }
 
 /**
  * \ingroup gdcmDicomDir
  * \brief  AddDicomDirPatientToEnd 
- * @param   begin iterator on the first HeaderEntry within the chained List
- * @param   end iterator on the last HeaderEntry within the chained List
+ * @param   s SQ Item to enqueue to the DicomPatient chained List
 */
-void gdcmDicomDir::AddDicomDirPatientToEnd(ListTag::iterator begin,ListTag::iterator end)
+void gdcmDicomDir::AddDicomDirPatientToEnd(gdcmSQItem *s)
 {
-   patients.push_back(new gdcmDicomDirPatient(begin,end,&tagHT, &listEntries));
+   patients.push_back(new gdcmDicomDirPatient(s, &tagHT));
 }
 
 /**
  * \ingroup gdcmDicomDir
  * \brief  AddDicomDirStudyToEnd 
- * @param   begin iterator on the first HeaderEntry within the chained List
- * @param   end iterator on the last HeaderEntry within the chained List
+ * @param   s SQ Item to enqueue to the DicomDirStudy chained List
  */
- void gdcmDicomDir::AddDicomDirStudyToEnd(ListTag::iterator begin,ListTag::iterator end)
+ void gdcmDicomDir::AddDicomDirStudyToEnd(gdcmSQItem *s)
 {
    if(patients.size()>0)
    {
       ListDicomDirPatient::iterator itp=patients.end();
       itp--;
-     (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(begin,end,&tagHT, &listEntries));
+     (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(s, &tagHT));
    }
 }
 /**
  * \ingroup gdcmDicomDir
  * \brief  AddDicomDirSerieToEnd 
- * @param   begin iterator on the first HeaderEntry within the chained List
- * @param   end iterator on the last HeaderEntry within the chained List
+ * @param   s SQ Item to enqueue to the DicomDirSerie chained List
  */
-void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterator end)
+void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s)
 {
    if(patients.size()>0)
    {
@@ -703,7 +805,7 @@ void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterat
       {
          ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
          itst--;
-        (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(begin,end,&tagHT, &listEntries));
+        (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(s, &tagHT));
       }
    }
 }
@@ -711,10 +813,9 @@ void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterat
 /**
  * \ingroup gdcmDicomDir
  * \brief   AddDicomDirImageToEnd
- * @param   begin iterator on the first HeaderEntry within the chained List
- * @param   end iterator on the last HeaderEntry within the chained List
+ * @param   s SQ Item to enqueue to the DicomDirImage chained List
  */
- void gdcmDicomDir::AddDicomDirImageToEnd(ListTag::iterator begin,ListTag::iterator end)
+ void gdcmDicomDir::AddDicomDirImageToEnd(gdcmSQItem *s)
 {
    if(patients.size()>0)
    {
@@ -730,7 +831,7 @@ void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterat
          {
             ListDicomDirSerie::iterator its=(*itst)->GetDicomDirSeries().end();
             its--;
-           (*its)->AddDicomDirImage(new gdcmDicomDirImage(begin,end,&tagHT, &listEntries));
+           (*its)->AddDicomDirImage(new gdcmDicomDirImage(s, &tagHT));
          }
       }
    }
@@ -754,7 +855,6 @@ void gdcmDicomDir::SetElements(std::string &path, ListHeader &list)
 
    SetElement(path,GDCM_DICOMDIR_META,NULL);
 
-   ListTag::iterator debPat=listEntries.begin();
    for(ListHeader::iterator it=list.begin();it!=list.end();++it) 
    {
       // get the current file characteristics
@@ -788,117 +888,6 @@ void gdcmDicomDir::SetElements(std::string &path, ListHeader &list)
    }
 }
 
-/**
- * \ingroup gdcmDicomDir
- * \brief   adds to the HTable and at the end of the Chained List
- *          the gdcmEntries (Dicom Elements) corresponding to the given type
- * @param   path full path file name(only used when type = GDCM_DICOMDIR_IMAGE
- * @param   type gdcmObject type to create (GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
- * @param   header gdcmHeader of the current file
- */
-void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader *header)
-{
-   std::list<gdcmElement> elemList;
-   std::list<gdcmElement>::iterator it;
-   guint16 tmpGr, tmpEl;
-   gdcmDictEntry *dictEntry;
-   gdcmHeaderEntry *entry;
-   std::string val;
-
-   switch(type)
-   {
-      case GDCM_DICOMDIR_PATIENT:
-         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
-         break;
-      case GDCM_DICOMDIR_STUDY:
-         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
-         break;
-      case GDCM_DICOMDIR_SERIE:
-         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
-         break;
-      case GDCM_DICOMDIR_IMAGE:
-         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
-         break;
-      case GDCM_DICOMDIR_META:
-         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
-         break;
-      default:
-         return;
-   }
-
-   for(it=elemList.begin();it!=elemList.end();++it)
-   {
-      tmpGr=it->group;
-      tmpEl=it->elem;
-      dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
-      entry=new gdcmHeaderEntry(dictEntry);
-      entry->SetOffset(0); // just to avoid missprinting
-
-      if(header)
-         val=header->GetEntryByNumber(tmpGr,tmpEl);
-      else
-         val=GDCM_UNFOUND;
-
-      if(val==GDCM_UNFOUND) 
-      {
-         if((tmpGr==0x0004) &&(tmpEl==0x1130) ) // File-set ID
-         {      
-          // force to the *end* File Name
-           val=GetName(path);              
-         }
-         else if( (tmpGr==0x0004) && (tmpEl==0x1500) ) // Only used for image
-         {
-            if(header->GetFileName().substr(0,path.length())!=path)
-            {
-               dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path of file name is incorrect");
-               val=header->GetFileName();
-            }
-            else {
-               val=&(header->GetFileName().c_str()[path.length()]);
-           }   
-         }
-         else
-         {
-            val=it->value;
-         }
-      } 
-      else
-      {
-         if (header->GetEntryLengthByNumber(tmpGr,tmpEl)== 0)
-           val=it->value;
-      }
-            
-      entry->SetValue(val);
-
-      if(dictEntry)
-      {
-         if(dictEntry->GetGroup()==0xfffe) 
-        {
-            entry->SetLength(entry->GetValue().length());       
-        }
-        else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) 
-         {
-            entry->SetLength(4);
-         } 
-         else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") ) 
-         {
-            entry->SetLength(2); 
-         } 
-         else if(dictEntry->GetVR()=="SQ") 
-         {
-            entry->SetLength(0xffffffff);
-         }
-         else
-         {
-            entry->SetLength(entry->GetValue().length());       
-         }
-      }
-      //AddHeaderEntry(entry); // both in H Table and in chained list
-      tagHT.insert( PairHT( entry->GetKey(),entry) );
-      listEntries.push_back(entry);  
-      //wasUpdated = 1;        // is private
-   }     
-}
 /**
  * \ingroup gdcmDicomDir
  * \brief   compares two dgcmHeaders
@@ -914,6 +903,11 @@ bool gdcmDicomDir::HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2)
  */
 
 void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() {
+
+// FIXME : to go on compiling
+
+// to be re written !
+/*
    int offset = 0;
    ListTag::iterator it;
    guint16 gr, el;
@@ -934,6 +928,7 @@ void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() {
    //bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
         SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
    return;
+   */
 }
 
 //-----------------------------------------------------------------------------
index d2d024872f9012dbde776e727fb91d2f2c8ed632..40bf6100ed1d9079c92ddefbe5fc75a2273b8fc7 100644 (file)
@@ -24,7 +24,7 @@ typedef GDCM_EXPORT void(gdcmMethod)(void * = NULL);
  * \brief    gdcmDicomDir defines an object representing a DICOMDIR in memory.
  *
  */
-class GDCM_EXPORT gdcmDicomDir: public gdcmParser
+class GDCM_EXPORT gdcmDicomDir: public gdcmDocument
 {
 public:
 //   gdcmDicomDir(ListTag *l,
@@ -37,14 +37,14 @@ public:
    ~gdcmDicomDir(void);
 
    /**
-    * \ingroup gdcmParser
+    * \ingroup gdcmDicomDir
     * \brief   Sets the print level for the Dicom Header 
     * \note    0 for Light Print; 1 for 'medium' Print, 2 for Heavy
     */
    void SetPrintLevel(int level) 
       { printLevel = level; };
   /**
-    * \ingroup gdcmParser
+    * \ingroup gdcmDicomDir
     * \brief   canonical Printer 
     * \sa    SetPrintLevel
   */     
@@ -52,22 +52,17 @@ public:
 
 // Informations contained in the parser
    virtual bool IsReadable(void);
-/**
- * \ingroup gdcmDicomDir
- * \brief   returns a pointer to the gdcmDicomDirMeta for this DICOMDIR.
- */   
+
+/// \brief   returns a pointer to the gdcmDicomDirMeta for this DICOMDIR. 
    inline gdcmDicomDirMeta   *GetDicomDirMeta()      
       {return metaElems;};
-/**
- * \ingroup gdcmDicomDir
- * \brief   returns the PATIENT chained List for this DICOMDIR.
- */      
+
+ /// \brief   returns the PATIENT chained List for this DICOMDIR.    
    inline ListDicomDirPatient &GetDicomDirPatients() 
       {return patients;};
 
 // Parsing
    void ParseDirectory(void);
-   void CheckBoundaries(void);
    
    void SetStartMethod(gdcmMethod *,void * =NULL,gdcmMethod * =NULL);
    void SetStartMethodArgDelete(gdcmMethod *);
@@ -75,24 +70,21 @@ public:
    void SetProgressMethodArgDelete(gdcmMethod *);
    void SetEndMethod(gdcmMethod *,void * =NULL,gdcmMethod * =NULL);
    void SetEndMethodArgDelete(gdcmMethod *);
-/**
- * \ingroup gdcmDicomDir
- * \brief   GetProgress.
- */ 
+
+/// \brief GetProgress GetProgress
    inline float GetProgress(void)  
       {return(progress);};
-/**
- * \ingroup gdcmDicomDir
- * \brief   AbortProgress.
- */   inline void  AbortProgress(void)
+
+/// \brief AbortProgress AbortProgress
+   inline void  AbortProgress(void)
       {abort=true;      };
-/**
- * \ingroup gdcmDicomDir
- * \brief   IsAborted.
- */   inline bool  IsAborted(void)
+
+/// \brief IsAborted IsAborted
+      inline bool  IsAborted(void)
       {return(abort);   };
    
 // Adding
+  gdcmDicomDirMeta *    NewMeta(void);
   gdcmDicomDirPatient * NewPatient(void);
 
 // Write
@@ -119,13 +111,12 @@ protected:
 
 private:
    void CreateDicomDir(void);
-   void AddObjectToEnd(gdcmDicomDirType type,
-                                ListTag::iterator begin,ListTag::iterator end);
-   void AddDicomDirMetaToEnd   (ListTag::iterator begin,ListTag::iterator end);
-   void AddDicomDirPatientToEnd(ListTag::iterator begin,ListTag::iterator end);
-   void AddDicomDirStudyToEnd  (ListTag::iterator begin,ListTag::iterator end);
-   void AddDicomDirSerieToEnd  (ListTag::iterator begin,ListTag::iterator end);
-   void AddDicomDirImageToEnd  (ListTag::iterator begin,ListTag::iterator end);
+//   void AddObjectToEnd(gdcmDicomDirType type, gdcmSQItem *s);
+   void AddDicomDirMeta   ();
+   void AddDicomDirPatientToEnd(gdcmSQItem *s);
+   void AddDicomDirStudyToEnd  (gdcmSQItem *s);
+   void AddDicomDirSerieToEnd  (gdcmSQItem *s);
+   void AddDicomDirImageToEnd  (gdcmSQItem *s);
 
    void SetElements(std::string &path,ListHeader &list);
    void SetElement (std::string &path,gdcmDicomDirType type,gdcmHeader *header);
@@ -135,13 +126,11 @@ private:
    static bool HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2);
    
 // Variables
-/**
-* \brief pointer on *the* gdcmObject 'DicomDirMeta Elements'
-*/
+
+/// \brief pointer on *the* gdcmObject 'DicomDirMeta Elements'
    gdcmDicomDirMeta *metaElems;
-/**
-* \brief chained list of DicomDirPatient (to be exploited recursively)
-*/   
+
+/// \brief chained list of DicomDirPatient (to be exploited recursively) 
    ListDicomDirPatient patients;
 
 /// pointer to the initialisation method for any progress bar   
index c9fd47b76a04ca6a6d827d0bf5a35fc372b81350..a8905981bc6e7102c4b1025bfa937399a490a578 100644 (file)
@@ -1,32 +1,27 @@
 // gdcmDicomDirImage.cxx
 //-----------------------------------------------------------------------------
 #include "gdcmDicomDirImage.h"
-
+#include "gdcmValEntry.h"
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 
 /**
  * \ingroup gdcmDicomDirImage
  * \brief  Constructor 
- * @param  begin  iterator (inside the gdcmParser chained list)
- *                on the first Header Entry (i.e Dicom Element)
- *                related to this "IMAGE" part
- * @param  end  iterator  (inside the gdcmParser chained list)
- *              on the last Header Entry (i.e Dicom Element) 
- *              related to this 'IMAGE' part
+ * @param  s  SQ Item holdoing the elements
  * @param ptagHT pointer to the HTable (gdcmObject needs it 
- *               to build the gdcmHeaderEntries)
- * @param plistEntries pointer to the chained List (gdcmObject needs it 
- *               to build the gdcmHeaderEntries)
+ *               to build the gdcmDocEntries)
  */
-gdcmDicomDirImage::gdcmDicomDirImage(ListTag::iterator begin,
-                                     ListTag::iterator end,
-                                     TagHeaderEntryHT *ptagHT, 
-                                    ListTag *plistEntries):
-   gdcmObject(begin,end,ptagHT,plistEntries)
+gdcmDicomDirImage::gdcmDicomDirImage(gdcmSQItem *s, TagDocEntryHT *ptagHT):
+   gdcmObject(ptagHT)
 {
+   docEntries = s->GetDocEntries();
 }
 
+gdcmDicomDirImage::gdcmDicomDirImage(TagDocEntryHT *ptagHT):
+   gdcmObject(ptagHT)
+{
+}
 /**
  * \ingroup gdcmDicomDirImage
  * \brief   Canonical destructor.
@@ -45,10 +40,10 @@ gdcmDicomDirImage::~gdcmDicomDirImage()
 void gdcmDicomDirImage::Print(std::ostream &os)
 {
    os<<"IMAGE : ";
-   for(ListTag::iterator i=beginObj;i!=endObj;++i)
+   for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i)
    {
       if( ((*i)->GetGroup()==0x0004) && ((*i)->GetElement()==0x1500) )
-         os<<(*i)->GetValue();
+         os<<((gdcmValEntry *)(*i))->GetValue();
    }
    os<<std::endl;
 
index 719c36842f62774298aa0d478fe1c893983e65c6..e2d74927adde3c06b0af98ca75625710a7f9981e 100644 (file)
@@ -8,8 +8,8 @@
 //-----------------------------------------------------------------------------
 class GDCM_EXPORT gdcmDicomDirImage : public gdcmObject {
 public:
-   gdcmDicomDirImage(ListTag::iterator begin,ListTag::iterator end,
-              TagHeaderEntryHT *ptagHT, ListTag *plistEntries); 
+   gdcmDicomDirImage(gdcmSQItem *s, TagDocEntryHT *ptagHT); 
+   gdcmDicomDirImage(TagDocEntryHT *ptagHT); 
 
    ~gdcmDicomDirImage(void);
 
index 3d62dc360e98e0b1efed5905670dbf791130e9fd..9a017cac190734902385c7a9dd4a07a630fd8754 100644 (file)
@@ -1,6 +1,7 @@
 // gdcmDicomDirMeta.h
 //-----------------------------------------------------------------------------
 #include "gdcmDicomDirMeta.h"
+#include "gdcmDocument.h"
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
@@ -8,23 +9,11 @@
 /**
  * \ingroup gdcmMeta
  * \brief  Constructor
- * @param  begin  iterator (inside the gdcmParser chained list)
- *                on the first Header Entry (i.e Dicom Element)
- *                related to the "META" part
- * @param  end  iterator  (inside the gdcmParser chained list)
- *              on the last Header Entry (i.e Dicom Element) 
- *              related to the 'META' part
- * @param ptagHT pointer to the HTable (gdcmObject needs it 
- *               to build the gdcmHeaderEntries)
- * @param plistEntries pointer to the chained List (gdcmObject needs it 
- *               to build the gdcmHeaderEntries)
  */ 
-gdcmDicomDirMeta::gdcmDicomDirMeta(ListTag::iterator begin,
-                                   ListTag::iterator end,
-                                  TagHeaderEntryHT *ptagHT, 
-                                  ListTag *plistEntries):
-   gdcmObject(begin,end,ptagHT,plistEntries)
+gdcmDicomDirMeta::gdcmDicomDirMeta(TagDocEntryHT *ptagHT):
+   gdcmObject(ptagHT)
 {
+
 }
 
 /**
@@ -33,6 +22,7 @@ gdcmDicomDirMeta::gdcmDicomDirMeta(ListTag::iterator begin,
  */
 gdcmDicomDirMeta::~gdcmDicomDirMeta() 
 {
+   
 }
 
 //-----------------------------------------------------------------------------
index c343719326881ffbf2b82b8e4ef8938f452246cb..eef83e02a1e2983717ab6b044803ab76e19f6347 100644 (file)
@@ -9,8 +9,7 @@
 class GDCM_EXPORT gdcmDicomDirMeta : public gdcmObject 
 {
 public:
-   gdcmDicomDirMeta(ListTag::iterator begin,ListTag::iterator end,
-                    TagHeaderEntryHT *ptagHT, ListTag *plistEntries); 
+   gdcmDicomDirMeta(TagDocEntryHT *ptagHT); 
 
    ~gdcmDicomDirMeta(void);
 
index 50f80ddc32e7ea48a95d675e1c945beeeb74d02f..33ae75b94f4b49d48789b20200f548e947b19ca7 100644 (file)
@@ -9,25 +9,20 @@
 /**
  * \ingroup gdcmDicomDirPatient
  * \brief   Constructor
- * @param  begin  iterator (inside the gdcmParser chained list)
- *                on the first Header Entry (i.e Dicom Element)
- *                related to this "PATIENT" part
- * @param  end  iterator  (inside the gdcmParser chained list)
- *              on the last Header Entry (i.e Dicom Element) 
- *              related to this 'PATIENT' part
+ * @param  s SQ Item holding the elements related to this "PATIENT" part
  * @param ptagHT pointer to the HTable (gdcmObject needs it 
  *               to build the gdcmHeaderEntries)
- * @param plistEntries pointer to the chained List (gdcmObject needs it 
- *               to build the gdcmHeaderEntries)
  */
-gdcmDicomDirPatient::gdcmDicomDirPatient(ListTag::iterator begin,
-                                         ListTag::iterator end,
-                                         TagHeaderEntryHT *ptagHT, 
-                                         ListTag *plistEntries):
-   gdcmObject(begin,end,ptagHT,plistEntries)
+gdcmDicomDirPatient::gdcmDicomDirPatient(gdcmSQItem *s, TagDocEntryHT *ptagHT):
+   gdcmObject(ptagHT)
 {
+   docEntries = s->GetDocEntries();
 }
 
+gdcmDicomDirPatient::gdcmDicomDirPatient(TagDocEntryHT *ptagHT):
+   gdcmObject(ptagHT)
+{
+}
 /**
  * \ingroup gdcmDicomDirPatient
  * \brief   Canonical destructor.
@@ -71,8 +66,9 @@ gdcmDicomDirStudy * gdcmDicomDirPatient::NewStudy(void) {
    std::list<gdcmElement> elemList;   
    elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
       
-   FillObject(elemList);
-   gdcmDicomDirStudy *st = new gdcmDicomDirStudy(i, j, ptagHT, plistEntries);
+   gdcmDicomDirStudy *st = new gdcmDicomDirStudy( ptagHT);
+   st->FillObject(elemList);
+
    studies.push_front(st);
    return st; 
 
index 3569e5055a7a131210b7e83a866feb4a9aec4c52..87c039bdea25d90e023a722c2c3bd0e4e6216742 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "gdcmObject.h"
 #include "gdcmDicomDirStudy.h"
-
+#include "gdcmSQItem.h"
 //-----------------------------------------------------------------------------
 typedef std::list<gdcmDicomDirStudy *> ListDicomDirStudy;
 
@@ -13,8 +13,9 @@ typedef std::list<gdcmDicomDirStudy *> ListDicomDirStudy;
 class GDCM_EXPORT gdcmDicomDirPatient : public gdcmObject 
 {
 public:
-   gdcmDicomDirPatient(ListTag::iterator begin,ListTag::iterator end,
-              TagHeaderEntryHT *ptagHT, ListTag *plistEntries); 
+   gdcmDicomDirPatient(gdcmSQItem *s, TagDocEntryHT *ptagHT); 
+   gdcmDicomDirPatient(TagDocEntryHT *ptagHT); 
+
    ~gdcmDicomDirPatient(void);
 
    virtual void Print(std::ostream &os = std::cout);
index 1272df3cfb88c61c0a50da666a0cc08d67c4a19c..f632168cee5452aef7c872b6755a2bb3fac99fdc 100644 (file)
@@ -8,25 +8,19 @@
 // Constructor / Destructor
 /**
  * \brief  Constructor 
- * @param  begin  iterator (inside the gdcmParser chained list)
- *                on the first Header Entry (i.e Dicom Element)
- *                related to this "SERIE" part
- * @param  end  iterator  (inside the gdcmParser chained list)
- *              on the last Header Entry (i.e Dicom Element) 
- *              related to this 'SERIE' part
+ * @param  s  SQ Item holding the elements related to this "SERIE" part
  * @param ptagHT pointer to the HTable (gdcmObject needs it 
- *               to build the gdcmHeaderEntries)
- * @param plistEntries pointer to the chained List (gdcmObject needs it 
- *               to build the gdcmHeaderEntries)
+ *               to build the gdcmDocEntries)
  */
-gdcmDicomDirSerie::gdcmDicomDirSerie(ListTag::iterator begin,
-                                     ListTag::iterator end,              
-                                     TagHeaderEntryHT *ptagHT, 
-                                     ListTag *plistEntries ):
-   gdcmObject(begin,end,ptagHT,plistEntries)
+gdcmDicomDirSerie::gdcmDicomDirSerie(gdcmSQItem *s, TagDocEntryHT *ptagHT):
+   gdcmObject(ptagHT)
+{
+   docEntries = s->GetDocEntries();
+}
+gdcmDicomDirSerie::gdcmDicomDirSerie(TagDocEntryHT *ptagHT):
+   gdcmObject(ptagHT)
 {
 }
-
 /**
  * \brief   Canonical destructor.
  */
@@ -65,8 +59,8 @@ gdcmDicomDirImage * gdcmDicomDirSerie::NewImage(void) {
    std::list<gdcmElement> elemList;   
    elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
       
+   gdcmDicomDirImage *st = new gdcmDicomDirImage(ptagHT);
    FillObject(elemList);
-   gdcmDicomDirImage *st = new gdcmDicomDirImage(i, j, ptagHT, plistEntries);
    images.push_front(st);
    return st;   
 } 
index d9df59fd0cf43dad823bad8d9f6e442414970276..c009dc081f5f69dec16f051120c52517d13db356 100644 (file)
@@ -13,8 +13,8 @@ typedef std::list<gdcmDicomDirImage *> ListDicomDirImage;
 class GDCM_EXPORT gdcmDicomDirSerie : public gdcmObject 
 {
 public:
-   gdcmDicomDirSerie(ListTag::iterator begin,ListTag::iterator end,
-              TagHeaderEntryHT *ptagHT, ListTag *plistEntries); 
+   gdcmDicomDirSerie(gdcmSQItem *s, TagDocEntryHT *ptagHT); 
+   gdcmDicomDirSerie(TagDocEntryHT *ptagHT); 
    ~gdcmDicomDirSerie(void);
 
    virtual void Print(std::ostream &os = std::cout);
index f6509abb380ef41a4cbb06ffd1616d7b47d9160b..df6b97ca8aa69e2ffb545621cab7f3394b061c3e 100644 (file)
@@ -9,25 +9,20 @@
 /**
  * \ingroup gdcmDicomDirStudy
  * \brief constructor  
- * @param  begin  iterator (inside the gdcmParser chained list)
- *                on the first Header Entry (i.e Dicom Element)
- *                related to this "STUDY" part
- * @param  end  iterator  (inside the gdcmParser chained list)
- *              on the last Header Entry (i.e Dicom Element) 
- *              related to this 'STUDY' part
+ * @param  s SQ Item holding the elements related to this "STUDY" part
  * @param ptagHT pointer to the HTable (gdcmObject needs it 
  *               to build the gdcmHeaderEntries)
- * @param plistEntries pointer to the chained List (gdcmObject needs it 
- *               to build the gdcmHeaderEntries)
  */
-gdcmDicomDirStudy::gdcmDicomDirStudy(ListTag::iterator begin,
-                                     ListTag::iterator end,
-                                     TagHeaderEntryHT *ptagHT, 
-                                     ListTag *plistEntries):
-   gdcmObject(begin,end,ptagHT,plistEntries)
+gdcmDicomDirStudy::gdcmDicomDirStudy(gdcmSQItem *s, TagDocEntryHT *ptagHT):
+   gdcmObject(ptagHT)
 {
+   docEntries = s->GetDocEntries();
 }
 
+gdcmDicomDirStudy::gdcmDicomDirStudy(TagDocEntryHT *ptagHT):
+   gdcmObject(ptagHT)
+{
+}
 /**
  * \ingroup gdcmDicomDirStudy
  * \brief   Canonical destructor.
@@ -72,8 +67,8 @@ gdcmDicomDirSerie * gdcmDicomDirStudy::NewSerie(void) {
    std::list<gdcmElement> elemList;
    elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();   
 
+   gdcmDicomDirSerie *st = new gdcmDicomDirSerie(ptagHT);
    FillObject(elemList);
-   gdcmDicomDirSerie *st = new gdcmDicomDirSerie(i, j, ptagHT, plistEntries);
    series.push_front(st);
    return st;  
 }   
index 91b24d562e26fcd1ad898ccd147ef0380e050951..75dbfa862bf158e1caf7df15d37280adfe511991 100644 (file)
@@ -12,8 +12,8 @@ typedef std::list<gdcmDicomDirSerie *> ListDicomDirSerie;
 //-----------------------------------------------------------------------------
 class GDCM_EXPORT gdcmDicomDirStudy : public gdcmObject {
 public:
-   gdcmDicomDirStudy(ListTag::iterator begin,ListTag::iterator end,
-              TagHeaderEntryHT *ptagHT, ListTag *plistEntries); 
+   gdcmDicomDirStudy(gdcmSQItem *s, TagDocEntryHT *ptagHT); 
+   gdcmDicomDirStudy(TagDocEntryHT *ptagHT); 
 
    ~gdcmDicomDirStudy(void);
 
index e3a00ccce225bb5f5370a537021fed66ee66f0de..5f8f3ccc2536bb4eb548efe2ed4dced09dec67a3 100644 (file)
@@ -92,15 +92,9 @@ void gdcmDirList::Explore(std::string dirName,bool recursive)
    }
 
 #else
-   // None  of  these  functions  is  in  POSIX.  The functions scandir() and
-   // alphasort() are from BSD 4.3, and have been available under Linux since
-   // libc4.  Libc4 and libc5 use the more precise prototype
-
    struct dirent **namelist;
    int n=scandir(dirName.c_str(), &namelist, 0, alphasort);
 
-   //if n < 0 should raise error
-
    for (int i= 0;i < n; i++) 
    {
       fileName=namelist[i]->d_name;     
@@ -113,9 +107,7 @@ void gdcmDirList::Explore(std::string dirName,bool recursive)
       {
          this->push_back(dirName+fileName);
       }
-      free(namelist[i]);
    }
-   free(namelist);
 #endif
 }
 
index 0777c3d7c07c80cc721218171f4a2384b57ce781..bf0bd1a2d9a1e8a84a5e759afe1f912230edc02e 100644 (file)
@@ -4,7 +4,7 @@
 #include "gdcmDebug.h"
 #include "jpeg/ljpg/jpegless.h"
 
-typedef std::pair<TagHeaderEntryHT::iterator,TagHeaderEntryHT::iterator> IterHT;
+typedef std::pair<TagDocEntryHT::iterator,TagDocEntryHT::iterator> IterHT;
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
@@ -735,8 +735,8 @@ bool gdcmFile::WriteBase (std::string fileName, FileType type) {
    // the *last* of the (GrPixel, NumPixel), if many.
           
    TagKey key = gdcmDictEntry::TranslateToKey(grPixel, numPixel); 
-   TagHeaderEntryHT::iterator p2;
-   gdcmHeaderEntry *PixelElement;
+   TagDocEntryHT::iterator p2;
+   gdcmDocEntry *PixelElement;
    
    IterHT it= Header->GetEntry().equal_range(key); // get a pair of iterators first-last synonym   
 
index 8096eb16503fd2d30f4162095497756d87be819b..15bf00f665a03f86447f4d6f3697d4f7376edd57 100644 (file)
@@ -5,6 +5,7 @@
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
 #include "gdcmTS.h"
+#include "gdcmValEntry.h"
 
 #include <vector>
 
@@ -23,14 +24,14 @@ gdcmHeader::gdcmHeader(const char *InFilename,
                        bool exception_on_error,
                        bool enable_sequences, 
                        bool ignore_shadow):
-   gdcmParser(InFilename,exception_on_error,enable_sequences,ignore_shadow)
+   gdcmDocument(InFilename,exception_on_error,enable_sequences,ignore_shadow)
 { 
-
+/*
    typedef struct {
       guint32 totalSQlength;
       guint32 alreadyParsedlength;
    } pileElem;
-
+*/
    
    // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010
    // We may encounter the 'RETired' (0x0028, 0x0200) tag
@@ -57,120 +58,7 @@ gdcmHeader::gdcmHeader(const char *InFilename,
       NumPixel = 0x1010;
    else
       NumPixel = 0x0010;
-
-   TagKey key = gdcmDictEntry::TranslateToKey(GrPixel, NumPixel);
-   countGrPixel = GetEntry().count(key);
-      
-   // we set the SQ Depth of each Header Entry
-   
-   int top =-1;
-   int countSQ = 0;      
-   pileElem pile[100]; // Hope embedded sequence depth is no that long !
-
-   int currentParsedlength = 0;
-   int totalElementlength;
-   std::ostringstream tab; 
-   tab << "   ";
-   
-   // GDCM_DEBUG
-   // Sorry; Dealing with e-film breaker images
-   // will (certainly) cause a lot of troubles ...
-   // I prefer keeping my 'trace' on .            
    
-   for (ListTag::iterator i = listEntries.begin();  
-      i != listEntries.end();
-      ++i) {
-         (*i)->SetSQDepthLevel(countSQ);
-         if ( (*i)->GetVR() == "SQ" && (*i)->GetReadLength() != 0) {   // SQ found         
-            countSQ++;
-            top ++;     
-            if ( top >= 20) {
-#ifdef GDCM_DEBUG
-               std::cout << "Kaie ! Kaie! SQ Stack Overflow" << std::endl;
-#endif //GDCM_DEBUG
-               return;
-            }
-#ifdef GDCM_DEBUG
-            std::cout << "\n >>>>> empile niveau " << top 
-               << "; Lgr SeQ: " << (*i)->GetReadLength() 
-               << "\n" <<std::endl;
-#endif //GDCM_DEBUG
-
-            pile[top].totalSQlength = (*i)->GetReadLength();
-            pile[top].alreadyParsedlength = 0; 
-            currentParsedlength = 0;                  
-
-         } else {  // non SQ found
-         if (countSQ != 0) { // we are 'inside a SeQuence'
-            if ( (*i)->GetGroup()==0xfffe  && (*i)->GetElement()==0xe0dd) {
-               // we just found 'end of SeQuence'
-
-#ifdef GDCM_DEBUG
-               std::cout << "fffe,e0dd : depile" << std::endl;
-#endif //GDCM_DEBUG
-
-               currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2                                    
-               countSQ --;
-               top --; 
-               pile[top].alreadyParsedlength +=  currentParsedlength;
-            } else {
-               // we are on a 'standard' elem
-               // or a Zero-length SeQuence
-
-               totalElementlength =  (*i)->GetFullLength();           
-               currentParsedlength += totalElementlength;                               
-               pile[top].alreadyParsedlength += totalElementlength;
-
-               if (pile[top].totalSQlength == 0xffffffff) {
-#ifdef GDCM_DEBUG
-                  std::cout << "totalSeQlength == 0xffffffff" << std::endl; 
-#endif //GDCM_DEBUG
-               } else {
-#ifdef GDCM_DEBUG
-                  std::cout << "alrdyPseLgt:"
-                   << pile[top].alreadyParsedlength << " totSeQlgt: " 
-                   << pile[top].totalSQlength << " curPseLgt: " 
-                   << currentParsedlength
-                   << std::endl;
-#endif //GDCM_DEBUG
-                  while (pile[top].alreadyParsedlength==pile[top].totalSQlength) {
-#ifdef GDCM_DEBUG
-                  std::cout << " \n<<<<<< On depile niveau " << top 
-                     << " \n" <<  std::endl;
-#endif //GDCM_DEBUG
-                  (*i)->SetSQDepthLevel(countSQ);                   
-                  currentParsedlength = pile[top].alreadyParsedlength;
-                  countSQ --;
-                  top --;
-                  if (top >=0) {
-                     pile[top].alreadyParsedlength +=  currentParsedlength +12;
-                     // 12 : length of 'SQ embedded' SQ element
-                     currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2
-
-#ifdef GDCM_DEBUG
-                     std::cout << pile[top].alreadyParsedlength << " " 
-                       << pile[top].totalSQlength << " " 
-                       << currentParsedlength
-                       << std::endl;
-#endif //GDCM_DEBUG
-                  }
-                  if (top == -1) {
-                     currentParsedlength = 0;
-                     break;
-                  }
-               }
-            }                          
-         }              
-      }   // end : 'inside a SeQuence'   
-   } 
-#ifdef GDCM_DEBUG
-   for (int k=0; k<(*i)->GetSQDepthLevel();k++) {
-      std::cout << tab;
-   }
-   (*i)->SetPrintLevel(2);
-   (*i)->Print();
-#endif //GDCM_DEBUG
-   } // end for        
 }
 
 /**
@@ -178,7 +66,7 @@ gdcmHeader::gdcmHeader(const char *InFilename,
  * @param exception_on_error whether we want to throw an exception or not
  */
 gdcmHeader::gdcmHeader(bool exception_on_error) :
-   gdcmParser(exception_on_error)
+   gdcmDocument(exception_on_error)
 {
 }
 
@@ -203,18 +91,22 @@ gdcmHeader::~gdcmHeader (void) {
   */ 
 void gdcmHeader::PrintEntryNoSQ(std::ostream & os) {
 
+// FIXME : Is it of any use, now?
+
+/*
    int depth;
    for (ListTag::iterator i = listEntries.begin();  
         i != listEntries.end();
         ++i)
    {
       depth= (*i)->GetSQDepthLevel();
-      if ( depth != 0 /*|| (*i)->GetVR() =="SQ" */){
+      if ( depth != 0 ){
          continue;
       }
       (*i)->SetPrintLevel(printLevel);
       (*i)->Print(os); 
    } 
+ */
 }
 
 /**
@@ -225,7 +117,9 @@ void gdcmHeader::PrintEntryNoSQ(std::ostream & os) {
   * \warning : will be removed
   * @return
   */ 
-void gdcmHeader::PrintEntryNiceSQ(std::ostream & os) {    
+void gdcmHeader::PrintEntryNiceSQ(std::ostream & os) {
+
+/*        
    std::ostringstream tab; 
    tab << "   ";
 
@@ -241,7 +135,9 @@ void gdcmHeader::PrintEntryNiceSQ(std::ostream & os) {
       (*i)->SetPrintLevel(printLevel);
       (*i)->Print(os);
              
-   } // end for     
+   } // end for 
+   
+   */    
 }
 
 //-----------------------------------------------------------------------------
@@ -257,19 +153,19 @@ void gdcmHeader::PrintEntryNiceSQ(std::ostream & os) {
  *         false otherwise. 
  */
 bool gdcmHeader::IsReadable(void) {
-   if(!gdcmParser::IsReadable()) {
+   if(!gdcmDocument::IsReadable()) {
       return(false);
    }
    std::string res = GetEntryByNumber(0x0028, 0x0005);
    if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) 
       return false; // Image Dimensions
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0100) )
+   if ( !GetDocEntryByNumber(0x0028, 0x0100) )
       return false; // "Bits Allocated"
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0101) )
+   if ( !GetDocEntryByNumber(0x0028, 0x0101) )
       return false; // "Bits Stored"
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0102) )
+   if ( !GetDocEntryByNumber(0x0028, 0x0102) )
       return false; // "High Bit"
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0103) )
+   if ( !GetDocEntryByNumber(0x0028, 0x0103) )
       return false; // "Pixel Representation" i.e. 'Sign'
    return true;
 }
@@ -281,12 +177,12 @@ bool gdcmHeader::IsReadable(void) {
  * @return  True when JPEGBaseLineProcess1found. False in all other cases.
  */
 bool gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
+   gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010);
    if ( !Element )
       return false;
-   LoadHeaderEntrySafe(Element);
+   LoadDocEntrySafe(Element);
 
-   std::string Transfer = Element->GetValue();
+   std::string Transfer = ((gdcmValEntry *)Element)->GetValue();
    if ( Transfer == "1.2.840.10008.1.2.4.50" )
       return true;
    return false;
@@ -299,11 +195,11 @@ bool gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(void) {
  * @return  True when JPEGExtendedProcess2-4 found. False in all other cases.
  */
 bool gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
+   gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010);
    if ( !Element )
       return false;
-   LoadHeaderEntrySafe(Element);
-   return ( Element->GetValue() == "1.2.840.10008.1.2.4.51" );
+   LoadDocEntrySafe(Element);
+   return ( ((gdcmValEntry *)Element)->GetValue() == "1.2.840.10008.1.2.4.51" );
 }
 
 /**
@@ -313,12 +209,12 @@ bool gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(void) {
  * @return  True when JPEGExtendedProcess3-5 found. False in all other cases.
  */
 bool gdcmHeader::IsJPEGExtendedProcess3_5TransferSyntax(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
+   gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010);
    if ( !Element )
       return false;
-   LoadHeaderEntrySafe(Element);
+   LoadDocEntrySafe(Element);
 
-   std::string Transfer = Element->GetValue();
+   std::string Transfer = ((gdcmValEntry *)Element)->GetValue();
    if ( Transfer == "1.2.840.10008.1.2.4.52" )
       return true;
    return false;
@@ -332,12 +228,12 @@ bool gdcmHeader::IsJPEGExtendedProcess3_5TransferSyntax(void) {
  *          other cases.
  */
 bool gdcmHeader::IsJPEGSpectralSelectionProcess6_8TransferSyntax(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
+   gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010);
    if ( !Element )
       return false;
-   LoadHeaderEntrySafe(Element);
+   LoadDocEntrySafe(Element);
 
-   std::string Transfer = Element->GetValue();
+   std::string Transfer = ((gdcmValEntry *)Element)->GetValue();
    if ( Transfer == "1.2.840.10008.1.2.4.53" )
       return true;
    return false;
@@ -351,12 +247,12 @@ bool gdcmHeader::IsJPEGSpectralSelectionProcess6_8TransferSyntax(void) {
  *          other cases.
  */
 bool gdcmHeader::IsRLELossLessTransferSyntax(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
+   gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010);
    if ( !Element )
       return false;
-   LoadHeaderEntrySafe(Element);
+   LoadDocEntrySafe(Element);
 
-   std::string Transfer = Element->GetValue();
+   std::string Transfer = ((gdcmValEntry *)Element)->GetValue();
    if ( Transfer == "1.2.840.10008.1.2.5" ) {
       return true;
     }
@@ -371,16 +267,18 @@ bool gdcmHeader::IsRLELossLessTransferSyntax(void) {
  *          other cases. 
  */
 bool gdcmHeader::IsJPEGLossless(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
+   gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010);
     // faire qq chose d'intelligent a la place de Ã§a
    if ( !Element )
       return false;
-   LoadHeaderEntrySafe(Element);
+   LoadDocEntrySafe(Element);
 
-   const char * Transfert = Element->GetValue().c_str();
+   const char * Transfert = ((gdcmValEntry *)Element)->GetValue().c_str();
+   
    if ( memcmp(Transfert+strlen(Transfert)-2 ,"70",2)==0) return true;
    if ( memcmp(Transfert+strlen(Transfert)-2 ,"55",2)==0) return true;
-   if (Element->GetValue() == "1.2.840.10008.1.2.4.57")   return true;
+   
+   if (((gdcmValEntry *)Element)->GetValue() == "1.2.840.10008.1.2.4.57")   return true;
 
    return false;
 }
@@ -393,12 +291,12 @@ bool gdcmHeader::IsJPEGLossless(void) {
  *          other cases.
  */
 bool gdcmHeader::IsJPEG2000(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
+   gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010);
    if ( !Element )
       return false;
-   LoadHeaderEntrySafe(Element);
+   LoadDocEntrySafe(Element);
 
-   std::string Transfer = Element->GetValue();
+   std::string Transfer = ((gdcmValEntry *)Element)->GetValue();
    if (    (Transfer == "1.2.840.10008.1.2.4.90") 
         || (Transfer == "1.2.840.10008.1.2.4.91") )
       return true;
@@ -415,7 +313,7 @@ bool gdcmHeader::IsDicomV3(void) {
    // Anyway, it's to late check if the 'Preamble' was found ...
    // And ... would it be a rich idea to check ?
    // (some 'no Preamble' DICOM images exist !)
-   return (GetHeaderEntryByNumber(0x0002, 0x0010) != NULL);
+   return (GetDocEntryByNumber(0x0002, 0x0010) != NULL);
 }
 
 /**
@@ -601,26 +499,9 @@ std::string gdcmHeader::GetPixelType(void) {
  * @return Pixel Offset
  */
 size_t gdcmHeader::GetPixelOffset(void) { 
-   //
-   // If the element (0x0088,0x0200) 'icone image sequence' is found
-   // (grPixel,numPixel) is stored twice : the first one for the icon
-   // the second one for the image ...
-   // pb : sometimes , (0x0088,0x0200) exists, but doesn't contain *anything*
-   // see gdcmData/MxTwinLossLess.dcm ...
-
-   /**
-    * \todo Clean me
-    *std::string icone = GetEntryByNumber(0x0088,0x0200); //icone image sequence
-    */
       
-   IterHT it = GetHeaderEntrySameNumber(GrPixel,NumPixel);          
-   TagKey key = gdcmDictEntry::TranslateToKey(GrPixel,NumPixel);
-   gdcmHeaderEntry* PixelElement;
-   if (countGrPixel == 1)   
-      PixelElement = (it.first)->second;
-   else {
-      PixelElement = (++it.first)->second; // hope there are no more than 2 !
-   } 
+   gdcmDocEntry* PixelElement = GetDocEntryByNumber(GrPixel,NumPixel);
    if (PixelElement) {
       return PixelElement->GetOffset();
    } else {
@@ -643,14 +524,7 @@ size_t gdcmHeader::GetPixelOffset(void) {
  */
 size_t gdcmHeader::GetPixelAreaLength(void) { 
           
-   IterHT it = GetHeaderEntrySameNumber(GrPixel,NumPixel);          
-   TagKey key = gdcmDictEntry::TranslateToKey(GrPixel,NumPixel);
-   gdcmHeaderEntry* PixelElement;
-  
-  if (countGrPixel==1)  
-      PixelElement = (it.first)->second;
-   else
-      PixelElement = (++it.first)->second;
+   gdcmDocEntry* PixelElement = GetDocEntryByNumber(GrPixel,NumPixel);
 
    if (PixelElement) {
       return PixelElement->GetLength();
@@ -677,22 +551,22 @@ bool gdcmHeader::HasLUT(void) {
 
    // Check the presence of the LUT Descriptors, and LUT Tables    
    // LutDescriptorRed    
-   if ( !GetHeaderEntryByNumber(0x0028,0x1101) )
+   if ( !GetDocEntryByNumber(0x0028,0x1101) )
       return false;
    // LutDescriptorGreen 
-   if ( !GetHeaderEntryByNumber(0x0028,0x1102) )
+   if ( !GetDocEntryByNumber(0x0028,0x1102) )
       return false;
    // LutDescriptorBlue 
-   if ( !GetHeaderEntryByNumber(0x0028,0x1103) )
+   if ( !GetDocEntryByNumber(0x0028,0x1103) )
       return false;   
    // Red Palette Color Lookup Table Data
-   if ( !GetHeaderEntryByNumber(0x0028,0x1201) )
+   if ( !GetDocEntryByNumber(0x0028,0x1201) )
       return false; 
    // Green Palette Color Lookup Table Data       
-   if ( !GetHeaderEntryByNumber(0x0028,0x1202) )
+   if ( !GetDocEntryByNumber(0x0028,0x1202) )
       return false;
    // Blue Palette Color Lookup Table Data      
-   if ( !GetHeaderEntryByNumber(0x0028,0x1203) )
+   if ( !GetDocEntryByNumber(0x0028,0x1203) )
       return false;
    // FIXME : (0x0028,0x3006) : LUT Data (CTX dependent)
    //         NOT taken into account, but we don't know how to use it ...   
@@ -889,11 +763,11 @@ void gdcmHeader::SetImageDataSize(size_t ImageDataSize) {
    std::string content1;
    char car[20];
 
-   // Assumes HeaderEntry (GrPixel, NumPixel) is unique ...   
+   // Assumes DocEntry (GrPixel, NumPixel) is unique ...   
    //\todo deal with multiplicity (see gdcmData/icone.dcm)
    sprintf(car,"%d",ImageDataSize);
  
-   gdcmHeaderEntry *a = GetHeaderEntryByNumber(GrPixel, NumPixel);
+   gdcmDocEntry *a = GetDocEntryByNumber(GrPixel, NumPixel);
    a->SetLength(ImageDataSize);
 
    ImageDataSize+=8;
@@ -955,7 +829,7 @@ void gdcmHeader::SetImageDataSize(size_t ImageDataSize) {
    return(false);
 }
 
-bool gdcmHeader::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type)
+bool gdcmHeader::WriteEntry(gdcmDocEntry *tag, FILE *_fp,FileType type)
 {
    guint32 length = tag->GetLength();
                                                                                 
@@ -963,7 +837,7 @@ bool gdcmHeader::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type)
    // bytes. When this is not the case, pad with an additional byte:
    if(length%2==1)
    {
-      tag->SetValue(tag->GetValue()+"\0");
+  //    tag->SetValue(tag->GetValue()+"\0"); // to go on compiling
       tag->SetLength(tag->GetReadLength()+1);
    }
                                                                                 
@@ -995,8 +869,8 @@ bool gdcmHeader::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type)
  */
 bool gdcmHeader::anonymizeHeader() {
 
-  gdcmHeaderEntry *patientNameHE = GetHeaderEntryByNumber (0x0010, 0x0010);
- // gdcmHeaderEntry *patientIDHE   = GetHeaderEntryByNumber (0x0010, 0x0020); 
+  gdcmDocEntry *patientNameHE = GetDocEntryByNumber (0x0010, 0x0010);
+ // gdcmDocEntry *patientIDHE   = GetDocEntryByNumber (0x0010, 0x0020); 
     
   ReplaceIfExistByNumber ("  ",0x0010, 0x2154); // Telephone   
   ReplaceIfExistByNumber ("  ",0x0010, 0x1040); // Adress
index 3d8564140d646e4667f2b6484dabee3427d903b1..a6a861c16595082b4a6bdb9232e54e8602932ab0 100644 (file)
@@ -4,8 +4,8 @@
 #define GDCMHEADER_H
 
 #include "gdcmCommon.h"
-#include "gdcmParser.h"
-
+//#include "gdcmParser.h"
+#include "gdcmDocument.h"
 //-----------------------------------------------------------------------------
 /**
  * \brief
@@ -26,7 +26,7 @@
  *        protected due to Swig limitations for as Has_a dependency between
  *        gdcmFile and gdcmHeader.
  */
-class GDCM_EXPORT gdcmHeader : public gdcmParser
+class GDCM_EXPORT gdcmHeader : public gdcmDocument
 {
 protected:
    /// In some cases (e.g. for some ACR-NEMA images) the Header Entry Element
@@ -110,40 +110,40 @@ public:
 //       there are protected in the parent class
 
    inline virtual std::string GetEntryByNumber  (guint16 group, guint16 element)
-      { return(gdcmParser::GetEntryByNumber(group,element)); }
+      { return(gdcmDocument::GetEntryByNumber(group,element)); }
       
    inline virtual std::string GetEntryVRByNumber(guint16 group, guint16 element)
-      { return(gdcmParser::GetEntryVRByNumber(group,element)); }
+      { return(gdcmDocument::GetEntryVRByNumber(group,element)); }
       
    inline virtual int GetEntryLengthByNumber(guint16 group, guint16 element)
-      { return(gdcmParser::GetEntryLengthByNumber(group,element)); }
+      { return(gdcmDocument::GetEntryLengthByNumber(group,element)); }
       
    inline virtual std::string GetEntryByName    (std::string tagName) 
-      { return(gdcmParser::GetEntryByName(tagName)); }
+      { return(gdcmDocument::GetEntryByName(tagName)); }
       
    inline virtual std::string GetEntryVRByName  (std::string tagName)
-      { return(gdcmParser::GetEntryVRByName(tagName)); }
+      { return(gdcmDocument::GetEntryVRByName(tagName)); }
       
    inline virtual bool SetEntryByNumber(std::string content,
                                         guint16 group, guint16 element)
-      { return(gdcmParser::SetEntryByNumber(content,group,element)); }
+      { return(gdcmDocument::SetEntryByNumber(content,group,element)); }
       
    inline virtual bool SetEntryByName(std::string content,std::string tagName)
-      { return(gdcmParser::SetEntryByName(content,tagName)); }
+      { return(gdcmDocument::SetEntryByName(content,tagName)); }
 
   inline virtual bool SetEntryLengthByNumber(guint32 l,
                                              guint16 group, guint16 element)
-      { return(gdcmParser::SetEntryLengthByNumber(l,group,element)); }
+      { return(gdcmDocument::SetEntryLengthByNumber(l,group,element)); }
 
    inline virtual void UpdateShaEntries(void)
-      { gdcmParser::UpdateShaEntries(); }
+      { gdcmDocument::UpdateShaEntries(); }
 
    /// Read (used in gdcmFile)
    void SetImageDataSize(size_t ExpectedSize);
 
    bool operator<(gdcmHeader &header);
 
-   bool WriteEntry(gdcmHeaderEntry *tag,FILE *_fp,FileType type);
+   bool WriteEntry(gdcmDocEntry *tag,FILE *_fp,FileType type);
    
    
    virtual void PrintEntryNoSQ  (std::ostream &os = std::cout); 
index e747b3b39afe68b55b562af49d8f91214d59270a..25cba3b529467488347a2d931d5401dbc93eed43 100644 (file)
@@ -3,30 +3,24 @@
 #include "gdcmObject.h"
 #include "gdcmGlobal.h"
 #include "gdcmDebug.h"
+#include "gdcmValEntry.h"
 
 //-----------------------------------------------------------------------------
 /**
  * \ingroup gdcmObject
  * \brief  Constructor 
- * @param  begin  iterator on the first Header Entry (i.e Dicom Element)
- *                related to this 'Object'
- * @param  end  iterator on the last Header Entry 
- *              (i.e Dicom Element) related to this 'Object'             
+ *          
  * @param ptagHT pointer to the HTable (gdcmObject needs it 
- *               to build the gdcmHeaderEntries)
- * @param plistEntries pointer to the chained List (gdcmObject needs it 
- *               to build the gdcmHeaderEntries)
+ *               to build the gdcmDocEntries)
+ * @param depth Seaquence depth level
  */
-gdcmObject::gdcmObject(ListTag::iterator begin, ListTag::iterator end,
-              TagHeaderEntryHT *ptagHT, ListTag *plistEntries) {
-   beginObj = begin;
-   endObj   = end;
+  
+gdcmObject::gdcmObject(TagDocEntryHT *ptagHT, int depth) 
+          : gdcmSQItem (depth) {
    this->ptagHT = ptagHT;
-   this->plistEntries = plistEntries;
-   if(begin==end)
-      dbg.Verbose(0, "gdcmObject::gdcmObject empty list");
 }
 
+
 /**
  * \ingroup gdcmObject
  * \brief   Canonical destructor.
@@ -34,141 +28,12 @@ gdcmObject::gdcmObject(ListTag::iterator begin, ListTag::iterator end,
 gdcmObject::~gdcmObject(void) {
 }
 
-//-----------------------------------------------------------------------------
-// Print
-/**
- * \ingroup gdcmObject
- * \brief   Prints the Object
- * @return
- */ 
-void gdcmObject::Print(std::ostream &os) {
-   if(printLevel>=0) {
-      ListTag::iterator i;
-      for(i=beginObj;;++i) {
-         (*i)->SetPrintLevel(printLevel);
-         (*i)->Print(os);
-         if (i == endObj) break;
-      }
-   }
-}
+
 
 //-----------------------------------------------------------------------------
 // Public
-/**
- * \ingroup gdcmObject
- * \brief   Get the value of an Header Entries (i.e Dicom Element) by number
- * @return
- */ 
-std::string gdcmObject::GetEntryByNumber(guint16 group, guint16 element) {
-   for(ListTag::iterator i=beginObj;;++i) {
-      if ( (*i)->GetGroup()==group && (*i)->GetElement()==element)
-         return (*i)->GetValue();
-      if (i == endObj) break;  
-   }   
-   return GDCM_UNFOUND;
-}
-
-/**
- * \ingroup gdcmObject
- * \brief   Get the value of an Header Entries (i.e Dicom Element) by name
- * @param   name : name of the searched element.
- * @return
- */ 
-std::string gdcmObject::GetEntryByName(TagName name)  {
-   gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict();
-   gdcmDictEntry *dictEntry = (*PubDict).GetDictEntryByName(name); 
-
-   if( dictEntry == NULL)
-      return GDCM_UNFOUND;
-   return GetEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement()); 
-}
 
-/**
- * \ingroup gdcmObject
- * \brief   Set the 'boundaries' gdcmObject (gdcmDicomDirPatient,
- *          gdcmDicomDirStudy, gdcmDicomDirSerie, gdcmDicomDirImage)
- *          comming for the parsing of a DICOMDIR file
- * \warning NOT en user intended function
- * @param  flag = 0 when META to be dealt with
- */ 
-void gdcmObject::ResetBoundaries(int flag) {
-   
-   if (flag) { // it's NOT a META
-     // upwards to fffe,e000   
-      for( i=j=debut();
-          ((*i)->GetGroup() != 0xfffe)  && ((*i)->GetElement() != 0xe000);
-         --i,j--) {   
-      }
-      beginObj=j;
-   }
-         
-  // upwards again to fffe,e000   
-   if (fin()== (--(plistEntries->end())) )  // Don't try anything more when end 
-       return;                              // of Chained List is reached   
-                                           
-   for( i=j=fin();
-        ((*i)->GetGroup() != 0xfffe)  && ((*i)->GetElement() != 0xe000);
-       --i,j--) {          
-   }
-   j--;
-   endObj=j;    
-}
 
-/**
- * \brief   Sets Entry (Dicom Element) value of an element,
- *          specified by it's tag (Group, Number) 
- *          and the length, too ...
- *          If the Element is not found, it's just created !
- * \warning we suppose, right now, the element belongs to a Public Group
- *          (NOT a shadow one)       
- * @param   val string value to set
- * @param   group Group of the searched tag.
- * @param   element Element of the searched tag.
- * @return  true if element was found or created successfully
- */
- bool gdcmObject::SetEntryByNumber(std::string val,guint16 group, 
-                                                  guint16 element) {
-
-   for(ListTag::iterator i=beginObj;;++i) { 
-      if ( (*i)->GetGroup() == 0xfffe && (*i)->GetElement() == 0xe000 ) 
-         continue;
-      if ( group   < (*i)->GetGroup() || 
-           (group == (*i)->GetGroup() && element < (*i)->GetElement()) ){
-        // instead of ReplaceOrCreateByNumber 
-        // that is a method of gdcmParser :-( 
-         gdcmHeaderEntry *Entry;
-         TagKey key = gdcmDictEntry::TranslateToKey(group, element);
-         if ( ! ptagHT->count(key)) {
-          // we assume a Public Dictionnary *is* loaded
-           gdcmDict *PubDict         = gdcmGlobal::GetDicts()->GetDefaultPubDict();
-           // if the invoked (group,elem) doesn't exist inside the Dictionary
-          // we create a VirtualDictEntry
-           gdcmDictEntry *DictEntry  = PubDict->GetDictEntryByNumber(group, element);
-          if (DictEntry == NULL) {
-             DictEntry=gdcmGlobal::GetDicts()->NewVirtualDictEntry(group,element,"UN","??","??");
-          } 
-           // we assume the constructor didn't fail
-           Entry = new gdcmHeaderEntry(DictEntry);
-          /// \todo
-          /// ----
-          /// better we don't assume too much !
-          /// in the next release, gdcmObject will be used 
-          /// to describe any Header Entry ...
-         } else {
-            Entry = ptagHT->find(key)->second;
-         }
-         Entry->SetValue(val); 
-         Entry->SetLength(val.length());
-         plistEntries->insert(i,Entry); 
-        return true;
-      }           
-      if (group == (*i)->GetGroup() && element == (*i)->GetElement() ) {
-         (*i)->SetValue(val);
-         (*i)->SetLength(val.length()); 
-         return true;    
-      }   
-   }                                               
-}
 /**
  * \ingroup gdcmObject
  * \brief   Builds a hash table (multimap) containing 
@@ -176,11 +41,11 @@ void gdcmObject::ResetBoundaries(int flag) {
  *          related to this 'object'
  * @return
  */ 
-TagHeaderEntryHT gdcmObject::GetEntry(void) {
-   TagHeaderEntryHT HT;
-   for(ListTag::iterator i=beginObj;;++i) {
-      HT.insert( PairHT( (*i)->GetKey(),(*i)) );
-      if (i == endObj) break;      
+TagDocEntryHT gdcmObject::GetEntry(void) {
+   TagDocEntryHT HT;
+   docEntries=GetDocEntries();   
+   for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) {
+      HT[(*i)->GetKey()]=*i;
    }
    return(HT);
 }
@@ -191,16 +56,14 @@ TagHeaderEntryHT gdcmObject::GetEntry(void) {
  *          pointers to all Header Entries (i.e Dicom Element)
  *          related to this 'object'
  * @return
- */ 
+ */
+ // FIXME : what was it used for ?!?
+ /* 
 ListTag gdcmObject::GetListEntry(void) {
-   ListTag list;
-   for(ListTag::iterator i=beginObj;;++i) {
-      list.push_back(*i);
-      if (i == endObj) break;      
-   }
-   return(list);
+   return(GetDocEntries());
 }
-
+*/
 
 //-----------------------------------------------------------------------------
 // Protected
@@ -210,24 +73,28 @@ ListTag gdcmObject::GetListEntry(void) {
  *          of a partially created DICOMDIR
  */
 void gdcmObject::FillObject(std::list<gdcmElement> elemList) {
+
+  // FillObject rempli le SQItem qui sera accroche au bon endroit
+
    std::list<gdcmElement>::iterator it;
    guint16 tmpGr,tmpEl;
    gdcmDictEntry *dictEntry;
-   gdcmHeaderEntry *entry;
-      
-   debInsertion = this->fin(); 
-   ++debInsertion;
-   finInsertion=debInsertion;
+   gdcmValEntry *entry;
+   
+   //gdcmSQItem *s = new gdcmSQItem;
    
+   // for all the Elements found in they own part of the DicomDir dict.     
    for(it=elemList.begin();it!=elemList.end();++it)
    {
       tmpGr=it->group;
       tmpEl=it->elem;
       dictEntry=gdcmGlobal::GetDicts()->GetDefaultPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
-      entry=new gdcmHeaderEntry(dictEntry);
+      entry=new gdcmValEntry(dictEntry);
       entry->SetOffset(0); // just to avoid further missprinting
       entry->SetValue(it->value);
 
+      // dealing with value length ...
+  
       if(dictEntry->GetGroup()==0xfffe) 
         {
             entry->SetLength(entry->GetValue().length());       
@@ -246,17 +113,11 @@ void gdcmObject::FillObject(std::list<gdcmElement> elemList) {
          }
       else
          {
-            entry->SetLength(entry->GetValue().length());       
+            entry->SetLength(entry->GetValue().length()); 
          }                                
-      ptagHT->insert( PairHT(entry->GetKey(),entry) ); // add in the (multimap) H Table
-      plistEntries->insert(debInsertion ,entry);       // add at the begining of the Patient list
-      ++finInsertion;                                     
-   }
-     
-   i=fin();
-   i++;
-   j=debInsertion;
-   j--;
+      //docEntries->insert(debInsertion ,entry); // ??? // add at the begining of the Patient list
+      AddDocEntry(entry);                                         
+   }   
 }   
 //-----------------------------------------------------------------------------
 // Private
index 7e842e0035b7c8ed4c3e90029b411503efd2dc84..67ba4737bd3773b76f910c98fe13a7f655f10b00 100644 (file)
@@ -6,9 +6,12 @@
 #include <string>
 #include <list>
 #include "gdcmCommon.h"
-#include "gdcmHeaderEntry.h"
-#include "gdcmParser.h"
+#include "gdcmDocEntry.h"
+//#include "gdcmParser.h"
+#include "gdcmDocument.h"
 #include "gdcmDicomDirElement.h"
+#include "gdcmSQItem.h"
+
 //-----------------------------------------------------------------------------
 class gdcmObject;
 typedef std::list<gdcmObject *> ListContent;
@@ -18,9 +21,10 @@ typedef std::list<gdcmObject *> ListContent;
  * \ingroup gdcmObject
  * \brief   Base object
  */
-class GDCM_EXPORT gdcmObject 
+class GDCM_EXPORT gdcmObject : public gdcmSQItem
 {
 public:
+
    /**
     * \ingroup gdcmParser
     * \brief   Sets the print level for the Dicom Header 
@@ -28,78 +32,26 @@ public:
     */
    void SetPrintLevel(int level) 
       { printLevel = level; };
-   virtual void Print(std::ostream &os = std::cout);
-
-   std::string GetEntryByNumber(guint16 group, guint16 element);
-   std::string GetEntryByName(TagName name);
+      
+  // std::string GetEntryByNumber(guint16 group, guint16 element);
+  // std::string GetEntryByName(TagName name);
    bool SetEntryByNumber(std::string val,guint16 group,guint16 element);
    
-   TagHeaderEntryHT GetEntry(void);
-   ListTag GetListEntry(void);
-   
-   void ResetBoundaries(int flag);
-/**
- * \ingroup gdcmObject
- * \brief   returns an iterator on the first Header Entry (i.e Dicom Element),
- *          inside the DICOMDIR chained list,
- *          related to this 'Object' 
- * @return
- */
-   ListTag::iterator debut(void) 
-      { return(beginObj);}
-   /**
-    * \ingroup gdcmObject
-    * \brief   returns an iterator on the last Header Entry (i.e Dicom Element),
-    *          inside the DICOMDIR chained list,
-    *          related to this 'Object' 
-    * @return
-    */
-    ListTag::iterator fin  (void) 
-       { return(endObj);  }
+   TagDocEntryHT GetEntry(void);
+   void FillObject(std::list<gdcmElement> elemList);
 
 protected:
+
  // constructor and destructor are protected to avoid end user to instanciate this class.
-   gdcmObject(ListTag::iterator begin,ListTag::iterator end,
-              TagHeaderEntryHT *ptagHT, ListTag *plistEntries); 
+   gdcmObject(TagDocEntryHT *ptagHT, int depth = 0);
    virtual ~gdcmObject(void);
 
-   void FillObject(std::list<gdcmElement> elemList);
+// variables :
 
-/**
-* \brief iterator on the first Header Entry (i.e Dicom Element), 
-*       inside the DICOMDIR chained list,
-*       related to this 'Object'
-*/   
-   ListTag::iterator beginObj;
-/**
-* \brief iterator on the last Header Entry (i.e Dicom Element), 
-*       inside the DICOMDIR chained list,
-*       related to this 'Object'
-*/
-   ListTag::iterator endObj;
-/**
-* \brief pointer to the HTable of the gdcmParser,
-*        (because we don't know it within any gdcmObject) 
-*/
-  TagHeaderEntryHT *ptagHT;
-/**
-* \brief pointer to the Chained List of the gdcmParser,
-*        (because we don't know it within any gdcmObject)  
-*/  
-   ListTag *plistEntries;
-/**
-* \brief detail level to be printed
-*/   
+///\brief detail level to be printed 
    int printLevel;
-   
-   /**
-   * \brief used to pass variables to FillObject function
-   *        Works as 'global' variable
-   */
-   std::list<gdcmHeaderEntry *>::iterator debInsertion, finInsertion, i,j;
 
 private:
-
 };
 
 //-----------------------------------------------------------------------------