]> Creatis software - gdcm.git/blobdiff - src/gdcmDicomDir.cxx
Normalization
[gdcm.git] / src / gdcmDicomDir.cxx
index 77ba8889623d6ff5ba6e1e7d8dcf4b2340af7aca..1c205cb948b077e5556ed7f7147b6b8caa18273b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/26 10:29:17 $
-  Version:   $Revision: 1.120 $
+  Date:      $Date: 2005/02/02 10:02:16 $
+  Version:   $Revision: 1.126 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
   
 =========================================================================*/
 
+//-----------------------------------------------------------------------------
+//  For full DICOMDIR description, see:
+//  PS 3.3-2003, pages 731-750
+//-----------------------------------------------------------------------------
 #include "gdcmDicomDir.h"
 #include "gdcmDicomDirStudy.h"
 #include "gdcmDicomDirSerie.h"
 
 namespace gdcm 
 {
-
-//-----------------------------------------------------------------------------
-//  For full DICOMDIR description, see:
-//  PS 3.3-2003, pages 731-750
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
-
 /**
  * \brief   Constructor : creates an empty DicomDir
  */
 DicomDir::DicomDir()
-   :Document( )
+         :Document( )
 {
    Initialize();  // sets all private fields to NULL
    NewMeta();
@@ -69,7 +68,7 @@ DicomDir::DicomDir()
 /**
  * \brief Constructor Parses recursively the directory and creates the DicomDir
  *        or uses an already built DICOMDIR, depending on 'parseDir' value.
- * @param fileName        name 
+ * @param fileName  name 
  *                      - of the root directory (parseDir = true)
  *                      - of the DICOMDIR       (parseDir = false)
  * @param parseDir boolean
@@ -153,29 +152,6 @@ DicomDir::~DicomDir()
    }
 }
 
-//-----------------------------------------------------------------------------
-// Print
-/**
- * \brief  Canonical Printer 
- * @param   os ostream we want to print in
- * @param indent Indentation string to be prepended during printing
- */
-void DicomDir::Print(std::ostream &os, std::string const & )
-{
-   if( MetaElems )
-   {
-      MetaElems->SetPrintLevel(PrintLevel);
-      MetaElems->Print(os);   
-   }   
-   for(ListDicomDirPatient::iterator cc  = Patients.begin();
-                                     cc != Patients.end();
-                                   ++cc)
-   {
-     (*cc)->SetPrintLevel(PrintLevel);
-     (*cc)->Print(os);
-   }
-}
-
 //-----------------------------------------------------------------------------
 // Public
 /**
@@ -398,12 +374,11 @@ bool DicomDir::WriteDicomDir(std::string const &fileName)
 
 //-----------------------------------------------------------------------------
 // Protected
-
 /**
  * \brief create a Document-like chained list from a root Directory 
  * @param path entry point of the tree-like structure
  */
-void DicomDir::CreateDicomDirChainedList(std::string const & path)
+void DicomDir::CreateDicomDirChainedList(std::string const &path)
 {
    CallStartMethod();
    DirList dirList(path,1); // gets recursively the file list
@@ -595,6 +570,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
    // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later
    // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later
    // for all the relevant elements found in their own spot of the DicomDir.dic
+
    // FIXME : troubles found when it's a SeqEntry
 
    for( it = elemList.begin(); it != elemList.end(); ++it)
@@ -658,7 +634,6 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
    }
 }
 
-//-----------------------------------------------------------------------------
 /**
  * \brief   CallStartMethod
  */
@@ -672,7 +647,6 @@ void DicomDir::CallStartMethod()
    }
 }
 
-//-----------------------------------------------------------------------------
 /**
  * \brief   CallProgressMethod
  */
@@ -684,7 +658,6 @@ void DicomDir::CallProgressMethod()
    }
 }
 
-//-----------------------------------------------------------------------------
 /**
  * \brief   CallEndMethod
  */
@@ -725,7 +698,7 @@ void DicomDir::Initialize()
  */
 void DicomDir::CreateDicomDir()
 {
-   // The list is parsed. 
+   // The SeqEntries of "Directory Record Sequence" are parsed. 
    //  When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
    //  1 - we save the beginning iterator
    //  2 - we continue to parse
@@ -737,7 +710,7 @@ void DicomDir::CreateDicomDir()
    DocEntry *e = GetDocEntry(0x0004, 0x1220);
    if ( !e )
    {
-      gdcmVerboseMacro( "NO Directory record sequence (0x0004,0x1220)");
+      gdcmVerboseMacro( "No Directory Record Sequence (0004,1220) found");
       /// \todo FIXME: what to do when the parsed file IS NOT a DICOMDIR file ? 
       return;         
    }
@@ -745,8 +718,7 @@ void DicomDir::CreateDicomDir()
    SeqEntry *s = dynamic_cast<SeqEntry *>(e);
    if ( !s )
    {
-      gdcmVerboseMacro( "No SeqEntry present");
-      // useless : (0x0004,0x1220) IS a Sequence !
+      gdcmVerboseMacro( "Element (0004,1220) is not a Sequence ?!?");
       return;
    }
 
@@ -816,9 +788,11 @@ void DicomDir::CreateDicomDir()
          // neither an 'IMAGE' SQItem. Skip to next item.
          continue;
       }
+      if( si )
+         MoveSQItem(si,tmpSI);
+
       tmpSI=s->GetNextSQItem();
    }
-// friend hunting : this one will be difficult to remove !
    ClearEntry();
 }
 
@@ -895,7 +869,8 @@ bool DicomDir::AddImageToEnd(DicomDirImage *dd)
 }
 
 /**
- * \brief  for each Header of the chained list, add/update the Patient/Study/Serie/Image info 
+ * \brief  for each Header of the chained list, 
+ *         add/update the Patient/Study/Serie/Image info 
  * @param   path path of the root directory
  * @param   list chained list of Headers
  */
@@ -987,6 +962,28 @@ bool DicomDir::HeaderLessThan(Document *header1, Document *header2)
    return *header1 < *header2;
 }
 
-} // end namespace gdcm
+//-----------------------------------------------------------------------------
+// Print
+/**
+ * \brief  Canonical Printer 
+ * @param   os ostream we want to print in
+ * @param indent Indentation string to be prepended during printing
+ */
+void DicomDir::Print(std::ostream &os, std::string const & )
+{
+   if( MetaElems )
+   {
+      MetaElems->SetPrintLevel(PrintLevel);
+      MetaElems->Print(os);   
+   }   
+   for(ListDicomDirPatient::iterator cc  = Patients.begin();
+                                     cc != Patients.end();
+                                   ++cc)
+   {
+     (*cc)->SetPrintLevel(PrintLevel);
+     (*cc)->Print(os);
+   }
+}
 
 //-----------------------------------------------------------------------------
+} // end namespace gdcm