-/**
- * \brief during parsing, Header Elements too long are not loaded in memory
- * @param newSize
- */
-void Document::SetMaxSizeLoadEntry(long newSize)
-{
- if ( newSize < 0 )
- {
- return;
- }
- if ((uint32_t)newSize >= (uint32_t)0xffffffff )
- {
- MaxSizeLoadEntry = 0xffffffff;
- return;
- }
- MaxSizeLoadEntry = newSize;
-}
-
-
-/**
- * \brief Header Elements too long will not be printed
- * \todo See comments of \ref Document::MAX_SIZE_PRINT_ELEMENT_VALUE
- * @param newSize
- */
-void Document::SetMaxSizePrintEntry(long newSize)
-{
- if ( newSize < 0 )
- {
- return;
- }
- if ((uint32_t)newSize >= (uint32_t)0xffffffff )
- {
- MaxSizePrintEntry = 0xffffffff;
- return;
- }
- MaxSizePrintEntry = newSize;
-}
-
-
-
-/**
- * \brief Handle broken private tag from Philips NTSCAN
- * where the endianess is being switch to BigEndian for no
- * apparent reason
- * @return no return
- */
-void Document::HandleBrokenEndian(uint16_t &group, uint16_t &elem)
-{
- // Endian reversion. Some files contain groups of tags with reversed endianess.
- static int reversedEndian = 0;
- // try to fix endian switching in the middle of headers
- if ((group == 0xfeff) && (elem == 0x00e0))
- {
- // start endian swap mark for group found
- reversedEndian++;
- SwitchByteSwapCode();
- // fix the tag
- group = 0xfffe;
- elem = 0xe000;
- }
- else if (group == 0xfffe && elem == 0xe00d && reversedEndian)
- {
- // end of reversed endian group
- reversedEndian--;
- SwitchByteSwapCode();
- }
-}
-
-/**
- * \brief Accesses the info from 0002,0010 : Transfer Syntax and TS
- * @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.find(GDCM_NOTLOADED) < transferSyntax.length()) )
- {
- gdcmErrorMacro( "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";
- }
-
- // we do it only when we need it
- const TSKey &tsName = Global::GetTS()->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
- * @return no return
- */
-void Document::HandleOutOfGroup0002(uint16_t &group, uint16_t &elem)
-{
- // Endian reversion. Some files contain groups of tags with reversed endianess.
- if ( !Group0002Parsed && group != 0x0002)
- {
- Group0002Parsed = true;
- // we just came out of group 0002
- // if Transfer syntax is Big Endian we have to change CheckSwap
-
- std::string ts = GetTransferSyntax();
- if ( !Global::GetTS()->IsTransferSyntax(ts) )
- {
- gdcmVerboseMacro("True DICOM File, with NO Tansfer Syntax: " << ts );
- return;
- }
-
- // Group 0002 is always 'Explicit ...' enven when Transfer Syntax says 'Implicit ..."
-
- if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRLittleEndian )
- {
- Filetype = ImplicitVR;
- }
-
- // FIXME Strangely, this works with
- //'Implicit VR Transfer Syntax (GE Private)
- if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRBigEndian )
- {
- gdcmVerboseMacro("Transfer Syntax Name = ["
- << GetTransferSyntaxName() << "]" );
- SwitchByteSwapCode();
- group = SwapShort(group);
- elem = SwapShort(elem);
- }