From b792278a90bb8f54b77595a073d435c2041dabf3 Mon Sep 17 00:00:00 2001 From: malaterre Date: Fri, 10 Dec 2004 16:48:37 +0000 Subject: [PATCH] ENH: Thanks to Benoit example I was able to rewrite the damn thing, hopefully it should work on win32 --- Example/TestFromScratch.cxx | 50 ++++++++++++++++++------------------ Example/WriteDicomSimple.cxx | 5 ++-- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Example/TestFromScratch.cxx b/Example/TestFromScratch.cxx index 27fd2627..66771cca 100644 --- a/Example/TestFromScratch.cxx +++ b/Example/TestFromScratch.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestFromScratch.cxx,v $ Language: C++ - Date: $Date: 2004/12/10 15:50:04 $ - Version: $Revision: 1.1 $ + Date: $Date: 2004/12/10 16:48:37 $ + Version: $Revision: 1.2 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,6 +19,7 @@ #include "gdcmFile.h" #include "gdcmDictEntry.h" #include "gdcmDocEntry.h" +#include "gdcmBinEntry.h" #include "gdcmValEntry.h" #include "gdcmDebug.h" @@ -52,39 +53,38 @@ int main(int argc, char *argv[]) // Hopefully default to something gdcm::Header *h2 = new gdcm::Header(); - const gdcm::TagDocEntryHT &nameHt = h1->GetTagHT(); - //const gdcm::TagDocEntryHT &nameHt = h2->GetTagHT(); seems to be empty ?? - for (gdcm::TagDocEntryHT::const_iterator tag = nameHt.begin(); tag != nameHt.end(); ++tag) + h1->Initialize(); + gdcm::DocEntry* d = h1->GetNextEntry(); + + // Copy of the header content + while(d) { - //Copy string only: - if (tag->second->GetVR().find("SQ") == 0) + if ( gdcm::BinEntry* b = dynamic_cast(d) ) { - // skip DICOM SeQuence, otherwise following cast will crash - continue; + // We skip bin entries + } + else if ( gdcm::ValEntry* v = dynamic_cast(d) ) + { + h2->ReplaceOrCreateByNumber( + v->GetValue(), + v->GetGroup(), + v->GetElement(), + v->GetVR() ); } - const std::string &name = tag->second->GetName(); - const std::string &value = ((gdcm::ValEntry*)(tag->second))->GetValue(); - if( name != "unkn" - && value.find( "gdcm::NotLoaded" ) != 0 - && value.find( "gdcm::Binary" ) != 0 - && value.find( "gdcm::Loaded" ) != 0 ) + else { - //std::cout << name << "," << value << std::endl; - gdcm::DictEntry *dictEntry = h2->GetPubDict()->GetDictEntryByName(name); - h2->ReplaceOrCreateByNumber( value, dictEntry->GetGroup(), dictEntry->GetElement()); + // We skip pb of SQ recursive exploration } - } - h2->ReplaceOrCreateByNumber( imageData, dataSize, 0x7fe0, 0x0010, "PXL" ); - h2->Print( std::cout ); + d = h1->GetNextEntry(); + } + //h2->Print( std::cout ); gdcm::File *f2 = new gdcm::File( h2 ); - - // SetImageData does not work because you need to have called - // somwhow ReplaceOrCreateByNumber before with the proper group/element f2->SetImageData(imageData, dataSize); - f2->WriteDcmExplVR( "output.dcm" ); + f2->SetWriteTypeToDcmExplVR(); + f2->Write( "output.dcm" ); delete f1; delete f2; diff --git a/Example/WriteDicomSimple.cxx b/Example/WriteDicomSimple.cxx index f426800e..6954426a 100644 --- a/Example/WriteDicomSimple.cxx +++ b/Example/WriteDicomSimple.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: WriteDicomSimple.cxx,v $ Language: C++ - Date: $Date: 2004/12/10 13:49:06 $ - Version: $Revision: 1.3 $ + Date: $Date: 2004/12/10 16:48:37 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -189,3 +189,4 @@ int main(int argc, char* argv[]) return 0; } + -- 2.48.1