X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDocument.cxx;h=bb3d81df1addaf1a83701eaae7d61b31a299731d;hb=033352f8a0d333fc12b7fa625d1819a574f4ddef;hp=4adb7d947cdd844e3130db7fd7f217ce7b449da0;hpb=130558c1fc10cbc2d5d58484b310fa86bd20d81b;p=gdcm.git diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 4adb7d94..bb3d81df 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/01/18 18:03:16 $ - Version: $Revision: 1.198 $ + Date: $Date: 2005/01/20 11:37:37 $ + Version: $Revision: 1.203 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -63,9 +63,12 @@ const unsigned int Document::MAX_SIZE_PRINT_ELEMENT_VALUE = 0x7fffffff; */ Document::Document( std::string const &filename ) : ElementSet(-1) { + RLEInfo = NULL; + JPEGInfo = NULL; + SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE); Filename = filename; - Initialise(); + Initialize(); Fp = 0; if ( !OpenFile() ) @@ -159,10 +162,13 @@ Document::Document( std::string const &filename ) : ElementSet(-1) */ Document::Document() : ElementSet(-1) { + RLEInfo = NULL; + JPEGInfo = NULL; + Fp = 0; SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE); - Initialise(); + Initialize(); SwapCode = 1234; Filetype = ExplicitVR; Group0002Parsed = false; @@ -176,8 +182,10 @@ Document::~Document () RefPubDict = NULL; RefShaDict = NULL; - delete RLEInfo; - delete JPEGInfo; + if( RLEInfo ) + delete RLEInfo; + if( JPEGInfo ) + delete JPEGInfo; } //----------------------------------------------------------------------------- @@ -409,7 +417,7 @@ bool Document::CloseFile() Fp = 0; } - return true; //FIXME how do we detect a non-close ifstream ? + return true; //FIXME how do we detect a non-closed ifstream ? } /** @@ -620,7 +628,6 @@ SeqEntry *Document::ReplaceOrCreate( uint16_t group, uint16_t elem) } } } - // Create a new seqEntry if necessary if (!seqEntry) { @@ -634,7 +641,6 @@ SeqEntry *Document::ReplaceOrCreate( uint16_t group, uint16_t elem) return NULL; } } - return seqEntry; } @@ -839,8 +845,8 @@ void *Document::GetEntryBinArea(uint16_t group, uint16_t elem) } /** - * \brief Loads (from disk) the element content - * when a string is not suitable + * \brief Loads (from disk) the element content + * when a string is not suitable * @param group group number of the Entry * @param elem element number of the Entry */ @@ -859,8 +865,8 @@ void Document::LoadEntryBinArea(uint16_t group, uint16_t elem) } /** - * \brief Loads (from disk) the element content - * when a string is not suitable + * \brief Loads (from disk) the element content + * when a string is not suitable * @param elem Entry whose binArea is going to be loaded */ void Document::LoadEntryBinArea(BinEntry *elem) @@ -922,94 +928,6 @@ void Document::LoadEntryBinArea(BinEntry *elem) return false; }*/ -/** - * \brief retrieves a Dicom Element using (group, element) - * @param group Group number of the searched Dicom Element - * @param elem Element number of the searched Dicom Element - * @return - */ -DocEntry *Document::GetDocEntry(uint16_t group, uint16_t elem) -{ - TagKey key = DictEntry::TranslateToKey(group, elem); - if ( !TagHT.count(key)) - { - return NULL; - } - return TagHT.find(key)->second; -} - -/** - * \brief Same as \ref Document::GetDocEntry except it only - * returns a result when the corresponding entry is of type - * ValEntry. - * @param group Group number of the searched Dicom Element - * @param elem Element number of the searched Dicom Element - * @return When present, the corresponding ValEntry. - */ -ValEntry *Document::GetValEntry(uint16_t group, uint16_t elem) -{ - DocEntry *currentEntry = GetDocEntry(group, elem); - if ( !currentEntry ) - { - return 0; - } - if ( ValEntry *entry = dynamic_cast(currentEntry) ) - { - return entry; - } - gdcmVerboseMacro( "Unfound ValEntry."); - - return 0; -} - -/** - * \brief Same as \ref Document::GetDocEntry except it only - * returns a result when the corresponding entry is of type - * BinEntry. - * @param group Group number of the searched Dicom Element - * @param elem Element number of the searched Dicom Element - * @return When present, the corresponding BinEntry. - */ -BinEntry *Document::GetBinEntry(uint16_t group, uint16_t elem) -{ - DocEntry *currentEntry = GetDocEntry(group, elem); - if ( !currentEntry ) - { - return 0; - } - if ( BinEntry *entry = dynamic_cast(currentEntry) ) - { - return entry; - } - gdcmVerboseMacro( "Unfound BinEntry."); - - return 0; -} - -/** - * \brief Same as \ref Document::GetDocEntry except it only - * returns a result when the corresponding entry is of type - * SeqEntry. - * @param group Group number of the searched Dicom Element - * @param elem Element number of the searched Dicom Element - * @return When present, the corresponding SeqEntry. - */ -SeqEntry *Document::GetSeqEntry(uint16_t group, uint16_t elem) -{ - DocEntry *currentEntry = GetDocEntry(group, elem); - if ( !currentEntry ) - { - return 0; - } - if ( SeqEntry *entry = dynamic_cast(currentEntry) ) - { - return entry; - } - gdcmVerboseMacro( "Unfound SeqEntry."); - - return 0; -} - /** * \brief Loads the element while preserving the current @@ -1307,7 +1225,7 @@ void Document::ParseSQ( SeqEntry *seqEntry, { if ( newDocEntry->IsSequenceDelimitor() ) { - seqEntry->SetSequenceDelimitationItem( newDocEntry ); + seqEntry->SetDelimitationItem( newDocEntry ); break; } } @@ -1350,7 +1268,7 @@ void Document::ParseSQ( SeqEntry *seqEntry, offsetStartCurrentSQItem = Fp->tellg(); // end try ----------------- - seqEntry->AddEntry( itemSQ, SQItemNumber ); + seqEntry->AddSQItem( itemSQ, SQItemNumber ); SQItemNumber++; if ( !delim_mode && ((long)(Fp->tellg())-offset ) >= l_max ) { @@ -1625,34 +1543,33 @@ void Document::FindDocEntryLength( DocEntry *entry ) // hands on a big endian encoded file: we switch the swap code to // big endian and proceed... - // - // if ( element == 0x0000 && length16 == 0x0400 ) - // { - // std::string ts = GetTransferSyntax(); - // if ( Global::GetTS()->GetSpecialTransferSyntax(ts) - // != TS::ExplicitVRBigEndian ) - // { - // throw FormatError( "Document::FindDocEntryLength()", - // " not explicit VR." ); - // return; - // } - // length16 = 4; - // SwitchByteSwapCode(); - - // Restore the unproperly loaded values i.e. the group, the element - // and the dictionary entry depending on them. -// uint16_t correctGroup = SwapShort( entry->GetGroup() ); +// if ( element == 0x0000 && length16 == 0x0400 ) +// { +// std::string ts = GetTransferSyntax(); +// if ( Global::GetTS()->GetSpecialTransferSyntax(ts) +// != TS::ExplicitVRBigEndian ) +// { +// throw FormatError( "Document::FindDocEntryLength()", +// " not explicit VR." ); +// return; +// } +// length16 = 4; +// SwitchByteSwapCode(); +// +// // Restore the unproperly loaded values i.e. the group, the element +// // and the dictionary entry depending on them. +// uint16_t correctGroup = SwapShort( entry->GetGroup() ); // uint16_t correctElem = SwapShort( entry->GetElement() ); -// DictEntry *newTag = GetDictEntry( correctGroup, correctElem ); if ( !newTag ) +// DictEntry *newTag = GetDictEntry( correctGroup, correctElem ); +// if ( !newTag ) // { - // This correct tag is not in the dictionary. Create a new one. +// // This correct tag is not in the dictionary. Create a new one. // newTag = NewVirtualDictEntry(correctGroup, correctElem); // } - // FIXME this can create a memory leaks on the old entry that be - // left unreferenced. +// // FIXME this can create a memory leaks on the old entry that be +// // left unreferenced. // entry->SetDictEntry( newTag ); // } - // 0xffff means that we deal with 'No Length' Sequence // or 'No Length' SQItem @@ -2122,7 +2039,7 @@ void Document::SkipBytes(uint32_t nBytes) * \brief Loads all the needed Dictionaries * \warning NOT end user intended method ! */ -void Document::Initialise() +void Document::Initialize() { RefPubDict = Global::GetDicts()->GetDefaultPubDict(); RefShaDict = NULL;