X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDocument.cxx;h=fed9a8ca3c22d68b511aad325964cdc7e55a6d78;hb=80dc5ecf0d3915f6c2a5505a540ff14957e07cc5;hp=eecf1488eec98e24886dd1318128bcdd573f462b;hpb=3f8964856e65c2447beab900b04a63d003192bf9;p=gdcm.git diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index eecf1488..fed9a8ca 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2005/11/15 10:30:46 $ - Version: $Revision: 1.328 $ + Date: $Date: 2006/01/31 11:32:06 $ + Version: $Revision: 1.337 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -33,6 +33,10 @@ #include // for isdigit #include // for atoi +#if defined(__BORLANDC__) + #include // for memset +#endif + namespace gdcm { //----------------------------------------------------------------------------- @@ -89,17 +93,6 @@ bool Document::Load( ) return false; } return DoTheLoadingDocumentJob( ); -} -/** - * \brief Loader. (DEPRECATED : not to break the API) - * @param fileName 'Document' (File or DicomDir) to be open for parsing - * @return false if file cannot be open or no swap info was found, - * or no tag was found. - */ -bool Document::Load( std::string const &fileName ) -{ - Filename = fileName; - return DoTheLoadingDocumentJob( ); } /** @@ -994,6 +987,33 @@ int Document::ComputeGroup0002Length( ) return groupLength; } +/** + * \brief CallStartMethod + */ +void Document::CallStartMethod() +{ + Progress = 0.0f; + Abort = false; + CommandManager::ExecuteCommand(this,CMD_STARTPROGRESS); +} + +/** + * \brief CallProgressMethod + */ +void Document::CallProgressMethod() +{ + CommandManager::ExecuteCommand(this,CMD_PROGRESS); +} + +/** + * \brief CallEndMethod + */ +void Document::CallEndMethod() +{ + Progress = 1.0f; + CommandManager::ExecuteCommand(this,CMD_ENDPROGRESS); +} + //----------------------------------------------------------------------------- // Private /** @@ -1025,7 +1045,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, bool delim_mode_intern = delim_mode; bool first = true; gdcmDebugMacro( "Enter in ParseDES, delim-mode " << delim_mode - << " at offset " << std::hex << offset ); + << " at offset " << std::hex << "0x(" << offset << ")" ); while (true) { if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) @@ -1072,8 +1092,8 @@ void Document::ParseDES(DocEntrySet *set, long offset, { gdcmDebugMacro( "in ParseDES : cannot add a DataEntry " << newDataEntry->GetKey() - << " (at offset : " - << newDataEntry->GetOffset() << " )" ); + << " (at offset : 0x(" + << newDataEntry->GetOffset() << ") )" ); used=false; } else @@ -1082,7 +1102,6 @@ void Document::ParseDES(DocEntrySet *set, long offset, // Load only if we can add (not a duplicate key) LoadDocEntry( newDataEntry ); } - if ( newDataEntry->GetElement() == 0x0000 ) // if on group length { if ( newDataEntry->GetGroup()%2 != 0 ) // if Shadow Group @@ -1090,8 +1109,9 @@ void Document::ParseDES(DocEntrySet *set, long offset, if ( LoadMode & LD_NOSHADOW ) // if user asked to skip shad.gr { std::string strLgrGroup = newDataEntry->GetString(); + int lgrGroup; - if ( newDataEntry->IsUnfound() ) + //if ( newDataEntry->IsUnfound() ) /?!? JPR { lgrGroup = atoi(strLgrGroup.c_str()); Fp->seekg(lgrGroup, std::ios::cur); @@ -1180,8 +1200,8 @@ void Document::ParseDES(DocEntrySet *set, long offset, { // Don't try to parse zero-length sequences gdcmDebugMacro( "Entry in ParseSQ, delim " << delim_mode_intern - << " at offset " << std::hex - << newDocEntry->GetOffset() ); + << " at offset 0x(" << std::hex + << newDocEntry->GetOffset() << ")"); ParseSQ( newSeqEntry, newDocEntry->GetOffset(), @@ -1194,8 +1214,8 @@ void Document::ParseDES(DocEntrySet *set, long offset, { gdcmWarningMacro( "in ParseDES : cannot add a SeqEntry " << newSeqEntry->GetKey() - << " (at offset : " - << newSeqEntry->GetOffset() << " )" ); + << " (at offset : 0x(" + << newSeqEntry->GetOffset() << ") )" ); used = false; } else @@ -1306,8 +1326,8 @@ DocEntry *Document::Backtrack(DocEntry *docEntry) long offset = PreviousDocEntry->GetOffset(); gdcmDebugMacro( "Backtrack :" << std::hex << group - << "|" << elem - << " at offset " << offset ); + << "|" << elem + << " at offset 0x(" <seekg(positionOnEntry, std::ios::beg); return GDCM_VRUNKNOWN; } @@ -2014,6 +2034,10 @@ DocEntry *Document::ReadNextDocEntry() { realVR = "UL"; // must be UL } + // Commented out in order not to generate 'Shadow Groups' where some + // Data Elements are Explicit VR and some other ones Implicit VR + // (Stupid MatLab DICOM Reader couln't read gdcm-written images) + /* else if (CurrentGroup%2 == 1 && (CurrentElem >= 0x0010 && CurrentElem <=0x00ff )) { @@ -2021,6 +2045,7 @@ DocEntry *Document::ReadNextDocEntry() // (gggg-0010->00FF where gggg is odd) attributes have to be LO realVR = "LO"; } + */ else { DictEntry *dictEntry = GetDictEntry(CurrentGroup,CurrentElem); @@ -2140,17 +2165,6 @@ void Document::HandleOutOfGroup0002(uint16_t &group, uint16_t &elem) // if Transfer Syntax is Big Endian we have to change CheckSwap std::string ts = GetTransferSyntax(); - if ( ts == GDCM_UNKNOWN ) - { - gdcmDebugMacro("True DICOM File, with NO Transfer Syntax (?!) " ); - return; - } - if ( !Global::GetTS()->IsTransferSyntax(ts) ) - { - gdcmWarningMacro("True DICOM File, with illegal Transfer Syntax: [" - << ts << "]"); - return; - } // Group 0002 is always 'Explicit ...' // even when Transfer Syntax says 'Implicit ..." @@ -2162,7 +2176,7 @@ void Document::HandleOutOfGroup0002(uint16_t &group, uint16_t &elem) } // FIXME Strangely, this works with - //'Implicit VR BigEndian Transfer Syntax (GE Private) + //'Implicit VR BigEndian Transfer Syntax' (GE Private) // // --> Probabely normal, since we considered we never have // to trust manufacturers. @@ -2177,6 +2191,33 @@ void Document::HandleOutOfGroup0002(uint16_t &group, uint16_t &elem) group = SwapShort(group); elem = SwapShort(elem); } + + /// \todo find a trick to warn user and stop processing + + if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == + TS::DeflatedExplicitVRLittleEndian) + { + gdcmWarningMacro("Transfer Syntax [" + << GetTransferSyntaxName() << "] :" + << " not yet dealt with "); + return; + } + + // The following shouldn't occur very often + // Let's check at the very end. + + if ( ts == GDCM_UNKNOWN ) + { + gdcmDebugMacro("True DICOM File, with NO Transfer Syntax (?!) " ); + return; + } + + if ( !Global::GetTS()->IsTransferSyntax(ts) ) + { + gdcmWarningMacro("True DICOM File, with illegal Transfer Syntax: [" + << ts << "]"); + return; + } } }