X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmFile.cxx;h=def9a2ba8bd8d53bbc5f7e4c4f92232d073eea79;hb=4331b970c740503e6827e72a172101a86d630907;hp=fe54402e1fddbfd7358d8603e2c873d0032decce;hpb=1d9ac5cec02b9daa18b16835882b531731b125ad;p=gdcm.git diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index fe54402e..def9a2ba 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 12:58:28 $ - Version: $Revision: 1.277 $ + Date: $Date: 2005/10/21 14:09:41 $ + Version: $Revision: 1.286 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -230,10 +230,11 @@ bool File::DoTheLoadingJob( ) // Change only made if usefull if ( PixelVR != oldEntry->GetVR() ) { - DictEntry* newDict = NewVirtualDictEntry(GrPixel,NumPixel, - PixelVR,"1","Pixel Data"); + DictEntry* newDict = DictEntry::New(GrPixel,NumPixel, + PixelVR,"1","Pixel Data"); DataEntry *newEntry = new DataEntry(newDict); + newDict->Delete(); newEntry->Copy(entry); newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea()); oldEntry->SetSelfArea(false); @@ -479,7 +480,7 @@ float File::GetXSpacing() } else { - gdcmWarningMacro( "Unfound Pixel Spacing (0018,1164)" ); + gdcmWarningMacro( "Unfound Imager Pixel Spacing (0018,1164)" ); } /* const std::string &strImagerPixelSpacing = GetEntryString(0x0018,0x1164); @@ -581,7 +582,7 @@ float File::GetYSpacing() } else { - gdcmWarningMacro( "Unfound Pixel Spacing (0018,1164)" ); + gdcmWarningMacro( "Unfound Imager Pixel Spacing (0018,1164)" ); } /* const std::string &strImagerPixelSpacing = GetEntryString(0x0018,0x1164); if ( strImagerPixelSpacing != GDCM_UNFOUND ) @@ -888,7 +889,6 @@ float File::GetZOrigin() entry = GetDataEntry(0x0020,0x0050); if( entry ) { - gdcmWarningMacro( "Unfound Location (0020,0050)"); if( entry->GetValueCount() == 1 ) return (float)entry->GetValue(0); gdcmWarningMacro( "Wrong Location (0020,0050)"); @@ -1570,7 +1570,7 @@ size_t File::GetPixelAreaLength() void File::AddAnonymizeElement (uint16_t group, uint16_t elem, std::string const &value) { - Element el; + DicomElement el; el.Group = group; el.Elem = elem; el.Value = value; @@ -1761,14 +1761,18 @@ bool File::Write(std::string fileName, FileType writetype) e0000->SetString(sLen.str()); } - int i_lgPix = GetEntryLength(GrPixel, NumPixel); - if (i_lgPix != -2) - { - // no (GrPixel, NumPixel) element - std::string s_lgPix = Util::Format("%d", i_lgPix+12); - s_lgPix = Util::DicomString( s_lgPix.c_str() ); - InsertEntryString(s_lgPix,GrPixel, 0x0000); - } + // Derma?.dcm does not have it...let's remove it FIXME FIXME + if( writetype != JPEG ) + { + int i_lgPix = GetEntryLength(GrPixel, NumPixel); + if (i_lgPix != -2) + { + // no (GrPixel, NumPixel) element + std::string s_lgPix = Util::Format("%d", i_lgPix+12); + s_lgPix = Util::DicomString( s_lgPix.c_str() ); + InsertEntryString(s_lgPix,GrPixel, 0x0000); + } + } Document::WriteContent(fp, writetype); @@ -1987,19 +1991,24 @@ bool File::ReadTag(uint16_t testGroup, uint16_t testElem) itemTagGroup = ReadInt16(); itemTagElem = ReadInt16(); } - catch ( FormatError /*e*/ ) + catch ( FormatError ) { - //std::cerr << e << std::endl; + gdcmErrorMacro( "Can not read tag for " + << " We should have found tag (" + << DictEntry::TranslateToKey(testGroup,testElem) << ")" + ) ; + return false; } if ( itemTagGroup != testGroup || itemTagElem != testElem ) { - gdcmWarningMacro( "Wrong Item Tag found:" + gdcmErrorMacro( "Wrong Item Tag found:" << " We should have found tag (" - << std::hex << testGroup << "," << testElem << ")" << std::endl + << DictEntry::TranslateToKey(testGroup,testElem) << ")" << std::endl << " but instead we encountered tag (" - << std::hex << itemTagGroup << "," << itemTagElem << ")" - << " at address: " << " 0x(" << (unsigned int)currentPosition << ")" + << DictEntry::TranslateToKey(itemTagGroup,itemTagElem) << ")" + << " at address: " << " 0x(" << std::hex + << (unsigned int)currentPosition << std::dec << ")" ) ; Fp->seekg(positionOnEntry, std::ios::beg); @@ -2027,17 +2036,17 @@ uint32_t File::ReadTagLength(uint16_t testGroup, uint16_t testElem) if ( !ReadTag(testGroup, testElem) ) { + gdcmErrorMacro( "ReadTag did not succeed for (" + << DictEntry::TranslateToKey(testGroup,testElem) + << ")..." ); return 0; } //// Then read the associated Item Length long currentPosition = Fp->tellg(); uint32_t itemLength = ReadInt32(); - { - gdcmWarningMacro( "Basic Item Length is: " - << itemLength << std::endl + gdcmDebugMacro( "Basic Item Length is: " << itemLength << " at address: " << std::hex << (unsigned int)currentPosition); - } return itemLength; } @@ -2084,7 +2093,7 @@ void File::ReadEncapsulatedBasicOffsetTable() // These are the deprecated method that one day should be removed (after the next release) #ifndef GDCM_LEGACY_REMOVE -/** +/* * * \brief Constructor (DEPRECATED : temporaryly kept not to break the API) * @param filename name of the file whose header we want to analyze * @deprecated do not use any longer @@ -2099,7 +2108,7 @@ File::File( std::string const &filename ) Load( ); // gdcm::Document is first Loaded, then the 'File part' } -/** +/* * * \brief Loader. (DEPRECATED : temporaryly kept not to break the API) * @param fileName file to be open for parsing * @return false if file cannot be open or no swap info was found,