]> Creatis software - gdcm.git/commitdiff
Replace confusing names gdcmImage, etc by gdcmDicomDirImage etc, to avoid
authorjpr <jpr>
Fri, 20 Feb 2004 17:31:31 +0000 (17:31 +0000)
committerjpr <jpr>
Fri, 20 Feb 2004 17:31:31 +0000 (17:31 +0000)
messing up the users

24 files changed:
src/CMakeLists.txt
src/Makefile.am
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDicomDirElement.cxx
src/gdcmDicomDirElement.h
src/gdcmDicomDirImage.cxx [moved from src/gdcmImage.cxx with 79% similarity]
src/gdcmDicomDirImage.h [moved from src/gdcmImage.h with 59% similarity]
src/gdcmDicomDirMeta.cxx [moved from src/gdcmMeta.cxx with 75% similarity]
src/gdcmDicomDirMeta.h [moved from src/gdcmMeta.h with 59% similarity]
src/gdcmDicomDirPatient.cxx [moved from src/gdcmPatient.cxx with 67% similarity]
src/gdcmDicomDirPatient.h [moved from src/gdcmPatient.h with 51% similarity]
src/gdcmDicomDirSerie.cxx [moved from src/gdcmSerie.cxx with 68% similarity]
src/gdcmDicomDirSerie.h [new file with mode: 0644]
src/gdcmDicomDirStudy.cxx [moved from src/gdcmStudy.cxx with 68% similarity]
src/gdcmDicomDirStudy.h [new file with mode: 0644]
src/gdcmDict.cxx
src/gdcmHeader.cxx
src/gdcmHeader.h
src/gdcmParser.cxx
src/gdcmParser.h
src/gdcmSerie.h
src/gdcmStudy.h [deleted file]
src/gdcmUtil.cxx

index 4db41ba88294a9fc98c0664f08c95b310e534a75..715d901bd67c8ac65c74348a25fa89cf435f01c4 100644 (file)
@@ -10,11 +10,12 @@ INCLUDE_DIRECTORIES(
 )\r
 \r
 SET(libgdcm_la_SOURCES\r
-       gdcmDicomDir.cxx\r
-       gdcmDicomDirElement.cxx\r
-       gdcmDict.cxx\r
-       gdcmDictEntry.cxx\r
-       gdcmDictSet.cxx\r
+\r
+   gdcmDicomDir.cxx\r
+   gdcmDicomDirElement.cxx\r
+   gdcmDict.cxx\r
+   gdcmDictEntry.cxx\r
+   gdcmDictSet.cxx\r
    gdcmDirList.cxx\r
    gdcmException.cxx\r
    gdcmFile.cxx\r
index da2a82241c7fd20d5a788798dee1a1975166728a..26911da7a79a25f8af40d03541e3046ac82eb71c 100644 (file)
@@ -10,11 +10,16 @@ CXXFLAGS = @CXXFLAGS@ -DPUB_DICT_PATH=\"$(datadir)/gdcm/\" \
 libgdcm_la_LIBADD = \
    $(top_builddir)/src/jpeg/libijg12/libgdcmijpeg12.la  \
    $(top_builddir)/src/jpeg/libijg8/libgdcmijpeg8.la    \
-   $(top_builddir)/src/jpeg/ljpg/libgdcmjpg.la 
+   $(top_builddir)/src/jpeg/ljpg/libgdcmjpg.la
 
 libgdcm_la_SOURCES=                \
    gdcmDicomDir.cxx                \
    gdcmDicomDirElement.cxx         \
+   gdcmDicomDirImage.cxx           \
+   gdcmDicomDirMeta.cxx            \
+   gdcmDicomDirPatient.cxx         \
+   gdcmDicomDirSerie.cxx           \
+   gdcmDicomDirStudy.cxx           \
    gdcmDict.cxx                    \
    gdcmDictEntry.cxx               \
    gdcmDictSet.cxx                 \
@@ -24,18 +29,13 @@ libgdcm_la_SOURCES=                \
    gdcmHeader.cxx                  \
    gdcmHeaderEntry.cxx             \
    gdcmHeaderHelper.cxx            \
-   gdcmImage.cxx                   \
-   gdcmMeta.cxx                    \
    gdcmJpeg12.cxx                  \
    gdcmJpeg2000.cxx                \
    gdcmJpeg.cxx                    \
    gdcmObject.cxx                  \
    gdcmParsePixels.cxx             \
    gdcmParser.cxx                  \
-   gdcmPatient.cxx                 \
    gdcmRLE.cxx                     \
-   gdcmSerie.cxx                   \
-   gdcmStudy.cxx                   \
    gdcmTS.cxx                      \
    gdcmUtil.cxx                    \
    gdcmVR.cxx
@@ -46,7 +46,12 @@ libgdcminclude_HEADERS =                \
        gdcmCommon.h                    \
        gdcmDicomDir.h                  \
         gdcmDicomDirElement.h           \
-       gdcmDictEntry.h                 \
+       gdcmDicomDirImage.h             \
+        gdcmDicomDirMeta.h              \
+       gdcmDicomDirPatient.h           \
+       gdcmDicomDirSerie.h             \
+       gdcmDicomDirStudy.h             \
+        gdcmDictEntry.h                 \
        gdcmDict.h                      \
        gdcmDictSet.h                   \
        gdcmDirList.h                   \
@@ -56,17 +61,11 @@ libgdcminclude_HEADERS =                \
        gdcmHeaderEntry.h               \
        gdcmHeader.h                    \
        gdcmHeaderHelper.h              \
-       gdcmImage.h                     \
-        gdcmMeta.h                      \
        gdcmObject.h                    \
        gdcmParser.h                    \
-       gdcmPatient.h                   \
-       gdcmSerie.h                     \
-       gdcmStudy.h                     \
        gdcmVR.h                        \
        gdcmTS.h
 
-
 EXTRA_DIST =   \
-       gdcmUtil.h      
+       gdcmUtil.h
 
index ac19e312329ae57b164a51df277ea3e471b7b21e..145ce1e8e9eca39607c99680a26a1616323bef69 100644 (file)
@@ -1,9 +1,9 @@
 // gdcmDicomDir.cxx
 //-----------------------------------------------------------------------------
 #include "gdcmDicomDir.h"
-#include "gdcmStudy.h"
-#include "gdcmSerie.h"
-#include "gdcmImage.h"
+#include "gdcmDicomDirStudy.h"
+#include "gdcmDicomDirSerie.h"
+#include "gdcmDicomDirImage.h"
 #include "gdcmDirList.h"
 #include "gdcmUtil.h"
 
 // Constructor / Destructor
 /*
  * \ingroup gdcmDicomDir
- * \brief   Constructor
- * @param   Filename
+ * \brief   Constructor : Parses recursively the directory and creates the DicomDir
+ * \                      or uses an already built DICOMDIR, depending on 'parseDir' value
+ * @param   Name          name of the root directory (parseDir = true)
+ *                        name of the DICOMDIR       (parseDir = false)
+ * @param   parseDir      true if user wants to explore the directories
  * @param   exception_on_error
  */
-gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
+gdcmDicomDir::gdcmDicomDir(const char *Name, bool parseDir,
                            bool exception_on_error):
-   gdcmParser(FileName,exception_on_error,true)
+   gdcmParser(Name,exception_on_error,true)
 {
-   startMethod=NULL;
-   progressMethod=NULL;
-   endMethod=NULL;
-   startMethodArgDelete=NULL;
+   startMethod=            NULL;
+   progressMethod=         NULL;
+   endMethod=              NULL;
+   startMethodArgDelete=   NULL;
    progressMethodArgDelete=NULL;
-   endMethodArgDelete=NULL;
-   startArg=NULL;
-   progressArg=NULL;
-   endArg=NULL;
+   endMethodArgDelete=     NULL;
+   startArg=               NULL;
+   progressArg=            NULL;
+   endArg=                 NULL;
 
-   progress=NULL;
+   progress=0.0;
    abort=false;
 
    metaElems=NULL;
@@ -70,7 +73,7 @@ gdcmDicomDir::~gdcmDicomDir()
    if(metaElems)
       delete metaElems;
    
-   for(ListPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
+   for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
    {
       delete *cc;
    }
@@ -90,7 +93,7 @@ void gdcmDicomDir::Print(std::ostream &os)
       metaElems->Print(os);   
    }
    
-   for(ListPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
+   for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
    {
      (*cc)->SetPrintLevel(printLevel);
      (*cc)->Print(os);
@@ -240,8 +243,8 @@ bool gdcmDicomDir::Write(std::string fileName)
    filePreamble=(char*)calloc(128,1);
    fwrite(filePreamble,128,1,fp1);
    fwrite("DICM",4,1,fp1);
-   free(filePreamble);
-
+   free(filePreamble);        
+   UpdateDirectoryRecordSequenceLength();
    WriteEntries(fp1,DICOMDIR);
 
    fclose(fp1);
@@ -348,7 +351,7 @@ void gdcmDicomDir::CreateDicomDir()
    //       + we create the object for the precedent tag
    //       + loop to 1 -
 
-   gdcmDicomDirType type=gdcmDicomDir::GDCM_META;
+   gdcmDicomDirType type=gdcmDicomDir::GDCM_DICOMDIR_META;
    ListTag::iterator begin;
    ListTag::iterator end;
 
@@ -362,7 +365,7 @@ void gdcmDicomDir::CreateDicomDir()
          end=i;
          AddObjectToEnd(type,begin,end);
 
-         type=gdcmDicomDir::GDCM_PATIENT;
+         type=gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
          begin=end;
       }        
 
@@ -371,7 +374,7 @@ void gdcmDicomDir::CreateDicomDir()
          end=i;
          AddObjectToEnd(type,begin,end);
 
-         type=gdcmDicomDir::GDCM_STUDY;
+         type=gdcmDicomDir::GDCM_DICOMDIR_STUDY;
          begin=end;
       }
 
@@ -380,7 +383,7 @@ void gdcmDicomDir::CreateDicomDir()
          end=i;
          AddObjectToEnd(type,begin,end);
 
-         type=gdcmDicomDir::GDCM_SERIE;
+         type=gdcmDicomDir::GDCM_DICOMDIR_SERIE;
          begin=end;
       }
 
@@ -389,7 +392,7 @@ void gdcmDicomDir::CreateDicomDir()
          end=i;
          AddObjectToEnd(type,begin,end);
 
-         type=gdcmDicomDir::GDCM_IMAGE;
+         type=gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
          begin=end;
       }
    }
@@ -412,20 +415,20 @@ void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,
 
    switch(type)
    {
-      case gdcmDicomDir::GDCM_META:
-         AddMetaToEnd(begin,end);
+      case gdcmDicomDir::GDCM_DICOMDIR_META:
+         AddDicomDirMetaToEnd(begin,end);
          break;      
-      case gdcmDicomDir::GDCM_PATIENT:
-         AddPatientToEnd(begin,end);
+      case gdcmDicomDir::GDCM_DICOMDIR_PATIENT:
+         AddDicomDirPatientToEnd(begin,end);
          break;
-      case gdcmDicomDir::GDCM_STUDY:
-         AddStudyToEnd(begin,end);
+      case gdcmDicomDir::GDCM_DICOMDIR_STUDY:
+         AddDicomDirStudyToEnd(begin,end);
          break;
-      case gdcmDicomDir::GDCM_SERIE:
-         AddSerieToEnd(begin,end);
+      case gdcmDicomDir::GDCM_DICOMDIR_SERIE:
+         AddDicomDirSerieToEnd(begin,end);
          break;
-      case gdcmDicomDir::GDCM_IMAGE:
-         AddImageToEnd(begin,end);
+      case gdcmDicomDir::GDCM_DICOMDIR_IMAGE:
+         AddDicomDirImageToEnd(begin,end);
          break;
    }
 }
@@ -436,11 +439,11 @@ void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,
  * @param   begin
  * @param   end
 */
-void gdcmDicomDir::AddMetaToEnd(ListTag::iterator begin,ListTag::iterator end)
+void gdcmDicomDir::AddDicomDirMetaToEnd(ListTag::iterator begin,ListTag::iterator end)
 {
    if(metaElems)
       delete metaElems;
-   metaElems = new gdcmMeta(begin,end);
+   metaElems = new gdcmDicomDirMeta(begin,end);
 }
 
 /*
@@ -449,9 +452,9 @@ void gdcmDicomDir::AddMetaToEnd(ListTag::iterator begin,ListTag::iterator end)
  * @param   begin
  * @param   end
 */
-void gdcmDicomDir::AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end)
+void gdcmDicomDir::AddDicomDirPatientToEnd(ListTag::iterator begin,ListTag::iterator end)
 {
-   patients.push_back(new gdcmPatient(begin,end));
+   patients.push_back(new gdcmDicomDirPatient(begin,end));
 }
 
 /*
@@ -460,13 +463,13 @@ void gdcmDicomDir::AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end
  * @param   begin
  * @param   end
  */
- void gdcmDicomDir::AddStudyToEnd(ListTag::iterator begin,ListTag::iterator end)
+ void gdcmDicomDir::AddDicomDirStudyToEnd(ListTag::iterator begin,ListTag::iterator end)
 {
    if(patients.size()>0)
    {
-      ListPatient::iterator itp=patients.end();
+      ListDicomDirPatient::iterator itp=patients.end();
       itp--;
-     (*itp)->AddStudy(new gdcmStudy(begin,end));
+     (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(begin,end));
    }
 }
 /*
@@ -475,18 +478,18 @@ void gdcmDicomDir::AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end
  * @param   begin
  * @param   end
  */
-void gdcmDicomDir::AddSerieToEnd(ListTag::iterator begin,ListTag::iterator end)
+void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterator end)
 {
    if(patients.size()>0)
    {
-      ListPatient::iterator itp=patients.end();
+      ListDicomDirPatient::iterator itp=patients.end();
       itp--;
 
-      if((*itp)->GetStudies().size()>0)
+      if((*itp)->GetDicomDirStudies().size()>0)
       {
-         ListStudy::iterator itst=(*itp)->GetStudies().end();
+         ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
          itst--;
-        (*itst)->AddSerie(new gdcmSerie(begin,end));
+        (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(begin,end));
       }
    }
 }
@@ -497,23 +500,23 @@ void gdcmDicomDir::AddSerieToEnd(ListTag::iterator begin,ListTag::iterator end)
  * @param   end
  * @param   
  */
- void gdcmDicomDir::AddImageToEnd(ListTag::iterator begin,ListTag::iterator end)
+ void gdcmDicomDir::AddDicomDirImageToEnd(ListTag::iterator begin,ListTag::iterator end)
 {
    if(patients.size()>0)
    {
-      ListPatient::iterator itp=patients.end();
+      ListDicomDirPatient::iterator itp=patients.end();
       itp--;
 
-      if((*itp)->GetStudies().size()>0)
+      if((*itp)->GetDicomDirStudies().size()>0)
       {
-         ListStudy::iterator itst=(*itp)->GetStudies().end();
+         ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
          itst--;
 
-         if((*itst)->GetSeries().size()>0)
+         if((*itst)->GetDicomDirSeries().size()>0)
          {
-            ListSerie::iterator its=(*itst)->GetSeries().end();
+            ListDicomDirSerie::iterator its=(*itst)->GetDicomDirSeries().end();
             its--;
-           (*its)->AddImage(new gdcmImage(begin,end));
+           (*its)->AddDicomDirImage(new gdcmDicomDirImage(begin,end));
          }
       }
    }
@@ -527,47 +530,47 @@ void gdcmDicomDir::AddSerieToEnd(ListTag::iterator begin,ListTag::iterator end)
  */
 void gdcmDicomDir::SetElements(std::string &path,ListHeader &list)
 {
-   std::string patPrevName="", patPrevID="";
+   std::string patPrevName="",         patPrevID="";
    std::string studPrevInstanceUID="", studPrevID="";
-   std::string serPrevInstanceUID="", serPrevID="";
+   std::string serPrevInstanceUID="",  serPrevID="";
 
-   std::string patCurName, patCurID;
+   std::string patCurName,         patCurID;
    std::string studCurInstanceUID, studCurID;
-   std::string serCurInstanceUID, serCurID;
+   std::string serCurInstanceUID,  serCurID;
 
-   SetElement(path,GDCM_NONE,NULL);
+   SetElement(path,GDCM_DICOMDIR_NONE,NULL);
 
    ListTag::iterator debPat=listEntries.begin();
    for(ListHeader::iterator it=list.begin();it!=list.end();++it) 
    {
       // get the current file characteristics
-      patCurName=(*it)->GetEntryByNumber(0x0010,0x0010); 
-      patCurID=(*it)->GetEntryByNumber(0x0010,0x0011); 
+      patCurName=        (*it)->GetEntryByNumber(0x0010,0x0010); 
+      patCurID=          (*it)->GetEntryByNumber(0x0010,0x0011); 
       studCurInstanceUID=(*it)->GetEntryByNumber(0x0020,0x000d);            
-      studCurID=(*it)->GetEntryByNumber(0x0020,0x0010);            
-      serCurInstanceUID=(*it)->GetEntryByNumber(0x0020,0x000e);            
-      serCurID=(*it)->GetEntryByNumber(0x0020,0x0011);
+      studCurID=         (*it)->GetEntryByNumber(0x0020,0x0010);            
+      serCurInstanceUID= (*it)->GetEntryByNumber(0x0020,0x000e);            
+      serCurID=          (*it)->GetEntryByNumber(0x0020,0x0011);
 
       if(patCurName!=patPrevName || patCurID!=patPrevID) 
-         SetElement(path,GDCM_PATIENT,*it);
+         SetElement(path,GDCM_DICOMDIR_PATIENT,*it);
 
       // if new Study Deal with 'STUDY' Elements   
       if(studCurInstanceUID!=studPrevInstanceUID || studCurID!=studPrevID) 
-         SetElement(path,GDCM_STUDY,*it);
+         SetElement(path,GDCM_DICOMDIR_STUDY,*it);
 
       // if new Serie Deal with 'SERIE' Elements   
       if(serCurInstanceUID!=serPrevInstanceUID || serCurID!=serPrevID) 
-         SetElement(path,GDCM_SERIE,*it);
+         SetElement(path,GDCM_DICOMDIR_SERIE,*it);
       
       // Always Deal with 'IMAGE' Elements  
-      SetElement(path,GDCM_IMAGE,*it);
+      SetElement(path,GDCM_DICOMDIR_IMAGE,*it);
 
-      patPrevName=patCurName;
-      patPrevID=patCurID;
+      patPrevName=        patCurName;
+      patPrevID=          patCurID;
       studPrevInstanceUID=studCurInstanceUID;
-      studPrevID=studCurID;
-      serPrevInstanceUID=serCurInstanceUID;
-      serPrevID=serCurID;
+      studPrevID=         studCurID;
+      serPrevInstanceUID= serCurInstanceUID;
+      serPrevID=          serCurID;
    }
 }
 
@@ -589,20 +592,20 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader
 
    switch(type)
    {
-      case GDCM_PATIENT:
-         elemList=gdcmGlobal::GetDicomDirElements()->GetPatientElements();
+      case GDCM_DICOMDIR_PATIENT:
+         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
          break;
-      case GDCM_STUDY:
-         elemList=gdcmGlobal::GetDicomDirElements()->GetStudyElements();
+      case GDCM_DICOMDIR_STUDY:
+         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
          break;
-      case GDCM_SERIE:
-         elemList=gdcmGlobal::GetDicomDirElements()->GetSerieElements();
+      case GDCM_DICOMDIR_SERIE:
+         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
          break;
-      case GDCM_IMAGE:
-         elemList=gdcmGlobal::GetDicomDirElements()->GetImageElements();
+      case GDCM_DICOMDIR_IMAGE:
+         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
          break;
-      case GDCM_NONE:
-         elemList=gdcmGlobal::GetDicomDirElements()->GetMetaElements();
+      case GDCM_DICOMDIR_NONE:
+         elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
          break;
       default:
          return;
@@ -643,12 +646,22 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader
          {
             val=it->value;
          }
+      } 
+      else
+      {
+         if (header->GetEntryLengthByNumber(tmpGr,tmpEl)== 0)
+           val=val=it->value;
       }
+            
       entry->SetValue(val);
 
       if(dictEntry)
       {
-         if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) 
+         if(dictEntry->GetGroup()==0xfffe) 
+        {
+            entry->SetLength(entry->GetValue().length()); //JPR                 
+        }
+        else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) 
          {
             entry->SetLength(4);
          } 
@@ -665,8 +678,8 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader
             entry->SetLength(entry->GetValue().length());       
          }
       }
-
-      listEntries.push_back(entry);
+      //listEntries.push_back(entry);
+      AddHeaderEntry(entry);   
    }     
 }
 
@@ -675,4 +688,28 @@ bool gdcmDicomDir::HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2)
    return(*header1<*header2);
 }
 
+
+
+void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() {
+   int offset = 0;
+   ListTag::iterator it;
+   guint16 gr, el;
+   string vr;
+   for(it=listEntries.begin();it!=listEntries.end();++it) {
+      gr = (*it)->GetGroup();
+      el = (*it)->GetElement();
+      vr = (*it)->GetVR();      
+      if (gr !=0xfffe) {
+         if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) {    
+            offset +=  4; // explicit VR AND OB, OW, SQ : 4 more bytes
+         }         
+         offset += 2 + 2 + 4 + (*it)->GetLength(); 
+      } else {
+         offset +=  4; // delimiters don't have a value.     
+      }            
+   }   
+   bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
+   return;
+}
+
 //-----------------------------------------------------------------------------
index 73cf77e57d0da0ad0b03c710435765226c0cc0fe..5db25bd1eee6f4729c813b6f65d4788da5dfccc6 100644 (file)
@@ -5,18 +5,18 @@
 
 #include "gdcmHeader.h"
 #include "gdcmCommon.h"
-#include "gdcmPatient.h"
-#include "gdcmMeta.h"
+#include "gdcmDicomDirPatient.h"
+#include "gdcmDicomDirMeta.h"
 #include "gdcmDicomDirElement.h"
 
 #include <list>
 #include <vector>
 
 //-----------------------------------------------------------------------------
-typedef std::list<gdcmPatient *>   ListPatient;
+typedef std::list<gdcmDicomDirPatient *>   ListDicomDirPatient;
 typedef std::vector<gdcmHeader *>  ListHeader;
 
-typedef GDCM_EXPORT void( gdcmMethod)(void * =NULL);
+typedef GDCM_EXPORT void(gdcmMethod)(void * = NULL);
 //-----------------------------------------------------------------------------
 /*
  * \defgroup gdcmDicomDir
@@ -26,7 +26,8 @@ typedef GDCM_EXPORT void( gdcmMethod)(void * =NULL);
 class GDCM_EXPORT gdcmDicomDir: public gdcmParser
 {
 public:
-//   gdcmDicomDir(ListTag *l,         bool exception_on_error = false);
+//   gdcmDicomDir(ListTag *l,
+//                bool exception_on_error = false);
    gdcmDicomDir(const char *FileName, 
                 bool parseDir = false,
                 bool exception_on_error = false);
@@ -38,8 +39,8 @@ public:
 
 // Informations contained in the parser
    virtual bool IsReadable(void);
-   inline gdcmMeta   *GetMeta()      {return metaElems;};
-   inline ListPatient &GetPatients() {return patients;};
+   inline gdcmDicomDirMeta   *GetDicomDirMeta()      {return metaElems;};
+   inline ListDicomDirPatient &GetDicomDirPatients() {return patients;};
 
 // Parsing
    void ParseDirectory(void);
@@ -62,12 +63,12 @@ public:
 // Types
    typedef enum
    {
-      GDCM_NONE,
-      GDCM_META,
-      GDCM_PATIENT,
-      GDCM_STUDY,
-      GDCM_SERIE,
-      GDCM_IMAGE,
+      GDCM_DICOMDIR_NONE,
+      GDCM_DICOMDIR_META,
+      GDCM_DICOMDIR_PATIENT,
+      GDCM_DICOMDIR_STUDY,
+      GDCM_DICOMDIR_SERIE,
+      GDCM_DICOMDIR_IMAGE,
    } gdcmDicomDirType;
    
 protected:
@@ -82,19 +83,21 @@ private:
    void CreateDicomDir(void);
    void AddObjectToEnd(gdcmDicomDirType type,
                         ListTag::iterator begin,ListTag::iterator end);
-   void AddMetaToEnd   (ListTag::iterator begin,ListTag::iterator end);
-   void AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end);
-   void AddStudyToEnd  (ListTag::iterator begin,ListTag::iterator end);
-   void AddSerieToEnd  (ListTag::iterator begin,ListTag::iterator end);
-   void AddImageToEnd  (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 SetElements(std::string &path,ListHeader &list);
    void SetElement (std::string &path,gdcmDicomDirType type,gdcmHeader *header);
+   
+   void UpdateDirectoryRecordSequenceLength(void);
 
    static bool HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2);
 
-   gdcmMeta *metaElems;
-   ListPatient patients;
+   gdcmDicomDirMeta *metaElems;
+   ListDicomDirPatient patients;
 
    gdcmMethod *startMethod;
    gdcmMethod *progressMethod;
index 25afc82dcd1c4be3e4c53161654d51097272db32..d7197ce969d1ef5a049b2d74c8848047d2172df2 100644 (file)
          elem.value = buff;
 
          if(type=="metaElem")
-            MetaList.push_back(elem);
+             DicomDirMetaList.push_back(elem);
          else if(type=="patientElem")
-            PatientList.push_back(elem);
+            DicomDirPatientList.push_back(elem);
          else if(type=="studyElem")
-            StudyList.push_back(elem);
+            DicomDirStudyList.push_back(elem);
          else if(type=="serieElem")
-            SerieList.push_back(elem);
+            DicomDirSerieList.push_back(elem);
          else if(type=="imageElem")
-            ImageList.push_back(elem);
+            DicomDirImageList.push_back(elem);
       }
-
       from.getline(buff, 1024, '\n');
    }
    from.close();
  * \brief   destructor 
  */
  gdcmDicomDirElement::~gdcmDicomDirElement() {
-   MetaList.clear();
-   PatientList.clear();
-   StudyList.clear();
-   SerieList.clear();
-   ImageList.clear();
+   DicomDirMetaList.clear();
+   DicomDirPatientList.clear();
+   DicomDirStudyList.clear();
+   DicomDirSerieList.clear();
+   DicomDirImageList.clear();
 }
 
 //-----------------------------------------------------------------------------
@@ -95,35 +94,35 @@ void gdcmDicomDirElement::Print(std::ostream &os) {
    char greltag[10];  //group element tag
 
    s << "Meta Elements :"<<std::endl;
-   for (it = MetaList.begin();it!=MetaList.end();++it)
+   for (it = DicomDirMetaList.begin();it!=DicomDirMetaList.end();++it)
    {
       sprintf(greltag,"%04x|%04x ",it->group,it->elem);
       s << "   ("<<greltag<<") = "<< it->value<<std::endl;
    }
 
    s << "Patient Elements :"<<std::endl;
-   for (it = PatientList.begin();it!=PatientList.end();++it)
+   for (it = DicomDirPatientList.begin();it!=DicomDirPatientList.end();++it)
    {
       sprintf(greltag,"%04x|%04x ",it->group,it->elem);
       s << "   ("<<greltag<<") = "<< it->value<<std::endl;
    }
 
    s << "Study Elements :"<<std::endl;
-   for (it = StudyList.begin();it!=StudyList.end();++it)
+   for (it = DicomDirStudyList.begin();it!=DicomDirStudyList.end();++it)
    {
       sprintf(greltag,"%04x|%04x ",it->group,it->elem);
       s << "   ("<<greltag<<") = "<< it->value<<std::endl;
    }
 
    s << "Serie Elements :"<<std::endl;
-   for (it = SerieList.begin();it!=SerieList.end();++it)
+   for (it = DicomDirSerieList.begin();it!=DicomDirSerieList.end();++it)
    {
       sprintf(greltag,"%04x|%04x ",it->group,it->elem);
       s << "   ("<<greltag<<") = "<< it->value<<std::endl;
    }
 
    s << "Image Elements :"<<std::endl;
-   for (it = ImageList.begin();it!=ImageList.end();++it)
+   for (it = DicomDirImageList.begin();it!=DicomDirImageList.end();++it)
    {
       sprintf(greltag,"%04x|%04x ",it->group,it->elem);
       s << "   ("<<greltag<<") = "<< it->value<<std::endl;
index cd747093bb3c1ce29e2aeea6cc8ccd8ef15af3e3..f813bca489b0fc44793e9e282fd7b0c6626117a1 100644 (file)
@@ -15,11 +15,11 @@ typedef struct
        std::string value;
 } gdcmElement;
 
-typedef std::list<gdcmElement> ListMetaElem;
-typedef std::list<gdcmElement> ListPatientElem;
-typedef std::list<gdcmElement> ListStudyElem;
-typedef std::list<gdcmElement> ListSerieElem;
-typedef std::list<gdcmElement> ListImageElem;
+typedef std::list<gdcmElement> ListDicomDirMetaElem;
+typedef std::list<gdcmElement> ListDicomDirPatientElem;
+typedef std::list<gdcmElement> ListDicomDirStudyElem;
+typedef std::list<gdcmElement> ListDicomDirSerieElem;
+typedef std::list<gdcmElement> ListDicomDirImageElem;
 
 //-----------------------------------------------------------------------------
 /*
@@ -35,18 +35,23 @@ public:
 
    void Print(std::ostream &os);
 
-   ListMetaElem    &GetMetaElements(void)    {return(MetaList);};
-   ListPatientElem &GetPatientElements(void) {return(PatientList);};
-   ListStudyElem   &GetStudyElements(void)   {return(StudyList);};
-   ListSerieElem   &GetSerieElements(void)   {return(SerieList);};
-   ListImageElem   &GetImageElements(void)   {return(ImageList);};
+   ListDicomDirMetaElem    &GetDicomDirMetaElements(void)    
+      {return(DicomDirMetaList);};
+   ListDicomDirPatientElem &GetDicomDirPatientElements(void) 
+      {return(DicomDirPatientList);};
+   ListDicomDirStudyElem   &GetDicomDirStudyElements(void)   
+      {return(DicomDirStudyList);};
+   ListDicomDirSerieElem   &GetDicomDirSerieElements(void)   
+      {return(DicomDirSerieList);};
+   ListDicomDirImageElem   &GetDicomDirImageElements(void)   
+      {return(DicomDirImageList);};
 
 private:
-   ListMetaElem    MetaList;
-   ListPatientElem PatientList;
-   ListStudyElem   StudyList;
-   ListSerieElem   SerieList;
-   ListImageElem   ImageList;
+   ListDicomDirMetaElem    DicomDirMetaList;
+   ListDicomDirPatientElem DicomDirPatientList;
+   ListDicomDirStudyElem   DicomDirStudyList;
+   ListDicomDirSerieElem   DicomDirSerieList;
+   ListDicomDirImageElem   DicomDirImageList;
 };
 
 //-----------------------------------------------------------------------------
similarity index 79%
rename from src/gdcmImage.cxx
rename to src/gdcmDicomDirImage.cxx
index 5484f9d92bc0e4c9ced0f75d14b9ee700125891c..00a54a2018148e3c0b92d4b29b6cb987ae36575c 100644 (file)
@@ -1,16 +1,16 @@
-// gdcmImage.cxx
+// gdcmDicomDirImage.cxx
 //-----------------------------------------------------------------------------
-#include "gdcmImage.h"
+#include "gdcmDicomDirImage.h"
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 /**
- * \ingroup gdcmImage
+ * \ingroup gdcmDicomDirImage
  * \brief   
  * @param   begin iterator of begin for the object
  * @param   end   iterator of end for the object
  */
-gdcmImage::gdcmImage(ListTag::iterator begin,ListTag::iterator end):
+gdcmDicomDirImage::gdcmDicomDirImage(ListTag::iterator begin,ListTag::iterator end):
    gdcmObject(begin,end)
 {
 }
@@ -19,18 +19,18 @@ gdcmImage::gdcmImage(ListTag::iterator begin,ListTag::iterator end):
  * \ingroup gdcmImage
  * \brief   Canonical destructor.
  */
-gdcmImage::~gdcmImage() 
+gdcmDicomDirImage::~gdcmDicomDirImage() 
 {
 }
 
 //-----------------------------------------------------------------------------
 // Print
 /**
- * \ingroup gdcmImage
+ * \ingroup gdcmDicomDirImage
  * \brief   Prints the Object
  * @return
  */ 
-void gdcmImage::Print(std::ostream &os)
+void gdcmDicomDirImage::Print(std::ostream &os)
 {
    os<<"IMAGE : ";
    for(ListTag::iterator i=beginObj;i!=endObj;++i)
similarity index 59%
rename from src/gdcmImage.h
rename to src/gdcmDicomDirImage.h
index 8c7906fc587ee92972ccf16c55fde0decc33a9b2..4f1173d99c8af7f41c28b7b07fdee504643719f3 100644 (file)
@@ -1,16 +1,16 @@
-// gdcmImage.h
+// gdcmDicomDirImage.h
 //-----------------------------------------------------------------------------
-#ifndef GDCMIMAGE_H
-#define GDCMIMAGE_H
+#ifndef GDCMDICOMIMAGE_H
+#define GDCMDICOMIMAGE_H
 
 #include "gdcmObject.h"
 
 //-----------------------------------------------------------------------------
-class GDCM_EXPORT gdcmImage : public gdcmObject 
+class GDCM_EXPORT gdcmDicomDirImage : public gdcmObject 
 {
 public:
-   gdcmImage(ListTag::iterator begin,ListTag::iterator end);
-   ~gdcmImage(void);
+   gdcmDicomDirImage(ListTag::iterator begin,ListTag::iterator end);
+   ~gdcmDicomDirImage(void);
 
    virtual void Print(std::ostream &os = std::cout);
 };
similarity index 75%
rename from src/gdcmMeta.cxx
rename to src/gdcmDicomDirMeta.cxx
index a9a0aa0da7f6707a001de31fe1d031ce4ab4bb48..945847609147be8daf65a680e901b1f920acd210 100644 (file)
@@ -1,36 +1,36 @@
-// gdcmMeta.h
+// gdcmDicomDirMeta.h
 //-----------------------------------------------------------------------------
-#include "gdcmMeta.h"
+#include "gdcmDicomDirMeta.h"
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 /**
- * \ingroup gdcmMeta
+ * \ingroup gdcmDicomDirMeta
  * \brief   
  * @param   begin iterator of begin for the object
  * @param   end   iterator of end   for the object
  */
-gdcmMeta::gdcmMeta(ListTag::iterator begin,ListTag::iterator end):
+gdcmDicomDirMeta::gdcmDicomDirMeta(ListTag::iterator begin,ListTag::iterator end):
    gdcmObject(begin,end)
 {
 }
 
 /**
- * \ingroup gdcmMeta
+ * \ingroup gdcmDicomDirMeta
  * \brief   Canonical destructor.
  */
-gdcmMeta::~gdcmMeta() 
+gdcmDicomDirMeta::~gdcmDicomDirMeta() 
 {
 }
 
 //-----------------------------------------------------------------------------
 // Print
 /**
- * \ingroup gdcmMeta
+ * \ingroup gdcmDicomDirMeta
  * \brief   Prints the Object
  * @return
  */ 
-void gdcmMeta::Print(std::ostream &os)
+void gdcmDicomDirMeta::Print(std::ostream &os)
 {
    os<<"META"<<std::endl;
    gdcmObject::Print(os);
similarity index 59%
rename from src/gdcmMeta.h
rename to src/gdcmDicomDirMeta.h
index 12e42eb92ba3997e1fa6b63fb5bf6201593b9f77..abc5d010ff1d750ae7867089ea02b190dae321a7 100644 (file)
@@ -1,16 +1,16 @@
-// gdcmMeta.h
+// gdcmDicomDirMeta.h
 //-----------------------------------------------------------------------------
-#ifndef GDCMMETA_H
-#define GDCMMETA_H
+#ifndef GDCMDICOMDIRMETA_H
+#define GDCMDICOMDIRMETA_H
 
 #include "gdcmObject.h"
 
 //-----------------------------------------------------------------------------
-class GDCM_EXPORT gdcmMeta : public gdcmObject 
+class GDCM_EXPORT gdcmDicomDirMeta : public gdcmObject 
 {
 public:
-   gdcmMeta(ListTag::iterator begin,ListTag::iterator end);
-   ~gdcmMeta(void);
+   gdcmDicomDirMeta(ListTag::iterator begin,ListTag::iterator end);
+   ~gdcmDicomDirMeta(void);
 
    virtual void Print(std::ostream &os = std::cout);
 };
similarity index 67%
rename from src/gdcmPatient.cxx
rename to src/gdcmDicomDirPatient.cxx
index e7f8ed4ad1f7d20abb3b6a3ff917f10956eb6e3b..007eeaf0f9a53d6fa969cfcff265032cdaa9f4bf 100644 (file)
@@ -1,27 +1,27 @@
-// gdcmPatient.cxx
+// gdcmDicomDirPatient.cxx
 //-----------------------------------------------------------------------------
-#include "gdcmPatient.h"
+#include "gdcmDicomDirPatient.h"
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 /**
- * \ingroup gdcmPatient
+ * \ingroup gdcmDicomDirPatient
  * \brief   
  * @param   begin iterator of begin for the object
  * @param   end   iterator of end for the object
  */
-gdcmPatient::gdcmPatient(ListTag::iterator begin,ListTag::iterator end):
+gdcmDicomDirPatient::gdcmDicomDirPatient(ListTag::iterator begin,ListTag::iterator end):
    gdcmObject(begin,end)
 {
 }
 
 /**
- * \ingroup gdcmPatient
+ * \ingroup gdcmDicomDirPatient
  * \brief   Canonical destructor.
  */
-gdcmPatient::~gdcmPatient() 
+gdcmDicomDirPatient::~gdcmDicomDirPatient() 
 {
-   for(ListStudy::iterator cc = studies.begin();cc != studies.end();++cc)
+   for(ListDicomDirStudy::iterator cc = studies.begin();cc != studies.end();++cc)
    {
       delete *cc;
    }
@@ -30,16 +30,16 @@ gdcmPatient::~gdcmPatient()
 //-----------------------------------------------------------------------------
 // Print
 /**
- * \ingroup gdcmPatient
+ * \ingroup gdcmDicomDirPatient
  * \brief   Prints the Object
  * @return
  */ 
-void gdcmPatient::Print(std::ostream &os)
+void gdcmDicomDirPatient::Print(std::ostream &os)
 {
    os<<"PATIENT"<<std::endl;
    gdcmObject::Print(os);
 
-   for(ListStudy::iterator cc = studies.begin();cc!=studies.end();++cc)
+   for(ListDicomDirStudy::iterator cc = studies.begin();cc!=studies.end();++cc)
    {
       (*cc)->SetPrintLevel(printLevel);
       (*cc)->Print(os);
similarity index 51%
rename from src/gdcmPatient.h
rename to src/gdcmDicomDirPatient.h
index 2d4d1e2690c2442c8b0224703fbc8a940baa8c45..2868f42a3aa8ecf7e578b1b8ad118d663572b535 100644 (file)
@@ -1,28 +1,28 @@
-// gdcmPatient.h
+// gdcmDicomDirPatient.h
 //-----------------------------------------------------------------------------
 #ifndef GDCMPATIENT_H
 #define GDCMPATIENT_H
 
 #include "gdcmObject.h"
-#include "gdcmStudy.h"
+#include "gdcmDicomDirStudy.h"
 
 //-----------------------------------------------------------------------------
-typedef std::list<gdcmStudy *> ListStudy;
+typedef std::list<gdcmDicomDirStudy *> ListDicomDirStudy;
 
 //-----------------------------------------------------------------------------
-class GDCM_EXPORT gdcmPatient : public gdcmObject 
+class GDCM_EXPORT gdcmDicomDirPatient : public gdcmObject 
 {
 public:
-   gdcmPatient(ListTag::iterator begin,ListTag::iterator end);
-   ~gdcmPatient(void);
+   gdcmDicomDirPatient(ListTag::iterator begin,ListTag::iterator end);
+   ~gdcmDicomDirPatient(void);
 
    virtual void Print(std::ostream &os = std::cout);
 
-   inline ListStudy &GetStudies() {return studies;};
-   inline void AddStudy(gdcmStudy *obj) {studies.push_back(obj);};
+   inline ListDicomDirStudy &GetDicomDirStudies() {return studies;};
+   inline void AddDicomDirStudy(gdcmDicomDirStudy *obj) {studies.push_back(obj);};
        
 private:
-   ListStudy studies;
+   ListDicomDirStudy studies;
 };
 
 //-----------------------------------------------------------------------------
similarity index 68%
rename from src/gdcmSerie.cxx
rename to src/gdcmDicomDirSerie.cxx
index 1ad1b6fddadac81a8f367bae4785d93efee022f7..a9f2d9654bb59439416fc37cc949e0ff97b19575 100644 (file)
@@ -1,27 +1,27 @@
-// gdcmSequence.cxx
+// gdcmDicomDirSerie.cxx
 //-----------------------------------------------------------------------------
-#include "gdcmSerie.h"
+#include "gdcmDicomDirSerie.h"
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 /**
- * \ingroup gdcmSerie
+ * \ingroup gdcmDicomDirSerie
  * \brief   
  * @param   begin iterator of begin for the object
  * @param   end   iterator of end for the object
  */
-gdcmSerie::gdcmSerie(ListTag::iterator begin,ListTag::iterator end):
+gdcmDicomDirSerie::gdcmDicomDirSerie(ListTag::iterator begin,ListTag::iterator end):
    gdcmObject(begin,end)
 {
 }
 
 /**
- * \ingroup gdcmSerie
+ * \ingroup gdcmDicomDirSerie
  * \brief   Canonical destructor.
  */
-gdcmSerie::~gdcmSerie() 
+gdcmDicomDirSerie::~gdcmDicomDirSerie() 
 {
-   for(ListImage::iterator cc = images.begin();cc != images.end();++cc)
+   for(ListDicomDirImage::iterator cc = images.begin();cc != images.end();++cc)
    {
       delete *cc;
    }
@@ -30,16 +30,16 @@ gdcmSerie::~gdcmSerie()
 //-----------------------------------------------------------------------------
 // Print
 /**
- * \ingroup gdcmSerie
+ * \ingroup gdcmDicomDirSerie
  * \brief   Prints the Object
  * @return
  */ 
-void gdcmSerie::Print(std::ostream &os)
+void gdcmDicomDirSerie::Print(std::ostream &os)
 {
    os<<"SERIE"<<std::endl;
    gdcmObject::Print(os);
 
-   for(ListImage::iterator cc = images.begin();cc != images.end();++cc)
+   for(ListDicomDirImage::iterator cc = images.begin();cc != images.end();++cc)
    {
       (*cc)->SetPrintLevel(printLevel);
       (*cc)->Print(os);
diff --git a/src/gdcmDicomDirSerie.h b/src/gdcmDicomDirSerie.h
new file mode 100644 (file)
index 0000000..9554d39
--- /dev/null
@@ -0,0 +1,29 @@
+// gdcmDicomDirSerie.h
+//-----------------------------------------------------------------------------
+#ifndef GDCMDICOMDIRSERIE_H
+#define GDCMDICOMDIRSERIE_H
+
+#include "gdcmObject.h"
+#include "gdcmDicomDirImage.h"
+
+//-----------------------------------------------------------------------------
+typedef std::list<gdcmDicomDirImage *> ListDicomDirImage;
+
+//-----------------------------------------------------------------------------
+class GDCM_EXPORT gdcmDicomDirSerie : public gdcmObject 
+{
+public:
+   gdcmDicomDirSerie(ListTag::iterator begin,ListTag::iterator end);
+   ~gdcmDicomDirSerie(void);
+
+   virtual void Print(std::ostream &os = std::cout);
+
+   inline ListDicomDirImage &GetDicomDirImages() {return images;};
+   inline void AddDicomDirImage(gdcmDicomDirImage *obj) {images.push_back(obj);};
+
+private:
+   ListDicomDirImage images;
+};
+
+//-----------------------------------------------------------------------------
+#endif
similarity index 68%
rename from src/gdcmStudy.cxx
rename to src/gdcmDicomDirStudy.cxx
index d57391e27866cefdbfc20e90893b5955f2c03a55..fd8e886bbdaa8b4c07e4a87cc3036de49ac9f350 100644 (file)
@@ -1,27 +1,27 @@
-// gdcmStudy.cxx
+// gdcmDicomDirStudy.cxx
 //-----------------------------------------------------------------------------
-#include "gdcmStudy.h"
+#include "gdcmDicomDirStudy.h"
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 /**
- * \ingroup gdcmStudy
+ * \ingroup gdcmDicomDirStudy
  * \brief   
  * @param   begin iterator of begin for the object
  * @param   end   iterator of end for the object
  */
-gdcmStudy::gdcmStudy(ListTag::iterator begin,ListTag::iterator end):
+gdcmDicomDirStudy::gdcmDicomDirStudy(ListTag::iterator begin,ListTag::iterator end):
    gdcmObject(begin,end)
 {
 }
 
 /**
- * \ingroup gdcmStudy
+ * \ingroup gdcmDicomDirStudy
  * \brief   Canonical destructor.
  */
-gdcmStudy::~gdcmStudy() 
+gdcmDicomDirStudy::~gdcmDicomDirStudy() 
 {
-   for(ListSerie::iterator cc = series.begin();cc != series.end();++cc)
+   for(ListDicomDirSerie::iterator cc = series.begin();cc != series.end();++cc)
    {
       delete *cc;
    }
@@ -30,16 +30,16 @@ gdcmStudy::~gdcmStudy()
 //-----------------------------------------------------------------------------
 // Print
 /**
- * \ingroup gdcmStudy
+ * \ingroup gdcmDicomDirStudy
  * \brief   Prints the Object
  * @return
  */ 
-void gdcmStudy::Print(std::ostream &os)
+void gdcmDicomDirStudy::Print(std::ostream &os)
 {
    os<<"STUDY"<<std::endl;
    gdcmObject::Print(os);
 
-   for(ListSerie::iterator cc = series.begin();cc != series.end();++cc)
+   for(ListDicomDirSerie::iterator cc = series.begin();cc != series.end();++cc)
    {
       (*cc)->SetPrintLevel(printLevel);
       (*cc)->Print(os);
diff --git a/src/gdcmDicomDirStudy.h b/src/gdcmDicomDirStudy.h
new file mode 100644 (file)
index 0000000..4c69b7b
--- /dev/null
@@ -0,0 +1,28 @@
+// gdcmDicomDirStudy.h
+//-----------------------------------------------------------------------------
+#ifndef GDCMDICOMDIRSTUDY_H
+#define GDCMDICOMDIRSTUDY_H
+
+#include "gdcmObject.h"
+#include "gdcmDicomDirSerie.h"
+
+//-----------------------------------------------------------------------------
+typedef std::list<gdcmDicomDirSerie *> ListDicomDirSerie;
+
+//-----------------------------------------------------------------------------
+class GDCM_EXPORT gdcmDicomDirStudy : public gdcmObject {
+public:
+   gdcmDicomDirStudy(ListTag::iterator begin,ListTag::iterator end);
+   ~gdcmDicomDirStudy(void);
+
+   virtual void Print(std::ostream &os = std::cout);
+
+   inline ListDicomDirSerie &GetDicomDirSeries() {return series;};
+   inline void AddDicomDirSerie(gdcmDicomDirSerie *obj) {series.push_back(obj);};
+
+private:
+   ListDicomDirSerie series;
+};
+
+//-----------------------------------------------------------------------------
+#endif
index c0fc1b2673c2d53784f771697d2141094917acc2..75834e1f76ea3f8a82b836d97241470cafcd9627 100644 (file)
@@ -62,7 +62,6 @@ gdcmDict::~gdcmDict() {
       if ( EntryToDelete )
          delete EntryToDelete;
    }
-
    // Since AddNewEntry adds symetrical in both KeyHt and NameHT we can
    // assume all the pointed gdcmDictEntries are already cleaned-up when
    // we cleaned KeyHt.
@@ -131,7 +130,7 @@ void gdcmDict::PrintByName(std::ostream& os) {
  * \ingroup gdcmDict
  * \brief  adds a new Dicom Dictionary Entry 
  * @param   NewEntry entry to add 
- * @return  false if Dicom Element already existed
+ * @return  false if Dicom Element already exists
  */
 bool gdcmDict::AddNewEntry(gdcmDictEntry *NewEntry) 
 {
index fce0e4657cafb40017c4d3ededc45bc7ae557d28..04c501ac428fe735bb535efa7ed7a16803210d98 100644 (file)
@@ -810,7 +810,7 @@ bool gdcmHeader::anonymizeHeader() {
   }
   
   // Just for fun :-(
-  // (if any) remove or replace 
+  // (if any) remove or replace all the stuff that contains a Date
   
 //0008 0012 DA ID Instance Creation Date
 //0008 0020 DA ID Study Date
index 1859192261b322966aaab4c4189366ff1b06494e..4308f3b4517c9a3446b19faef8e2b5fda0c2399d 100644 (file)
@@ -84,16 +84,22 @@ public:
 
    inline virtual std::string GetEntryByNumber  (guint16 group, guint16 element)
       { return(gdcmParser::GetEntryByNumber(group,element)); }
+      
    inline virtual std::string GetEntryVRByNumber(guint16 group, guint16 element)
       { return(gdcmParser::GetEntryVRByNumber(group,element)); }
       
+   inline virtual int GetEntryLengthByNumber(guint16 group, guint16 element)
+      { return(gdcmParser::GetEntryLengthByNumber(group,element)); }
+      
    inline virtual std::string GetEntryByName    (std::string tagName) 
       { return(gdcmParser::GetEntryByName(tagName)); }
+      
    inline virtual std::string GetEntryVRByName  (std::string tagName)
       { return(gdcmParser::GetEntryVRByName(tagName)); }
       
    inline virtual bool SetEntryByNumber(std::string content,guint16 group, guint16 element)
       { return(gdcmParser::SetEntryByNumber(content,group,element)); }
+      
    inline virtual bool SetEntryByName(std::string content,std::string tagName)
       { return(gdcmParser::SetEntryByName(content,tagName)); }
 
index 70c859fdf0f018b68d9640a99e7a75e8f6789052..2090c155173db2500d045507b7a2027b819fc5c5 100644 (file)
@@ -1,4 +1,4 @@
-// gdcmHeader.cxx
+// gdcmParser.cxx
 //-----------------------------------------------------------------------------
 #include "gdcmParser.h"
 #include "gdcmUtil.h"
@@ -566,6 +566,7 @@ std::string gdcmParser::GetEntryVRByName(std::string tagName) {
    return elem->GetVR();
 }
 
+
 /**
  * \ingroup gdcmParser
  * \brief   Searches within Header Entries (Dicom Elements) parsed with 
@@ -605,6 +606,21 @@ std::string gdcmParser::GetEntryVRByNumber(guint16 group, guint16 element) {
    return elem->GetVR();
 }
 
+/**
+ * \ingroup gdcmParser
+ * \brief   Searches within Header Entries (Dicom Elements) parsed with 
+ *          the public and private dictionaries 
+ *          for the value length of a given tag..
+ * @param   group Group of the searched tag.
+ * @param   element Element of the searched tag.
+ * @return  Corresponding element length; -2 if not found
+ */
+int gdcmParser::GetEntryLengthByNumber(guint16 group, guint16 element) {
+   gdcmHeaderEntry* elem =  GetHeaderEntryByNumber(group, element);
+   if ( !elem )
+      return -2;
+   return elem->GetLength();
+}
 /**
  * \ingroup gdcmParser
  * \brief   Sets the value (string) of the Header Entry (Dicom Element)
@@ -682,7 +698,7 @@ bool gdcmParser::SetEntryByNumber(std::string content,
  * @param l new length to substitute with
  * @param group   group of the Entry to modify
  * @param element element of the Entry to modify
- * @return  1 on success, 0 otherwise.
+ * @return  true on success, false otherwise.
  */
 bool gdcmParser::SetEntryLengthByNumber(guint32 l, 
                                         guint16 group, 
@@ -702,7 +718,7 @@ bool gdcmParser::SetEntryLengthByNumber(guint32 l,
  * \brief   Gets (from Header) the offset  of a 'non string' element value 
  *          (LoadElementValues has already be executed)
  * @param Group   group of the Entry 
- * @param Elem element of the Entry
+ * @param Elem  element of the Entry
  * @return File Offset of the Element Value 
  */
 size_t gdcmParser::GetEntryOffsetByNumber(guint16 Group, guint16 Elem) 
@@ -860,7 +876,7 @@ void gdcmParser::UpdateShaEntries(void) {
  */
 gdcmHeaderEntry* gdcmParser::GetHeaderEntryByNumber(guint16 group, guint16 element) 
 {
-   TagKey key = gdcmDictEntry::TranslateToKey(group, element);
+   TagKey key = gdcmDictEntry::TranslateToKey(group, element);   
    if ( ! tagHT.count(key))
       return NULL;
    return tagHT.find(key)->second;
@@ -1034,7 +1050,7 @@ void gdcmParser::WriteEntries(FILE *_fp,FileType type)
    //       TODO : find a trick (in STL?) to do it, at low cost !
 
    void *ptr;
-
+   int ff=0xffffffff;
    // TODO (?) tester les echecs en ecriture (apres chaque fwrite)
    int compte =0;
    
@@ -1045,9 +1061,9 @@ void gdcmParser::WriteEntries(FILE *_fp,FileType type)
       // === Deal with the length
       //     --------------------
       if(((*tag2)->GetLength())%2==1)
-      {
+      { 
          (*tag2)->SetValue((*tag2)->GetValue()+"\0");
-         (*tag2)->SetLength((*tag2)->GetLength()+1);
+         (*tag2)->SetLength((*tag2)->GetReadLength()+1);
       }
 
       gr    = (*tag2)->GetGroup();
@@ -1070,38 +1086,29 @@ void gdcmParser::WriteEntries(FILE *_fp,FileType type)
       fwrite ( &gr,(size_t)2 ,(size_t)1 ,_fp);  //group
       fwrite ( &el,(size_t)2 ,(size_t)1 ,_fp);  //element
       
-      // if ( (type == ExplicitVR) && (gr <= 0x0002) ) // ?!?  < 2  
-      if ( (type == ExplicitVR) || (type == DICOMDIR) )      
-      {
+      if ( (type == ExplicitVR) || (type == DICOMDIR) ) {
          // EXPLICIT VR
          guint16 z=0, shortLgr;
-         if (vr == "unkn") 
-         { // Unknown was 'written'     
-            shortLgr=lgr;
+        
+         if (gr == 0xfffe) { // NO Value Representation for 'delimiters'
+               // no length : write ffffffff           
+            fwrite (&ff,(size_t)4 ,(size_t)1 ,_fp);
+            continue;       // NO value for 'delimiters'                           
+        }
+        
+        shortLgr=lgr;   
+         if (vr == "unkn") {     // Unknown was 'written'
+           // deal with Little Endian            
             fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
             fwrite ( &z,  (size_t)2 ,(size_t)1 ,_fp);
-         } 
-         else 
-         {
-            if (gr != 0xfffe) 
-            { // NO value for 'delimiters'
-               if (vr == "unkn") // Unknown was 'written'
-                  fwrite(&z,(size_t)2 ,(size_t)1 ,_fp);
-               else     
-                  fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,_fp);
-            }
-
-            if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") || gr == 0xfffe)
-            {
-               if (gr != 0xfffe)
+         } else {
+            fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,_fp);                     
+            if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ){           
                   fwrite ( &z,  (size_t)2 ,(size_t)1 ,_fp);
                   fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp);
-            } 
-            else 
-            {
-               shortLgr=lgr;
-               fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
-            }
+            } else {
+              fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
+           }
          }
       } 
       else // IMPLICIT VR 
@@ -1112,7 +1119,7 @@ void gdcmParser::WriteEntries(FILE *_fp,FileType type)
       // === Deal with the value
       //     -------------------
       if (vr == "SQ")  continue; // no "value" to write for the SEQuences
-      if (gr == 0xfffe)continue;
+      if (gr == 0xfffe)continue; // no "value" to write for the delimiters
       
       if (voidArea != NULL) 
       { // there is a 'non string' LUT, overlay, etc
@@ -1160,6 +1167,110 @@ void gdcmParser::WriteEntries(FILE *_fp,FileType type)
    }
 }
 
+
+/**
+ * \ingroup gdcmParser
+ * \brief   writes on disc according to the requested format
+ *          (ACR-NEMA, ExplicitVR, ImplicitVR) the image
+ * \warning Uses the H Table, instead of the Chained List
+ *          in order to be compliant with the old way to proceed
+ *         (added elements taken in to account)
+ *         Only THERALYS, during a transitory phase is supposed
+ *         to use this method !!!
+ * \warning DON'T try, right now, to write a DICOM image
+ *           from an ACR Header (meta elements will be missing!)
+ * @param   _fp already open file pointer
+ * @param   type type of the File to be written 
+ *          (ACR-NEMA, ExplicitVR, ImplicitVR)
+ */
+void gdcmParser::WriteEntriesDeprecated(FILE *_fp,FileType type) {
+   guint16 gr, el;
+   guint32 lgr;
+   const char * val;
+   std::string vr;
+   guint32 val_uint32;
+   guint16 val_uint16;
+   
+   std::vector<std::string> tokens;
+
+   void *ptr;
+
+   // Tout ceci ne marche QUE parce qu'on est sur un proc Little Endian 
+   // restent a tester les echecs en ecriture (apres chaque fwrite)
+
+   for (TagHeaderEntryHT::iterator tag2=tagHT.begin();
+        tag2 != tagHT.end();
+        ++tag2){
+
+      gr =  tag2->second->GetGroup();
+      el =  tag2->second->GetElement();
+      lgr = tag2->second->GetLength();
+      val = tag2->second->GetValue().c_str();
+      vr =  tag2->second->GetVR();
+      
+     // std::cout << "Tag "<< std::hex << gr << " " << el << std::endl;
+
+      if ( type == ACR ) { 
+         if (gr < 0x0008)   continue; // ignore pure DICOM V3 groups
+         if (gr %2)         continue; // ignore shadow groups
+         if (vr == "SQ" )   continue; // ignore Sequences
+         if (gr == 0xfffe ) continue; // ignore delimiters
+      } 
+
+      fwrite ( &gr,(size_t)2 ,(size_t)1 ,_fp);  //group
+      fwrite ( &el,(size_t)2 ,(size_t)1 ,_fp);  //element
+
+      if ( (type == ExplicitVR) && (gr <= 0x0002) ) {
+         // EXPLICIT VR
+         guint16 z=0, shortLgr;
+         fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,_fp);
+
+         if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) {
+            fwrite ( &z,  (size_t)2 ,(size_t)1 ,_fp);
+            fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp);
+
+         } else {
+            shortLgr=lgr;
+            fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
+         }
+      } else { // IMPLICIT VR
+         fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp);
+      }
+
+      if (vr == "US" || vr == "SS") {
+         tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+         Tokenize (tag2->second->GetValue(), tokens, "\\");
+         for (unsigned int i=0; i<tokens.size();i++) {
+            val_uint16 = atoi(tokens[i].c_str());
+            ptr = &val_uint16;
+            fwrite ( ptr,(size_t)2 ,(size_t)1 ,_fp);
+         }
+         tokens.clear();
+         continue;
+      }
+      if (vr == "UL" || vr == "SL") {
+         tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+         Tokenize (tag2->second->GetValue(), tokens, "\\");
+         for (unsigned int i=0; i<tokens.size();i++) {
+            val_uint32 = atoi(tokens[i].c_str());
+            ptr = &val_uint32;
+            fwrite ( ptr,(size_t)4 ,(size_t)1 ,_fp);
+         }
+         tokens.clear();
+         continue;
+      }     
+      // Pixels are never loaded in the element !
+      if ((gr == 0x7fe0) && (el == 0x0010) ) break;
+
+      fwrite ( val,(size_t)lgr ,(size_t)1 ,_fp); // Elem value
+   }
+}
+
+
+
+
+
+
 /**
  * \ingroup gdcmParser
  * \brief   Swaps back the bytes of 4-byte long integer accordingly to
@@ -1431,6 +1542,7 @@ void gdcmParser::AddHeaderEntry(gdcmHeaderEntry *newHeaderEntry) {
    guint16 group   = Entry->GetGroup();
    std::string  vr = Entry->GetVR();
    guint16 length16;
+   
    if( (element == NumPixel) && (group == GrPixel) ) 
    {
       dbg.SetDebug(GDCM_DEBUG);
@@ -1522,18 +1634,18 @@ void gdcmParser::AddHeaderEntry(gdcmHeaderEntry *newHeaderEntry) {
          // Actually, length= 0xffff means that we deal with
          // Unknown Sequence Length 
       }
-
       FixHeaderEntryFoundLength(Entry, (guint32)length16);
       return;
    }
    else
    {
-      // Either implicit VR or a non DICOM conformal (see not below) explicit
+      // Either implicit VR or a non DICOM conformal (see note below) explicit
       // VR that ommited the VR of (at least) this element. Farts happen.
       // [Note: according to the part 5, PS 3.5-2001, section 7.1 p25
       // on Data elements "Implicit and Explicit VR Data Elements shall
       // not coexist in a Data Set and Data Sets nested within it".]
       // Length is on 4 bytes.
+      
       FixHeaderEntryFoundLength(Entry, ReadInt32());
       return;
    }
@@ -1834,11 +1946,13 @@ void gdcmParser::FixHeaderEntryFoundLength(gdcmHeaderEntry *Entry, guint32 Found
                                                  
    else if(Entry->GetGroup() == 0xfffe)
    { 
+  // cout << "ReadLength " <<Entry->GetReadLength() << " UsableLength " << FoundLength << endl;  
+  //   Entry->Print();                                                           
                        // sometimes, length seems to be wrong                                      
       FoundLength =0;  // some more clever checking to be done !
                        // I give up!
                       // only  gdcm-MR-PHILIPS-16-Multi-Seq.dcm
-                      // causes troubles :-(                                                     
+                      // causes troubles :-(                  
    }     
     
    Entry->SetUsableLength(FoundLength);
index 9841aa80014b704c71e0fbaa2357be27c9c62715..892ceb5e8d8af6c059aba19b6a6079c5f8ec2a18 100644 (file)
@@ -114,6 +114,7 @@ protected:
    virtual std::string GetEntryVRByName  (std::string tagName);
    virtual std::string GetEntryByNumber  (guint16 group, guint16 element);
    virtual std::string GetEntryVRByNumber(guint16 group, guint16 element);
+   virtual int     GetEntryLengthByNumber(guint16 group, guint16 element);
 
    virtual bool SetEntryByName  (std::string content, std::string tagName);
    virtual bool SetEntryByNumber(std::string content, guint16 group, guint16 element);
@@ -136,6 +137,9 @@ protected:
 
    void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR);
    void WriteEntries(FILE *_fp,FileType type);
+   void WriteEntriesDeprecated(FILE *_fp,FileType type); // JPR
+
+   void AddHeaderEntry       (gdcmHeaderEntry *);
 
 // Variables
    FILE *fp;
@@ -165,7 +169,6 @@ private:
 
    void LoadHeaderEntries    (void);
    void LoadHeaderEntry      (gdcmHeaderEntry *);
-   void AddHeaderEntry       (gdcmHeaderEntry *);
    void FindHeaderEntryLength(gdcmHeaderEntry *);
    void FindHeaderEntryVR    (gdcmHeaderEntry *);
    bool CheckHeaderEntryVR   (gdcmHeaderEntry *, VRKey);
index 996203b882c790b2a82a057f0a91c38843f51690..9554d39a5c342e75e6c125e8a6e9b922031498a3 100644 (file)
@@ -1,28 +1,28 @@
-// gdcmSerie.h
+// gdcmDicomDirSerie.h
 //-----------------------------------------------------------------------------
-#ifndef GDCMSERIE_H
-#define GDCMSERIE_H
+#ifndef GDCMDICOMDIRSERIE_H
+#define GDCMDICOMDIRSERIE_H
 
 #include "gdcmObject.h"
-#include "gdcmImage.h"
+#include "gdcmDicomDirImage.h"
 
 //-----------------------------------------------------------------------------
-typedef std::list<gdcmImage *> ListImage;
+typedef std::list<gdcmDicomDirImage *> ListDicomDirImage;
 
 //-----------------------------------------------------------------------------
-class GDCM_EXPORT gdcmSerie : public gdcmObject 
+class GDCM_EXPORT gdcmDicomDirSerie : public gdcmObject 
 {
 public:
-   gdcmSerie(ListTag::iterator begin,ListTag::iterator end);
-   ~gdcmSerie(void);
+   gdcmDicomDirSerie(ListTag::iterator begin,ListTag::iterator end);
+   ~gdcmDicomDirSerie(void);
 
    virtual void Print(std::ostream &os = std::cout);
 
-   inline ListImage &GetImages() {return images;};
-   inline void AddImage(gdcmImage *obj) {images.push_back(obj);};
+   inline ListDicomDirImage &GetDicomDirImages() {return images;};
+   inline void AddDicomDirImage(gdcmDicomDirImage *obj) {images.push_back(obj);};
 
 private:
-   ListImage images;
+   ListDicomDirImage images;
 };
 
 //-----------------------------------------------------------------------------
diff --git a/src/gdcmStudy.h b/src/gdcmStudy.h
deleted file mode 100644 (file)
index ebf31c1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// gdcmStudy.h
-//-----------------------------------------------------------------------------
-#ifndef GDCMSTUDY_H
-#define GDCMSTUDY_H
-
-#include "gdcmObject.h"
-#include "gdcmSerie.h"
-
-//-----------------------------------------------------------------------------
-typedef std::list<gdcmSerie *> ListSerie;
-
-//-----------------------------------------------------------------------------
-class GDCM_EXPORT gdcmStudy : public gdcmObject 
-{
-public:
-   gdcmStudy(ListTag::iterator begin,ListTag::iterator end);
-   ~gdcmStudy(void);
-
-   virtual void Print(std::ostream &os = std::cout);
-
-   inline ListSerie &GetSeries() {return series;};
-   inline void AddSerie(gdcmSerie *obj) {series.push_back(obj);};
-
-private:
-   ListSerie series;
-};
-
-//-----------------------------------------------------------------------------
-#endif
index faad02548843d592f30abff1a2bfc3bdb439a2f2..336be556873df4b7f5d43dc39a9d622d52d099f8 100644 (file)
@@ -59,11 +59,11 @@ gdcmDicomDirElement *gdcmGlobal::ddElem = (gdcmDicomDirElement *)0;
 gdcmGlobal gdcmGlob;
 
 gdcmGlobal::gdcmGlobal(void) {
-   if (VR || TS || Dicts)
+   if (VR || TS || Dicts || ddElem)
       dbg.Verbose(0, "gdcmGlobal::gdcmGlobal : VR or TS or Dicts already allocated");
-   Dicts = new gdcmDictSet();
-   VR = new gdcmVR();
-   TS = new gdcmTS();
+   Dicts  = new gdcmDictSet();
+   VR     = new gdcmVR();
+   TS     = new gdcmTS();
    ddElem = new gdcmDicomDirElement();
 }