]> Creatis software - gdcm.git/commitdiff
Add
authorjpr <jpr>
Mon, 29 Aug 2005 13:05:01 +0000 (13:05 +0000)
committerjpr <jpr>
Mon, 29 Aug 2005 13:05:01 +0000 (13:05 +0000)
void Document::AddForceLoadElement(uint16_t group, uint16_t elem); method
to allow forcing the loading of some elements, even if they exceed
the current MAX_SIZE_LOAD_ELEMENT_VALUE  (default : 4096)

src/gdcmBinEntry.cxx
src/gdcmDocument.cxx
src/gdcmDocument.h
src/gdcmFile.cxx
src/gdcmFile.h

index fdbda3f1a9b4dd4cc33a3a8b81e564bde90123c8..3e150aaa6326f89ff05803af19ca2cd87f59c402 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/25 14:59:49 $
-  Version:   $Revision: 1.74 $
+  Date:      $Date: 2005/08/29 13:05:01 $
+  Version:   $Revision: 1.75 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -170,7 +170,7 @@ void BinEntry::Print(std::ostream &os, std::string const & )
             s << "]";
       }
       else
-      {
+      { 
          if ( Util::IsCleanArea( GetBinArea(),GetLength()  ) )
          {
             std::string cleanString = 
@@ -181,8 +181,7 @@ void BinEntry::Print(std::ostream &os, std::string const & )
          {
             s << " [" << GetValue()
               << "; length = " << GetLength() << "]";
-         }
+         } 
       }
    }
    else
index 4f2ad927233afd359d57f262a48a5cd5b0a0c323..8177c0172a808addabe22ad60070fb497e16f27c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/29 09:41:22 $
-  Version:   $Revision: 1.269 $
+  Date:      $Date: 2005/08/29 13:05:01 $
+  Version:   $Revision: 1.270 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -258,6 +258,37 @@ bool Document::DoTheLoadingDocumentJob(  )
      }      
    }
 
+   // Force Loading some more elements if user asked to.
+
+   gdcm::DocEntry *d;
+   for (ListElements::iterator it = UserForceLoadList.begin();  
+                               it != UserForceLoadList.end();
+                             ++it)
+   {
+      d = GetDocEntry( (*it).Group, (*it).Elem);
+
+      if ( d == NULL)
+         continue;
+
+      if ( dynamic_cast<BinEntry *>(d) )
+      {
+         LoadDocEntry(d, true);
+         continue;
+      }
+
+      if ( dynamic_cast<BinEntry *>(d) )
+      {
+         LoadEntryBinArea((*it).Group, (*it).Elem);
+         continue;
+      }
+      if ( dynamic_cast<SeqEntry *>(d) )
+      {
+         gdcmWarningMacro( "You cannot 'ForceLoad' a SeqEntry ");
+         continue;
+      }
+   }
+
    CloseFile(); 
   
    // ----------------------------
@@ -283,10 +314,22 @@ bool Document::DoTheLoadingDocumentJob(  )
          SetValEntry(rows   , 0x0028, 0x0011);
    }
    // --- End of ACR-LibIDO kludge --- 
-
    return true;
 }
 
+
+/**
+ * \brief Adds a new element we want to load anyway
+ * @param   group  Group number of the target tag.
+ * @param   elem Element number of the target tag.
+ */
+void Document::AddForceLoadElement (uint16_t group, uint16_t elem) 
+{ 
+   Element el;
+   el.Group = group;
+   el.Elem  = elem;
+   UserForceLoadList.push_back(el); 
+}
 /**
  * \brief   Get the public dictionary used
  */
@@ -1270,11 +1313,13 @@ return newEntry;
 }
 
 /**
- * \brief   Loads the element content if its length doesn't exceed
- *          the value specified with Document::SetMaxSizeLoadEntry()
+ * \brief   Loads (or not) the element content depending if its length exceeds
+ *          or not the value specified with Document::SetMaxSizeLoadEntry()
  * @param   entry Header Entry (Dicom Element) to be dealt with
+ * @param  forceLoad wheter we want to load its content even if its length 
+ *         exceeds the value specified with Document::SetMaxSizeLoadEntry()
  */
-void Document::LoadDocEntry(DocEntry *entry)
+void Document::LoadDocEntry(DocEntry *entry, bool forceLoad)
 {
    uint16_t group  = entry->GetGroup();
    std::string  vr = entry->GetVR();
@@ -1304,37 +1349,41 @@ void Document::LoadDocEntry(DocEntry *entry)
    // the element content and it's length.
 
    std::ostringstream s;
-   if (length > MaxSizeLoadEntry)
-   {
-      if (BinEntry *binEntryPtr = dynamic_cast< BinEntry* >(entry) )
-      {  
-         s << GDCM_NOTLOADED;
-         s << " Ad.:" << (long)entry->GetOffset();
-         s << " x(" << std::hex << entry->GetOffset() << ")";
-         s << std::dec;
-         s << " Lgt:"  << entry->GetLength();
-         s << " x(" << std::hex << entry->GetLength() << ")";
-         binEntryPtr->SetValue(s.str());
-      }
-      else if (ValEntry *valEntryPtr = dynamic_cast< ValEntry* >(entry) )
-      {
-         s << GDCM_NOTLOADED;  
-         s << " Address:" << (long)entry->GetOffset();
-         s << " Length:"  << entry->GetLength();
-         s << " x(" << std::hex << entry->GetLength() << ")";
-         valEntryPtr->SetValue(s.str());
-      }
-      else
+
+   if (!forceLoad)
+   {
+      if (length > MaxSizeLoadEntry)
       {
-         // fusible
-         gdcmErrorMacro( "MaxSizeLoadEntry exceeded, neither a BinEntry "
-                      << "nor a ValEntry ?! Should never print that !" );
-      }
+         if (BinEntry *binEntryPtr = dynamic_cast< BinEntry* >(entry) )
+         {  
+            s << GDCM_NOTLOADED;
+            s << " Ad.:" << (long)entry->GetOffset();
+            s << " x(" << std::hex << entry->GetOffset() << ")";
+            s << std::dec;
+            s << " Lgt:"  << entry->GetLength();
+            s << " x(" << std::hex << entry->GetLength() << ")";
+            binEntryPtr->SetValue(s.str());
+         }
+         else if (ValEntry *valEntryPtr = dynamic_cast< ValEntry* >(entry) )
+         {
+            s << GDCM_NOTLOADED;  
+            s << " Address:" << (long)entry->GetOffset();
+            s << " Length:"  << entry->GetLength();
+            s << " x(" << std::hex << entry->GetLength() << ")";
+            valEntryPtr->SetValue(s.str());
+         }
+         else
+         {
+            // fusible
+            gdcmErrorMacro( "MaxSizeLoadEntry exceeded, neither a BinEntry "
+                         << "nor a ValEntry ?! Should never print that !" );
+         }
 
-      // to be sure we are at the end of the value ...
-      Fp->seekg((long)entry->GetOffset()+(long)entry->GetLength(),
-                std::ios::beg);
-      return;
+         // to be sure we are at the end of the value ...
+         Fp->seekg((long)entry->GetOffset()+(long)entry->GetLength(),
+                   std::ios::beg);
+         return;
+      }
    }
 
    // When we find a BinEntry not very much can be done :
index 289500ba4ef05a069a3773308debf62ed92c944d..b89d15c558d36c1fbad41955fd630ca39551ae5b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.h,v $
   Language:  C++
-  Date:      $Date: 2005/08/24 12:09:13 $
-  Version:   $Revision: 1.119 $
+  Date:      $Date: 2005/08/29 13:05:01 $
+  Version:   $Revision: 1.120 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -100,6 +100,7 @@ typedef std::list<Element> ListElements;
    virtual void LoadEntryBinArea(BinEntry *entry);
 
    void LoadDocEntrySafe(DocEntry *entry);
+   void AddForceLoadElement(uint16_t group, uint16_t elem);
  
 // Ordering of Documents
    bool operator<(Document &document);
@@ -166,8 +167,11 @@ protected:
    /// are NOT loaded.
    static const unsigned int MAX_SIZE_LOAD_ELEMENT_VALUE;
 
-   /// List of elements to Anonymize
-   ListElements AnonymizeList;
+   /// User supplied list of elements to Anonymize
+   ListElements UserAnonymizeList;
+
+   /// User supplied list of elements to force Load
+   ListElements UserForceLoadList;
 
    /// \brief Bit string integer (each one considered as a boolean)
    ///        Bit 0 : Skip Sequences,    if possible
@@ -191,7 +195,7 @@ private:
    void ParseDES(DocEntrySet *set, long offset, long l_max, bool delim_mode);
    void ParseSQ (SeqEntry *seq,    long offset, long l_max, bool delim_mode);
 
-   void LoadDocEntry         (DocEntry *e);
+   void LoadDocEntry         (DocEntry *e, bool forceLoad = false);
    void FindDocEntryLength   (DocEntry *e) throw ( FormatError );
    uint32_t FindDocEntryLengthOBOrOW() throw( FormatUnexpected );
    std::string FindDocEntryVR();
index f79b64e7c8618eb8cc8f574c93ef064f13daf54e..1e90cccb49650543aa4b9a35789e4d5adb3e3cd7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/30 18:17:08 $
-  Version:   $Revision: 1.264 $
+  Date:      $Date: 2005/08/29 13:05:01 $
+  Version:   $Revision: 1.265 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1289,7 +1289,7 @@ void File::AddAnonymizeElement (uint16_t group, uint16_t elem,
    el.Group = group;
    el.Elem  = elem;
    el.Value = value;
-   AnonymizeList.push_back(el); 
+   UserAnonymizeList.push_back(el); 
 }
 
 /**
@@ -1305,8 +1305,8 @@ void File::AnonymizeNoLoad()
    uint32_t lgth;
    uint32_t valLgth = 0;
    std::string *spaces;
-   for (ListElements::iterator it = AnonymizeList.begin();  
-                               it != AnonymizeList.end();
+   for (ListElements::iterator it = UserAnonymizeList.begin();  
+                               it != UserAnonymizeList.end();
                              ++it)
    { 
       d = GetDocEntry( (*it).Group, (*it).Elem);
@@ -1314,11 +1314,11 @@ void File::AnonymizeNoLoad()
       if ( d == NULL)
          continue;
 
-         if ( dynamic_cast<SeqEntry *>(d) )
-         {
-            gdcmWarningMacro( "You cannot 'Anonymize a SeqEntry ");
-            continue;
-         }
+      if ( dynamic_cast<SeqEntry *>(d) )
+      {
+         gdcmWarningMacro( "You cannot 'Anonymize' a SeqEntry ");
+         continue;
+      }
 
       offset = d->GetOffset();
       lgth =   d->GetLength();
@@ -1344,7 +1344,7 @@ void File::AnonymizeNoLoad()
 bool File::AnonymizeFile()
 {
    // If Anonymisation list is empty, let's perform some basic anonymization
-   if ( AnonymizeList.begin() == AnonymizeList.end() )
+   if ( UserAnonymizeList.begin() == UserAnonymizeList.end() )
    {
       // If exist, replace by spaces
       SetValEntry ("  ",0x0010, 0x2154); // Telephone   
@@ -1362,15 +1362,15 @@ bool File::AnonymizeFile()
          }
          else
          {
-            SetValEntry("anonymised", 0x0010, 0x0010);
+            SetValEntry("anonymized", 0x0010, 0x0010);
          }
       }
    }
    else
    {
       gdcm::DocEntry *d;
-      for (ListElements::iterator it = AnonymizeList.begin();  
-                                  it != AnonymizeList.end();
+      for (ListElements::iterator it = UserAnonymizeList.begin();  
+                                  it != UserAnonymizeList.end();
                                 ++it)
       {  
          d = GetDocEntry( (*it).Group, (*it).Elem);
index ef3fac78af93473961e19d255165c21908c4c2fa..57ef7d107c03f6aa31af9b2ce5abe36e54d5dfc6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.h,v $
   Language:  C++
-  Date:      $Date: 2005/07/24 02:34:42 $
-  Version:   $Revision: 1.115 $
+  Date:      $Date: 2005/08/29 13:05:02 $
+  Version:   $Revision: 1.116 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -167,7 +167,7 @@ public:
    void AddAnonymizeElement (uint16_t group, uint16_t elem, 
                              std::string const &value);
    /// Clears the list of elements to be anonymized
-   void ClearAnonymizeList() { AnonymizeList.clear(); }      
+   void ClearAnonymizeList() { UserAnonymizeList.clear(); }      
    void AnonymizeNoLoad();
    /// Replace patient's own information by info from the Anonymization list
    bool AnonymizeFile();