X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmFile.cxx;h=ffa7ae08bb998bb79502119382fcd58471e55adf;hb=d0dd94b3bab6007ec04534a451f456ceebd6dca7;hp=aa6db0bd2c5a347c4e1cd9e77a0caa20b254a1b0;hpb=86db5f0e37e40668ff8afea3f65f3b5213707115;p=gdcm.git diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index aa6db0bd..ffa7ae08 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/26 17:17:31 $ - Version: $Revision: 1.202 $ + Date: $Date: 2005/01/28 15:10:56 $ + Version: $Revision: 1.205 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -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); + } + } } } @@ -157,14 +173,21 @@ bool File::Write(std::string fileName, FileType filetype) return false; } + // Entry : 0002|0000 = group length -> recalculated + ValEntry *e0002 = GetValEntry(0x0002,0x0000); + if( e0002 ) + { + std::ostringstream sLen; + sLen << ComputeGroup0002Length(filetype); + e0002->SetValue(sLen.str()); + } + // Bits Allocated if ( GetEntryValue(0x0028,0x0100) == "12") { SetValEntry("16", 0x0028,0x0100); } - /// \todo correct 'Pixel group' Length if necessary - int i_lgPix = GetEntryLength(GrPixel, NumPixel); if (i_lgPix != -2) { @@ -178,7 +201,6 @@ bool File::Write(std::string fileName, FileType filetype) // (or in future gdcmPixelData class) // Drop Palette Color, if necessary - if ( GetEntryValue(0x0028,0x0002).c_str()[0] == '3' ) { // if SamplesPerPixel = 3, sure we don't need any LUT ! @@ -1347,10 +1369,10 @@ void File::InitializeDefaultFile() std::string time = Util::GetCurrentTime(); std::string uid = Util::CreateUniqueUID(); std::string uidMedia = uid; - std::string uidClass = uid + ".1"; - std::string uidInst = uid + ".10"; - std::string uidStudy = uid + ".100"; - std::string uidSerie = uid + ".1000"; + std::string uidInst = uid; + std::string uidClass = Util::CreateUniqueUID(); + std::string uidStudy = Util::CreateUniqueUID(); + std::string uidSerie = Util::CreateUniqueUID(); static DICOM_DEFAULT_VALUE defaultvalue[] = { { "146 ", 0x0002, 0x0000}, // Meta Element Group Length // FIXME: how to recompute ? @@ -1404,7 +1426,6 @@ void File::InitializeDefaultFile() } } - //----------------------------------------------------------------------------- // Private /**