X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=src%2FgdcmHeader.cxx;h=30f8cf4bd5a8cc09f1e99143a861f424cda52afc;hb=64ef25e1cadb4b840a4cedfe0adaddecb2d7ca42;hp=90299a8a0ab45d4a08a4d685b8f7533b1390f508;hpb=e6671b4378ba33a2cdf7c711e4e45250af74dbbc;p=gdcm.git diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 90299a8a..30f8cf4b 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeader.cxx,v $ Language: C++ - Date: $Date: 2004/07/31 23:30:04 $ - Version: $Revision: 1.181 $ + Date: $Date: 2004/09/20 18:14:23 $ + Version: $Revision: 1.187 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -30,12 +30,9 @@ /** * \brief Constructor * @param filename name of the file whose header we want to analyze - * @param exception_on_error whether we want to throw an exception or not */ -gdcmHeader::gdcmHeader( std::string const & filename, - bool exception_on_error ): - gdcmDocument( filename, - exception_on_error ) +gdcmHeader::gdcmHeader( std::string const & filename ): + gdcmDocument( filename ) { // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010 // We may encounter the 'RETired' (0x0028, 0x0200) tag @@ -80,10 +77,9 @@ gdcmHeader::gdcmHeader( std::string const & filename, /** * \brief Constructor - * @param exception_on_error whether we want to throw an exception or not */ -gdcmHeader::gdcmHeader(bool exception_on_error) : - gdcmDocument( exception_on_error ) +gdcmHeader::gdcmHeader() + :gdcmDocument() { } @@ -112,10 +108,7 @@ void gdcmHeader::Write(FILE* fp,FileType filetype) SetEntryByNumber("16", 0x0028,0x0100); } - // correct Pixel group Length if necessary - - // TODO : create a gdcmHeader::Write method and move this part. - // (only gdcmHeader knows GrPixel, NumPixel) + // TODO : correct 'Pixel group' Length if necessary int i_lgPix = GetEntryLengthByNumber(GrPixel, NumPixel); if (i_lgPix != -2) @@ -127,7 +120,10 @@ void gdcmHeader::Write(FILE* fp,FileType filetype) delete[] dumm; ReplaceOrCreateByNumber(s_lgPix,GrPixel, 0x0000); } - + + // FIXME : should be nice if we could move it to gdcmFile + // (or in future gdcmPixelData class) + // Drop Palette Color, if necessary if ( GetEntryByNumber(0x0028,0x0002).c_str()[0] == '3' ) @@ -139,32 +135,32 @@ void gdcmHeader::Write(FILE* fp,FileType filetype) gdcmDocEntry* e = GetDocEntryByNumber(0x0028,0x01101); if (e) { - RemoveEntry(e); + RemoveEntryNoDestroy(e); } e = GetDocEntryByNumber(0x0028,0x1102); if (e) { - RemoveEntry(e); + RemoveEntryNoDestroy(e); } e = GetDocEntryByNumber(0x0028,0x1103); if (e) { - RemoveEntry(e); + RemoveEntryNoDestroy(e); } e = GetDocEntryByNumber(0x0028,0x01201); if (e) { - RemoveEntry(e); + RemoveEntryNoDestroy(e); } e = GetDocEntryByNumber(0x0028,0x1202); if (e) { - RemoveEntry(e); + RemoveEntryNoDestroy(e); } e = GetDocEntryByNumber(0x0028,0x1203); if (e) { - RemoveEntry(e); + RemoveEntryNoDestroy(e); } } gdcmDocument::Write(fp,filetype); @@ -757,7 +753,6 @@ int gdcmHeader::GetBitsStored() return 0; // It's supposed to be mandatory // the caller will have to check } - return atoi( strSize.c_str() ); } @@ -777,7 +772,6 @@ int gdcmHeader::GetBitsAllocated() return 0; // It's supposed to be mandatory // the caller will have to check } - return atoi( strSize.c_str() ); } @@ -797,7 +791,6 @@ int gdcmHeader::GetSamplesPerPixel() return 1; // Well, it's supposed to be mandatory ... // but sometimes it's missing : *we* assume Gray pixels } - return atoi( strSize.c_str() ); } @@ -814,7 +807,6 @@ int gdcmHeader::GetPlanarConfiguration() { return 0; } - return atoi( strSize.c_str() ); } @@ -848,7 +840,6 @@ int gdcmHeader::GetPixelSize() { return 8; } - dbg.Verbose(0, "gdcmHeader::GetPixelSize: Unknown pixel type"); return 0; } @@ -907,7 +898,6 @@ std::string gdcmHeader::GetPixelType() { sign = "S"; } - return bitsAlloc + sign; } @@ -1204,7 +1194,6 @@ uint8_t* gdcmHeader::GetLUTRGBA() *a = 1; // Alpha component a += 4; } - return LUTRGBA; } @@ -1218,6 +1207,12 @@ std::string gdcmHeader::GetTransfertSyntaxName() // use the gdcmTS (TS : Transfert Syntax) std::string transfertSyntax = GetEntryByNumber(0x0002,0x0010); + if ( transfertSyntax == GDCM_NOTLOADED ) { // fusible + std::cout << "Transfert Syntax not loaded. " << std::endl + << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" + << std::endl; + return "Uncompressed ACR-NEMA"; + } if ( transfertSyntax == GDCM_UNFOUND ) { dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName:" @@ -1267,13 +1262,14 @@ void gdcmHeader::SetImageDataSize(size_t ImageDataSize) */ bool gdcmHeader::AnonymizeHeader() { - gdcmDocEntry* patientNameHE = GetDocEntryByNumber (0x0010, 0x0010); + // If exist, replace by spaces + SetEntryByNumber (" ",0x0010, 0x2154); // Telephone + SetEntryByNumber (" ",0x0010, 0x1040); // Adress + SetEntryByNumber (" ",0x0010, 0x0020); // Patient ID - ReplaceIfExistByNumber (" ",0x0010, 0x2154); // Telephone - ReplaceIfExistByNumber (" ",0x0010, 0x1040); // Adress - ReplaceIfExistByNumber (" ",0x0010, 0x0020); // Patient ID + gdcmDocEntry* patientNameHE = GetDocEntryByNumber (0x0010, 0x0010); - if ( patientNameHE ) + if ( patientNameHE ) // we replace it by Study Instance UID (why not) { std::string studyInstanceUID = GetEntryByNumber (0x0020, 0x000d); if ( studyInstanceUID != GDCM_UNFOUND )