X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FexExtractTag.cxx;h=41e59dd16d15c363f107f73e417c331277e8eddd;hb=d37154e4495e1e1c18c44f6cae6ef2ff8a2891cf;hp=07843925e4faf3c9c7df4a195dffc5accb520512;hpb=6b51b22366f878e1050c75a6ebb755bd2ff365c7;p=gdcm.git diff --git a/Example/exExtractTag.cxx b/Example/exExtractTag.cxx index 07843925..41e59dd1 100644 --- a/Example/exExtractTag.cxx +++ b/Example/exExtractTag.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exExtractTag.cxx,v $ Language: C++ - Date: $Date: 2005/10/25 14:52:27 $ - Version: $Revision: 1.3 $ + Date: $Date: 2007/06/06 13:03:09 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) { - gdcm::File *f; + GDCM_NAME_SPACE::File *f; if( argc < 5 ) { @@ -35,19 +35,31 @@ int main(int argc, char *argv[]) return 1; } std::string fileName = argv[1]; + + // Find the dicom tag, and extract the string + uint16_t group, elem; + std::istringstream convert; + convert.str( argv[2] ); + convert >> std::hex >> group; + convert.clear(); //important + convert.str( argv[3] ); + convert >> std::hex >> elem; std::cout << fileName << std::endl; // ============================================================ // Read the input image. // ============================================================ - f = gdcm::File::New( ); + f = GDCM_NAME_SPACE::File::New( ); - //f->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW); + //f->SetLoadMode(GDCM_NAME_SPACE::LD_NOSEQ | GDCM_NAME_SPACE::LD_NOSHADOW); f->SetFileName( fileName ); + // Make sure the Data Element will be loaded + f->AddForceLoadElement ( group, elem); + bool res = f->Load(); - if( gdcm::Debug::GetDebugFlag() ) + if( GDCM_NAME_SPACE::Debug::GetDebugFlag() ) { std::cout << "---------------------------------------------" << std::endl; f->Print(); @@ -62,27 +74,21 @@ int main(int argc, char *argv[]) } std::cout << " ... is readable " << std::endl; - // Find the dicom tag, and extract the string - uint16_t group, elem; - std::istringstream convert; - convert.str( argv[2] ); - convert >> std::hex >> group; - convert.clear(); //important - convert.str( argv[3] ); - convert >> std::hex >> elem; + // (Find the dicom tag, and) extract the string + std::cout << "Extracting tag: (0x" << std::hex << std::setw(4) << std::setfill('0') << group << ",0x" << std::setw(4) << std::setfill('0') << elem << ")" << std::endl; std::string dicom_tag_value = f->GetEntryString(group, elem); - if (dicom_tag_value == gdcm::GDCM_UNFOUND) + if (dicom_tag_value == GDCM_NAME_SPACE::GDCM_UNFOUND) { - gdcm::DictEntry *dictEntry = f->GetPubDict()->GetEntry( group, elem); + GDCM_NAME_SPACE::DictEntry *dictEntry = f->GetPubDict()->GetEntry( group, elem); std::cerr << "Image doesn't contain any tag: " << dictEntry->GetName() << std::endl; f->Delete(); return 1; } - gdcm::DocEntry *dicom_tag_doc = f->GetDocEntry(group, elem); - gdcm::DataEntry *dicom_tag = dynamic_cast(dicom_tag_doc); + GDCM_NAME_SPACE::DocEntry *dicom_tag_doc = f->GetDocEntry(group, elem); + GDCM_NAME_SPACE::DataEntry *dicom_tag = dynamic_cast(dicom_tag_doc); if( !dicom_tag ) { std::cerr << "Sorry DataEntry only please" << std::endl;