]> Creatis software - gdcm.git/blobdiff - src/gdcmDicomDir.cxx
Comments
[gdcm.git] / src / gdcmDicomDir.cxx
index 769ce05901da1ceb26b72674f8383b3a45a78d18..40a41eef7e2db6c113324cdfbff637415a74177b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/02 14:52:24 $
-  Version:   $Revision: 1.127 $
+  Date:      $Date: 2005/02/11 16:36:52 $
+  Version:   $Revision: 1.131 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #else
 #   include <unistd.h>
 #endif
-
+// ----------------------------------------------------------------------------
+//         Note for future developpers
+// ----------------------------------------------------------------------------
+//
+//  Dicom PS 3.3 describes the relationship between Directory Records, as follow
+//
+//  Directory Record Type      Directory Record Types which may be included
+//                                in the next lower-level directory Entity
+//
+// (Root directory Entity)     PATIENT
+//
+// PATIENT                     STUDY
+//
+// STUDY                       SERIES, VISIT, RESULTS, STUDY COMPONENT
+//
+// SERIES                      IMAGE, OVERLAYS, MODALITY LUT, VOI LUT,
+//                             CURVE, STORED PRINT, RT DOSE, RT STRUCTURE SET
+//                             RT PLAN, RT TREAT RECORD, PRESENTATION, WAVEFORM,
+//                             SR DOCUMENT, KEY OBJECT DOC, SPECTROSCOPY,
+//                             RAW DATA, REGISTRATION, FIDUCIAL
+// IMAGE
+// OVERLAY
+// MODALITY LUT
+// VOI LUT
+// CURVE
+// STORED PRINT
+// RT DOSE
+// RT STRUCTURE SET
+// RT PLAN
+// RT TREAT RECORD
+// PRESENTATION
+// WAVEFORM
+// SR DOCUMENT
+// KEY OBJECT DOC
+// SPECTROSCOPY
+// RAW DATA
+// REGISTRATION
+// FIDUCIAL
+// 
+// ----------------------
+// The current gdcm version only deals with :
+//
+// (Root directory Entity)     PATIENT
+// PATIENT                     STUDY
+// STUDY                       SERIES 
+// SERIES                      IMAGE
+// IMAGE                       /
+//
+// DicomDir::CreateDicomDir will have to be completed
+// Treelike structure management will have to be upgraded
+// ----------------------------------------------------------------------------
+    
 namespace gdcm 
 {
 //-----------------------------------------------------------------------------
@@ -92,7 +143,7 @@ DicomDir::DicomDir(std::string const &fileName, bool parseDir ):
    if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse
    {
       if (!parseDir)
-         gdcmVerboseMacro( "Entry HT empty for file: "<<fileName);
+         gdcmWarningMacro( "Entry HT empty for file: "<<fileName);
 
    // Only if user passed a root directory
    // ------------------------------------
@@ -109,13 +160,12 @@ DicomDir::DicomDir(std::string const &fileName, bool parseDir ):
       {
          NewMeta();
 
-         gdcmVerboseMacro( "Parse directory and create the DicomDir");
+         gdcmWarningMacro( "Parse directory and create the DicomDir");
          ParseDirectory();
       }
       else
       {
-         /// \todo if parseDir == false, it should be tagged as an error
-         // NO ! user may just call ParseDirectory() *after* constructor
+         //  user may just call ParseDirectory() *after* constructor
       }
    }
    // Only if user passed a DICOMDIR
@@ -126,10 +176,8 @@ DicomDir::DicomDir(std::string const &fileName, bool parseDir ):
       DocEntry *e = GetDocEntry(0x0004, 0x1220);
       if ( !e )
       {
-         gdcmVerboseMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
+         gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
                           << " in file " << fileName);
-         /// \todo FIXME : what do we do when the parsed file IS NOT a
-         ///       DICOMDIR file ?         
       }
       else
          CreateDicomDir();
@@ -166,17 +214,17 @@ bool DicomDir::IsReadable()
 {
    if( Filetype == Unknown)
    {
-      gdcmVerboseMacro( "Wrong filetype");
+      gdcmWarningMacro( "Wrong filetype");
       return false;
    }
    if( !MetaElems )
    {
-      gdcmVerboseMacro( "Meta Elements missing in DicomDir");
+      gdcmWarningMacro( "Meta Elements missing in DicomDir");
       return false;
    }
    if( Patients.size() <= 0 )
    {
-      gdcmVerboseMacro( "NO Patient in DicomDir");
+      gdcmWarningMacro( "NO Patient in DicomDir");
       return false;
    }
 
@@ -393,7 +441,7 @@ bool DicomDir::WriteDicomDir(std::string const &fileName)
                                          std::ios::out | std::ios::binary);
    if( !fp ) 
    {
-      gdcmVerboseMacro("Failed to open(write) File: " << fileName.c_str());
+      gdcmWarningMacro("Failed to open(write) File: " << fileName.c_str());
       return false;
    }
 
@@ -460,7 +508,7 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
       header = new File( it->c_str() );
       if( !header )
       {
-         gdcmVerboseMacro( "Failure in new gdcm::File " << it->c_str() );
+         gdcmWarningMacro( "Failure in new gdcm::File " << it->c_str() );
          continue;
       }
       
@@ -468,7 +516,7 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
       {
          // Add the file to the chained list:
          list.push_back(header);
-         gdcmVerboseMacro( "Readable " << it->c_str() );
+         gdcmWarningMacro( "Readable " << it->c_str() );
        }
        else
        {
@@ -568,15 +616,14 @@ void DicomDir::CreateDicomDir()
    DocEntry *e = GetDocEntry(0x0004, 0x1220);
    if ( !e )
    {
-      gdcmVerboseMacro( "No Directory Record Sequence (0004,1220) found");
-      /// \todo FIXME: what to do when the parsed file IS NOT a DICOMDIR file ? 
+      gdcmWarningMacro( "No Directory Record Sequence (0004,1220) found");
       return;         
    }
    
    SeqEntry *s = dynamic_cast<SeqEntry *>(e);
    if ( !s )
    {
-      gdcmVerboseMacro( "Element (0004,1220) is not a Sequence ?!?");
+      gdcmWarningMacro( "Element (0004,1220) is not a Sequence ?!?");
       return;
    }
 
@@ -596,7 +643,7 @@ void DicomDir::CreateDicomDir()
       }
       else
       {
-         gdcmVerboseMacro( "Not a ValEntry.");
+         gdcmWarningMacro( "Not a ValEntry.");
          continue;
       }
 
@@ -732,7 +779,7 @@ bool DicomDir::AddImageToEnd(DicomDirImage *dd)
  * @param   path path of the root directory
  * @param   list chained list of Headers
  */
-void DicomDir::SetElements(std::string const & path, VectDocument const &list)
+void DicomDir::SetElements(std::string const &path, VectDocument const &list)
 {
    ClearEntry();
    ClearPatient();
@@ -747,7 +794,8 @@ void DicomDir::SetElements(std::string const & path, VectDocument const &list)
 
    bool first = true;
    for( VectDocument::const_iterator it = list.begin();
-                                     it != list.end(); ++it )
+                                     it != list.end(); 
+                                   ++it )
    {
       // get the current file characteristics
       patCurName         = (*it)->GetEntryValue(0x0010,0x0010);
@@ -869,10 +917,10 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
    // imageElem 0008 1150 "" // Referenced SOP Class UID    : to be set/forged later
    // 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 all the relevant elements found in their own spot of the DicomDir.dic
    for( it = elemList.begin(); it != elemList.end(); ++it)
    {
       tmpGr     = it->Group;
@@ -905,7 +953,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
          {
             if( header->GetFileName().substr(0, path.length()) != path )
             {
-               gdcmVerboseMacro( "The base path of file name is incorrect");
+               gdcmWarningMacro( "The base path of file name is incorrect");
                val = header->GetFileName();
             }
             else
@@ -928,7 +976,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
 
       if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
       {
-         gdcmVerboseMacro("GDCM_DICOMDIR_META ?!? should never print that");
+         gdcmWarningMacro("GDCM_DICOMDIR_META ?!? should never print that");
       }
       si->AddEntry(entry);
    }