X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDocument.cxx;h=43f9b0a199eb97a473651f644d3b2a25dcb4a47e;hb=934741ba56fd719a775e93cc93616c25b3d10901;hp=b246b79159343e84541b90d100c32c4ddbd865fd;hpb=b1520ca5b7b3665aa40c14b63169bfab92eece55;p=gdcm.git diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index b246b791..43f9b0a1 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2004/06/22 13:47:33 $ - Version: $Revision: 1.22 $ + Date: $Date: 2004/06/23 09:30:22 $ + Version: $Revision: 1.26 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -126,6 +126,25 @@ gdcmDocument::gdcmDocument(std::string const & inFilename, long l=ParseDES( this, beg, lgt, false); // le Load sera fait a la volee (void)l; //is l used anywhere ? + + rewind(fp); + + // Load 'non string' values + + std::string PhotometricInterpretation = GetEntryByNumber(0x0028,0x0004); + if( PhotometricInterpretation == "PALETTE COLOR " ) { + LoadEntryVoidArea(0x0028,0x1200); // gray LUT + LoadEntryVoidArea(0x0028,0x1201); // R LUT + LoadEntryVoidArea(0x0028,0x1202); // G LUT + LoadEntryVoidArea(0x0028,0x1203); // B LUT + + LoadEntryVoidArea(0x0028,0x1221); // Segmented Red Palette Color LUT Data + LoadEntryVoidArea(0x0028,0x1222); // Segmented Green Palette Color LUT Data + LoadEntryVoidArea(0x0028,0x1223); // Segmented Blue Palette Color LUT Data + } + //FIXME later : how to use it? + LoadEntryVoidArea(0x0028,0x3006); //LUT Data (CTX dependent) + CloseFile(); // -------------------------------------------------------------- @@ -390,11 +409,12 @@ bool gdcmDocument::IsRLELossLessTransferSyntax(void) * @return True when RLE Lossless found. False in all * other cases. */ + bool gdcmDocument::IsJPEGLossless(void) { return ( IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_55) || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_57) - || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_90) ); + || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_70) ); // was 90 } /** @@ -551,8 +571,8 @@ bool gdcmDocument::WriteF(FileType filetype) { * if ( filetype == ACR) * UpdateGroupLength(true,ACR); */ - - Write(fp,filetype); // the gdcmElementSet one ! + + Write(fp,filetype); // the gdcmElementSet one ! /// WriteEntries(fp,type); // old stuff return true; @@ -637,14 +657,14 @@ gdcmBinEntry * gdcmDocument::ReplaceOrCreateByNumber( guint16 Elem) { gdcmDocEntry* a; - gdcmBinEntry* b; + gdcmBinEntry* b; a = GetDocEntryByNumber( Group, Elem); if (a == NULL) { a =NewBinEntryByNumber(Group, Elem); if (a == NULL) return NULL; - b = new gdcmBinEntry(a); + b = new gdcmBinEntry(a); AddEntry(b); } SetEntryByNumber(voidArea, lgth, Group, Elem); @@ -846,7 +866,7 @@ bool gdcmDocument::SetEntryByNumber(void *content, TagKey key = gdcmDictEntry::TranslateToKey(group, element); if ( ! tagHT.count(key)) return false; - + /* Hope Binray field length is never wrong if(lgth%2) // Non even length are padded with a space (020H). { @@ -1180,7 +1200,7 @@ long gdcmDocument::ParseDES(gdcmDocEntrySet *set, long offset, long l_max, bool NewValEntry->SetDepthLevel(depth); set->AddEntry(NewValEntry); LoadDocEntry(NewValEntry); - if (/*!delim_mode && */NewValEntry->isItemDelimitor()) + if (NewValEntry->isItemDelimitor()) break; if ( !delim_mode && ftell(fp)-offset >= l_max) { @@ -1261,7 +1281,7 @@ long gdcmDocument::ParseSQ(gdcmSeqEntry *set, long offset, long l_max, bool delim_mode) { int SQItemNumber = 0; - + gdcmDocEntry *NewDocEntry = (gdcmDocEntry *)0; gdcmSQItem *itemSQ; bool dlm_mod; @@ -1293,7 +1313,7 @@ long gdcmDocument::ParseSQ(gdcmSeqEntry *set, lgr=ParseDES(itemSQ, NewDocEntry->GetOffset(), l, dlm_mod); - set->AddEntry(itemSQ,SQItemNumber); + set->AddEntry(itemSQ,SQItemNumber); SQItemNumber ++; if (!delim_mode && (ftell(fp)-offset) >= l_max) { break; @@ -1323,9 +1343,6 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry *Entry) // (fffe e0dd) tells us the current SeQuence just ended if( group == 0xfffe ) { // NO more value field for SQ ! - //Entry->SetValue("gdcm::Skipped"); - // appel recursif de Load Value - // (meme pb que pour le parsing) return; } @@ -1338,21 +1355,41 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry *Entry) // The elements whose length is bigger than the specified upper bound // are not loaded. Instead we leave a short notice of the offset of // the element content and it's length. + if (length > MaxSizeLoadEntry) { + if (gdcmBinEntry* BinEntryPtr = dynamic_cast< gdcmBinEntry* >(Entry) ) + { + std::ostringstream s; + s << "gdcm::NotLoaded (BinEntry)"; + s << " Address:" << (long)Entry->GetOffset(); + s << " Length:" << Entry->GetLength(); + s << " x(" << std::hex << Entry->GetLength() << ")"; + BinEntryPtr->SetValue(s.str()); + } + // to be sure we are at the end of the value ... + fseek(fp,(long)Entry->GetOffset()+(long)Entry->GetLength(),SEEK_SET); + return; + // Be carefull : a BinEntry IS_A ValEntry ... if (gdcmValEntry* ValEntryPtr = dynamic_cast< gdcmValEntry* >(Entry) ) { std::ostringstream s; - s << "gdcm::NotLoaded."; + s << "gdcm::NotLoaded. (ValEntry)"; s << " Address:" << (long)Entry->GetOffset(); s << " Length:" << Entry->GetLength(); s << " x(" << std::hex << Entry->GetLength() << ")"; ValEntryPtr->SetValue(s.str()); - } + } // to be sure we are at the end of the value ... - fseek(fp,(long)Entry->GetOffset()+(long)Entry->GetLength(),SEEK_SET); - + fseek(fp,(long)Entry->GetOffset()+(long)Entry->GetLength(),SEEK_SET); return; } + + // When we find a BinEntry not very much can be done : + if (gdcmBinEntry* BinEntryPtr = dynamic_cast< gdcmBinEntry* >(Entry) ) { + LoadEntryVoidArea (BinEntryPtr->GetGroup(),BinEntryPtr->GetElement()); + return; + } + // Any compacter code suggested (?) if ( IsDocEntryAnInteger(Entry) ) { @@ -1777,16 +1814,6 @@ void gdcmDocument::SkipToNextDocEntry(gdcmDocEntry *entry) (void)fseek(fp, (long)(entry->GetReadLength()), SEEK_CUR); } -/** - * \brief Loads the value for a a given VLEntry - * \warning NOT end user intended method ! - * @param entry - */ -void gdcmDocument::LoadVLEntry(gdcmDocEntry *entry) -{ - //SkipBytes(entry->GetLength()); - LoadDocEntry(entry); -} /** * \brief When the length of an element value is obviously wrong (because * the parser went Jabberwocky) one can hope improving things by