]> Creatis software - gdcm.git/commitdiff
ENH: Since HandleOutOfGroup0002 need access to the transfer syntax move the method...
authormalaterre <malaterre>
Tue, 11 Jan 2005 23:06:35 +0000 (23:06 +0000)
committermalaterre <malaterre>
Tue, 11 Jan 2005 23:06:35 +0000 (23:06 +0000)
src/gdcmDocument.cxx
src/gdcmDocument.h
src/gdcmHeader.cxx
src/gdcmHeader.h

index 24777f51729a1ecef83fea09ed7850b9b00059a9..ae50bc8a2cbd31b55893e6e57c672bb5f84939d0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/11 22:46:22 $
-  Version:   $Revision: 1.179 $
+  Date:      $Date: 2005/01/11 23:06:35 $
+  Version:   $Revision: 1.180 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -2361,6 +2361,40 @@ void Document::HandleBrokenEndian(uint16_t &group, uint16_t &elem)
    }
 }
 
+/**
+ * \brief Accesses the info from 0002,0010 : Transfer Syntax and TS
+ *        else 1.
+ * @return The full Transfer Syntax Name (as opposed to Transfer Syntax UID)
+ */
+std::string Document::GetTransferSyntaxName()
+{
+   // use the TS (TS : Transfer Syntax)
+   std::string transferSyntax = GetEntry(0x0002,0x0010);
+
+   if ( transferSyntax == GDCM_NOTLOADED )
+   {
+      gdcmVerboseMacro( "Transfer Syntax not loaded. " << std::endl
+               << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" );
+      return "Uncompressed ACR-NEMA";
+   }
+   if ( transferSyntax == GDCM_UNFOUND )
+   {
+      gdcmVerboseMacro( "Unfound Transfer Syntax (0002,0010)");
+      return "Uncompressed ACR-NEMA";
+   }
+
+   while ( ! isdigit((unsigned char)transferSyntax[transferSyntax.length()-1]) )
+   {
+      transferSyntax.erase(transferSyntax.length()-1, 1);
+   }
+   // we do it only when we need it
+   TS* ts         = Global::GetTS();
+   std::string tsName = ts->GetValue( transferSyntax );
+
+   // Global::GetTS() is a global static you shall never try to delete it!
+   return tsName;
+}
+
 /**
  * \brief   Group 0002 is always coded Little Endian
  *          whatever Transfer Syntax is
@@ -2372,25 +2406,23 @@ void Document::HandleOutOfGroup0002(uint16_t group)
    if ( !Group0002Parsed && group != 0x0002)
    {
       Group0002Parsed = true;
-     // we just came out of group 0002
-     // if Transfer syntax is Big Endian we have to change CheckSwap
+      // we just came out of group 0002
+      // if Transfer syntax is Big Endian we have to change CheckSwap
 
-      TagKey key = DictEntry::TranslateToKey(0x0002, 0x0010);
-      if ( !TagHT.count(key))
+      std::string ts = GetTransferSyntaxName();
+      if ( !Global::GetTS()->IsTransferSyntax(ts) )
       {
-         gdcmVerboseMacro("True DICOM File, with NO Tansfer Syntax ?!?");
+         gdcmVerboseMacro("True DICOM File, with NO Tansfer Syntax: " << ts );
          return;
       }
 
-   // FIXME Strangely, this works with 
-   //'Implicit VR Transfer Syntax (GE Private)
-
-       if ( ((ValEntry *)TagHT.find(key)->second)->GetValue()
-               == "Explicit VR - Big Endian" )
-       {
-          gdcmVerboseMacro("Tansfer Syntax = Explicit VR - Big Endian");
-          SwitchByteSwapCode();
-        }
+      // FIXME Strangely, this works with 
+      //'Implicit VR Transfer Syntax (GE Private)
+      if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRBigEndian )
+      {
+         gdcmVerboseMacro("Tansfer Syntax = Explicit VR - Big Endian");
+         SwitchByteSwapCode();
+      }
    }
 }
 
index 3b33d635d087ac5c18f07dbe883da8bb13ca5147..8d4425fa1b4f01f1eabee0f7e9738fd0f1c58e19 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/11 22:46:22 $
-  Version:   $Revision: 1.82 $
+  Date:      $Date: 2005/01/11 23:06:35 $
+  Version:   $Revision: 1.83 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -121,7 +121,10 @@ public:
 
    void LoadDocEntrySafe(DocEntry *entry);
    TagDocEntryHT *BuildFlatHashTable();
-      
+
+   /// Return the Transfer Syntax as a string
+   std::string GetTransferSyntaxName();
+
 protected:
 // Methods
    // Constructor and destructor are protected to forbid end user 
index bc79a67529d62409f16936ade3ec814f1ecbcae5..b5b3b07afc4f050ee386c8d8a574ed27e313d6a6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/11 20:49:44 $
-  Version:   $Revision: 1.230 $
+  Date:      $Date: 2005/01/11 23:06:35 $
+  Version:   $Revision: 1.231 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1193,39 +1193,6 @@ int Header::GetLUTNbits()
    return lutNbits;
 }
 
-/**
- * \brief Accesses the info from 0002,0010 : Transfer Syntax and TS
- *        else 1.
- * @return The full Transfer Syntax Name (as opposed to Transfer Syntax UID)
- */
-std::string Header::GetTransferSyntaxName()
-{
-   // use the TS (TS : Transfer Syntax)
-   std::string transferSyntax = GetEntry(0x0002,0x0010);
-
-   if ( transferSyntax == GDCM_NOTLOADED )
-   {
-      gdcmVerboseMacro( "Transfer Syntax not loaded. " << std::endl
-               << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" );
-      return "Uncompressed ACR-NEMA";
-   }
-   if ( transferSyntax == GDCM_UNFOUND )
-   {
-      gdcmVerboseMacro( "Unfound Transfer Syntax (0002,0010)");
-      return "Uncompressed ACR-NEMA";
-   }
-
-   while ( ! isdigit((unsigned char)transferSyntax[transferSyntax.length()-1]) )
-   {
-      transferSyntax.erase(transferSyntax.length()-1, 1);
-   }
-   // we do it only when we need it
-   TS* ts         = Global::GetTS();
-   std::string tsName = ts->GetValue( transferSyntax );
-
-   //delete ts; /// \todo Seg Fault when deleted ?!
-   return tsName;
-}
 
 //-----------------------------------------------------------------------------
 // Protected
index 5d8037ba2d45d224ca0e90bf0add81797fbea56e..87a10f130f0fc6d296d82dc60fc3883f8878adc2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmHeader.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/11 15:15:38 $
-  Version:   $Revision: 1.99 $
+  Date:      $Date: 2005/01/11 23:06:35 $
+  Version:   $Revision: 1.100 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -159,9 +159,6 @@ public:
    bool   HasLUT();
    int    GetLUTNbits();
 
-   /// Return the Transfer Syntax as a string
-   std::string GetTransferSyntaxName();
-
    /// Accessor to \ref Header::GrPixel
    uint16_t GetGrPixel()  { return GrPixel; }