Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/01/11 22:05:22 $
- Version: $Revision: 1.177 $
+ 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
SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE);
Initialise();
- SwapCode = 0;
+ SwapCode = 1234;
Filetype = ExplicitVR;
Group0002Parsed = false;
}
{
switch (SwapCode)
{
- case 0 :
+ case 1234 :
break;
case 4321 :
a=( ((a<<24) & 0xff000000) | ((a<<8) & 0x00ff0000) |
}
else
{
- SwapCode = 0;
+ SwapCode = 1234;
gdcmVerboseMacro( "HostByteOrder = NetworkByteOrder");
}
Filetype = ACR;
return true;
case 0x00000004 :
- SwapCode = 0;
+ SwapCode = 1234;
Filetype = ACR;
return true;
default :
case 0x0006 :
case 0x0007 :
case 0x0008 :
- SwapCode = 0;
+ SwapCode = 1234;
Filetype = ACR;
return true;
case 0x0100 :
}
// Then the only info we have is the net2host one.
//if (! net2host )
- // SwapCode = 0;
+ // SwapCode = 1234;
//else
// SwapCode = 4321;
//return;
void Document::SwitchByteSwapCode()
{
gdcmVerboseMacro( "Switching Byte Swap code.");
- if ( SwapCode == 0 )
+ if ( SwapCode == 1234 )
{
SwapCode = 4321;
}
else if ( SwapCode == 4321 )
{
- SwapCode = 0;
+ SwapCode = 1234;
}
else if ( SwapCode == 3412 )
{
* apparent reason
* @return no return
*/
-void Document::HandleBrokenEndian(uint16_t group, uint16_t elem)
+void Document::HandleBrokenEndian(uint16_t &group, uint16_t &elem)
{
// Endian reversion. Some files contain groups of tags with reversed endianess.
static int reversedEndian = 0;
}
}
+/**
+ * \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
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();
+ }
}
}