X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=src%2FgdcmFile.cxx;h=0b31c5ceeb8f72673aa04a509621f78af1693aad;hb=bbfa3cf89fc2ede7c43259e945f021044b56069f;hp=6fc5a059a97cc4939eaaffde8bc6018c0af47efc;hpb=dfd2b1cd2925e77ef9466cfb2fc71706c84a418c;p=gdcm.git diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 6fc5a059..0b31c5ce 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/01/28 10:34:28 $ - Version: $Revision: 1.204 $ + Date: $Date: 2005/02/02 10:02:17 $ + Version: $Revision: 1.207 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -37,8 +37,8 @@ namespace gdcm * \brief Constructor * @param filename name of the file whose header we want to analyze */ -File::File( std::string const &filename ): - Document( filename ) +File::File( std::string const &filename ) + :Document( filename ) { RLEInfo = new RLEFramesInfo; JPEGInfo = new JPEGFragmentsInfo; @@ -99,21 +99,37 @@ File::File( std::string const &filename ): ComputeJPEGFragmentInfo(); CloseFile(); - // Change the created dict entry - std::string PixelVR; - // 8 bits allocated is a 'O Bytes' , as well as 24 (old ACR-NEMA RGB) - // more than 8 (i.e 12, 16) is a 'O Words' - if ( GetBitsAllocated() == 8 || GetBitsAllocated() == 24 ) - PixelVR = "OB"; - else - PixelVR = "OW"; + // Create a new BinEntry to change the the DictEntry + // The changed DictEntry will have + // - a correct PixelVR OB or OW) + // - a VM to "PXL" + // - the name to "Pixel Data" + BinEntry *oldEntry = dynamic_cast(entry); + if(oldEntry) + { + std::string PixelVR; + // 8 bits allocated is a 'O Bytes' , as well as 24 (old ACR-NEMA RGB) + // more than 8 (i.e 12, 16) is a 'O Words' + if ( GetBitsAllocated() == 8 || GetBitsAllocated() == 24 ) + PixelVR = "OB"; + else + PixelVR = "OW"; + + // Change only made if usefull + if( PixelVR != oldEntry->GetVR() ) + { + DictEntry* newDict = NewVirtualDictEntry(GrPixel,NumPixel, + PixelVR,"1","Pixel Data"); - DictEntry* newEntry = NewVirtualDictEntry(GrPixel, NumPixel, - PixelVR, "PXL", "Pixel Data"); + BinEntry *newEntry = new BinEntry(newDict); + newEntry->Copy(entry); + newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea()); + oldEntry->SetSelfArea(false); - // friend class hunting : should we *create* a new entry, - // instead of modifying its DictEntry,in order not to use 'friend' ? - entry->SetDictEntry( newEntry ); + RemoveEntry(oldEntry); + AddEntry(newEntry); + } + } } } @@ -139,6 +155,8 @@ File::~File () delete JPEGInfo; } +//----------------------------------------------------------------------------- +// Public /** * \brief Performs some consistency checking on various 'File related' * (as opposed to 'DicomDir related') entries @@ -230,7 +248,7 @@ bool File::Write(std::string fileName, FileType filetype) BinEntry *b = GetBinEntry(GrPixel,NumPixel); if ( GetPixelSize() == 16 ) { - uint16_t *im16 = (uint16_t*)b->GetBinArea(); + uint16_t *im16 = (uint16_t *)b->GetBinArea(); int lgr = b->GetLength(); for( int i = 0; i < lgr / 2; i++ ) { @@ -240,7 +258,7 @@ bool File::Write(std::string fileName, FileType filetype) #endif //GDCM_WORDS_BIGENDIAN */ - Document::WriteContent(fp,filetype); + Document::WriteContent(fp, filetype); /* #ifdef GDCM_WORDS_BIGENDIAN @@ -263,13 +281,6 @@ bool File::Write(std::string fileName, FileType filetype) return true; } -//----------------------------------------------------------------------------- -// Print - - -//----------------------------------------------------------------------------- -// Public - /** * \brief This predicate, based on hopefully reasonable heuristics, * decides whether or not the current File was properly parsed @@ -917,7 +928,7 @@ int File::GetBitsAllocated() */ int File::GetSamplesPerPixel() { - const std::string& strSize = GetEntryValue(0x0028,0x0002); + const std::string &strSize = GetEntryValue(0x0028,0x0002); if ( strSize == GDCM_UNFOUND ) { gdcmVerboseMacro( "(0028,0002) is supposed to be mandatory"); @@ -934,7 +945,7 @@ int File::GetSamplesPerPixel() */ bool File::IsMonochrome() { - const std::string& PhotometricInterp = GetEntryValue( 0x0028, 0x0004 ); + const std::string &PhotometricInterp = GetEntryValue( 0x0028, 0x0004 ); if ( Util::DicomStringEqual(PhotometricInterp, "MONOCHROME1") || Util::DicomStringEqual(PhotometricInterp, "MONOCHROME2") ) { @@ -1664,5 +1675,7 @@ void File::ReadAndSkipEncapsulatedBasicOffsetTable() } //----------------------------------------------------------------------------- +// Print +//----------------------------------------------------------------------------- } // end namespace gdcm