X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDocument.cxx;h=fc405eef2fa89450ea156c66e756ad751e0eba5a;hb=4822f705ce310f318fd342fdcf00024f9a44acd4;hp=4a82467dc7b63a8d593423cf383a59db1c249745;hpb=6a7c2fbcb5bfc240a3b9875ad4836f5dc058e069;p=gdcm.git diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 4a82467d..fc405eef 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/10/20 15:24:09 $ - Version: $Revision: 1.301 $ + Date: $Date: 2005/10/26 06:09:34 $ + Version: $Revision: 1.308 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -605,7 +605,7 @@ void Document::WriteContent(std::ofstream *fp, FileType filetype) // Skip if user wants to write an ACR-NEMA file if ( filetype == ImplicitVR || filetype == ExplicitVR || - filetype == JPEG ) + filetype == JPEG ) { // writing Dicom File Preamble char filePreamble[128]; @@ -660,7 +660,7 @@ void Document::LoadEntryBinArea(uint16_t group, uint16_t elem) /** * \brief Loads (from disk) the element content * when a string is not suitable - * @param elem Entry whose binArea is going to be loaded + * @param entry Entry whose binArea is going to be loaded */ void Document::LoadEntryBinArea(DataEntry *entry) { @@ -684,7 +684,7 @@ void Document::LoadEntryBinArea(DataEntry *entry) return; } - // Read the datas + // Read the data Fp->read((char*)data, l); if ( Fp->fail() || Fp->eof() ) { @@ -718,7 +718,7 @@ void Document::LoadEntryBinArea(DataEntry *entry) } case 8: { - gdcmWarningMacro("Can't swap 64 bits datas"); + gdcmWarningMacro("Can't swap 64 bits data"); /* uint64_t *data64 = (uint64_t *)data; for(i=0;iGetVR(); + + // Useless checking, now ! + /* if ( Filetype == ExplicitVR && !Global::GetVR()->IsVROfBinaryRepresentable(vr) ) { ////// No DataEntry: should mean UNKOWN VR gdcmWarningMacro( std::hex << newDocEntry->GetGroup() << "|" << newDocEntry->GetElement() - << " : No DataEntry." - "Probably unknown VR."); + << " : unknown VR." + " Probably 'Implicit VR' entry within " + "an explicit VR 'document'."); } + */ if ( !set->AddEntry( newDataEntry ) ) { @@ -1019,6 +1025,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, } else { + newDataEntry->Delete(); // Load only if we can add (not a duplicate key) LoadDocEntry( newDataEntry ); } @@ -1051,7 +1058,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, (!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) ) { if ( !used ) - delete newDocEntry; + newDocEntry->Delete(); break; } @@ -1081,7 +1088,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, if ( newDocEntry->GetGroup()%2 != 0 ) { Fp->seekg( l, std::ios::cur); - delete newDocEntry; // Delete, not in the set + newDocEntry->Delete(); // Delete, not in the set continue; } } @@ -1089,7 +1096,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, { // User asked to skip *any* SeQuence Fp->seekg( l, std::ios::cur); - delete newDocEntry; // Delete, not in the set + newDocEntry->Delete(); // Delete, not in the set continue; } // delay the dynamic cast as late as possible @@ -1138,18 +1145,22 @@ void Document::ParseDES(DocEntrySet *set, long offset, << newSeqEntry->GetOffset() << " )" ); used = false; } + else + { + newDocEntry->Delete(); + } if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) { if ( !used ) - delete newDocEntry; - break; + newDocEntry->Delete(); + break; } } // end SeqEntry : VR = "SQ" if ( !used ) { - delete newDocEntry; + newDocEntry->Delete(); } first = false; } // end While @@ -1183,16 +1194,17 @@ void Document::ParseSQ( SeqEntry *seqEntry, if ( newDocEntry->IsSequenceDelimitor() ) { seqEntry->SetDelimitationItem( newDocEntry ); + newDocEntry->Delete(); break; } } if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) { - delete newDocEntry; + newDocEntry->Delete(); break; } // create the current SQItem - SQItem *itemSQ = new SQItem( seqEntry->GetDepthLevel() ); + SQItem *itemSQ = SQItem::New( seqEntry->GetDepthLevel() ); unsigned int l = newDocEntry->GetReadLength(); if ( l == 0xffffffff ) @@ -1206,7 +1218,6 @@ void Document::ParseSQ( SeqEntry *seqEntry, // Let's try :------------ // remove fff0,e000, created out of the SQItem - delete newDocEntry; Fp->seekg(offsetStartCurrentSQItem, std::ios::beg); // fill up the current SQItem, starting at the beginning of fff0,e000 @@ -1216,6 +1227,8 @@ void Document::ParseSQ( SeqEntry *seqEntry, // end try ----------------- seqEntry->AddSQItem( itemSQ, SQItemNumber ); + itemSQ->Delete(); + newDocEntry->Delete(); SQItemNumber++; if ( !delim_mode && ((long)(Fp->tellg())-offset ) >= l_max ) { @@ -1234,7 +1247,7 @@ DocEntry *Document::Backtrack(DocEntry *docEntry) { // delete the Item Starter, built erroneously out of any Sequence // it's not yet in the HTable/chained list - delete docEntry; + docEntry->Delete(); // Get all info we can from PreviousDocEntry uint16_t group = PreviousDocEntry->GetGroup(); @@ -1489,7 +1502,7 @@ VRKey Document::FindDocEntryVR() VRKey vr; Fp->read(&(vr[0]),(size_t)2); - gdcmDebugMacro( "--> VR: " << vr ) + //gdcmDebugMacro( "--> VR: " << vr ) if ( !CheckDocEntryVR(vr) ) { gdcmWarningMacro( "Unknown VR '" << vr << "'" ) @@ -1969,7 +1982,7 @@ DocEntry *Document::ReadNextDocEntry() } } } - gdcmDebugMacro( "Found VR: " << vr << " / Real VR: " << realVR ); + // gdcmDebugMacro( "Found VR: " << vr << " / Real VR: " << realVR ); DocEntry *newEntry; if ( Global::GetVR()->IsVROfSequence(realVR) ) @@ -2006,7 +2019,7 @@ DocEntry *Document::ReadNextDocEntry() catch ( FormatError ) { // Call it quits - delete newEntry; + newEntry->Delete(); return 0; }