]> Creatis software - gdcm.git/blobdiff - src/gdcmDocument.cxx
- now, DicomDir stuff stakes into account the 'new' structure
[gdcm.git] / src / gdcmDocument.cxx
index 10fd52f39b03b6b8e7301947ab205a10aa755220..37966499bb038759d5d188a47fce182a6a0f29ab 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/08/02 16:42:14 $
-  Version:   $Revision: 1.65 $
+  Date:      $Date: 2004/08/26 15:29:53 $
+  Version:   $Revision: 1.68 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -94,7 +94,7 @@ gdcmDocument::gdcmDocument( std::string const & filename )
    {
       return;
    }
-   
+
    dbg.Verbose(0, "gdcmDocument::gdcmDocument: starting parsing of file: ",
                   Filename.c_str());
    rewind(Fp);
@@ -260,8 +260,6 @@ bool gdcmDocument::IsReadable()
 {
    if( Filetype == gdcmUnknown)
    {
-      std::cout << " gdcmDocument::IsReadable: Filetype " << Filetype
-               << " " << "gdcmUnknown " << gdcmUnknown << std::endl; //JPR
       dbg.Verbose(0, "gdcmDocument::IsReadable: wrong filetype");
       return false;
    }
@@ -671,6 +669,35 @@ gdcmBinEntry * gdcmDocument::ReplaceOrCreateByNumber(
    return b;
 }  
 
+
+/*
+ * \brief   Modifies the value of a given Header Entry (Dicom Element)
+ *          when it exists. Create it when unexistant.
+ * @param   Group   Group number of the Entry 
+ * @param   Elem  Element number of the Entry
+ * \return  pointer to the modified/created SeqEntry (NULL when creation
+ *          failed).
+ */
+gdcmSeqEntry * gdcmDocument::ReplaceOrCreateByNumber(
+                                         uint16_t group, 
+                                         uint16_t elem)
+{
+   gdcmSeqEntry* b = 0;
+   gdcmDocEntry* a = GetDocEntryByNumber( group, elem);
+   if (!a)
+   {
+      a = NewSeqEntryByNumber(group, elem);
+      if (!a)
+      {
+         return 0;
+      }
+
+      b = new gdcmSeqEntry(a, 1); // FIXME : 1 (Depth)
+      AddEntry(b);
+   }   
+   return b;
+} 
 /**
  * \brief Set a new value if the invoked element exists
  *        Seems to be useless !!!
@@ -1207,7 +1234,7 @@ uint32_t gdcmDocument::SwapLong(uint32_t a)
          a=( ((a<< 8) & 0xff00ff00) | ((a>>8) & 0x00ff00ff)  );
          break;
       default :
-         std::cout << "swapCode= " << SwapCode << std::endl;
+         //std::cout << "swapCode= " << SwapCode << std::endl;
          dbg.Error(" gdcmDocument::SwapLong : unset swap code");
          a = 0;
    }
@@ -1372,7 +1399,6 @@ long gdcmDocument::ParseDES(gdcmDocEntrySet *set,
       }
       delete newDocEntry;
    }
-
    return l; // Probably useless 
 }
 
@@ -1521,7 +1547,7 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry)
    if ( IsDocEntryAnInteger(entry) )
    {   
       uint32_t NewInt;
-      std::ostringstream s;
+      //std::ostringstream s; //shadow previous declaration
       int nbInt;
       // When short integer(s) are expected, read and convert the following 
       // n *two characters properly i.e. consider them as short integers as
@@ -1613,8 +1639,7 @@ void gdcmDocument::FindDocEntryLength( gdcmDocEntry *entry )
 {
    uint16_t element = entry->GetElement();
    std::string  vr  = entry->GetVR();
-   uint16_t length16;
-       
+   uint16_t length16;       
    
    if ( Filetype == gdcmExplicitVR && !entry->IsImplicitVR() ) 
    {
@@ -2537,7 +2562,7 @@ gdcmDocEntry* gdcmDocument::ReadNextDocEntry()
    {
       // We reached the EOF (or an error occured) therefore 
       // header parsing has to be considered as finished.
-      std::cout << e;
+      //std::cout << e;
       return 0;
    }
 
@@ -2551,7 +2576,7 @@ gdcmDocEntry* gdcmDocument::ReadNextDocEntry()
    catch ( gdcmFormatError e )
    {
       // Call it quits
-      std::cout << e;
+      //std::cout << e;
       delete newEntry;
       return 0;
    }