X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FexExtractTag.cxx;h=07843925e4faf3c9c7df4a195dffc5accb520512;hb=dd3805817a765e562b1b15590102e65bead50cef;hp=297b149c53e7483406b7a3b87c554378383cf8de;hpb=d7c4febcff4437ae1f7b4c447fc4e50bdc096700;p=gdcm.git diff --git a/Example/exExtractTag.cxx b/Example/exExtractTag.cxx index 297b149c..07843925 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/10 21:57:57 $ - Version: $Revision: 1.1 $ + Date: $Date: 2005/10/25 14:52:27 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,7 +20,7 @@ #include "gdcmCommon.h" #include "gdcmDebug.h" #include "gdcmDocEntry.h" -#include "gdcmBinEntry.h" +#include "gdcmDataEntry.h" #include @@ -29,11 +29,11 @@ int main(int argc, char *argv[]) gdcm::File *f; if( argc < 5 ) - { - std::cerr << "Usage :" << argv[0] << " input.dcm group element outputfile" << std::endl; - std::cerr << " Ex: " << argv[0] << " /tmp/bla.dcm 0029 2110 /tmp/out.raw" << std::endl; - return 1; - } + { + std::cerr << "Usage :" << argv[0] << " input.dcm group element outputfile" << std::endl; + std::cerr << " Ex: " << argv[0] << " /tmp/bla.dcm 0029 2110 /tmp/out.raw" << std::endl; + return 1; + } std::string fileName = argv[1]; std::cout << fileName << std::endl; @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) // Read the input image. // ============================================================ - f = new gdcm::File( ); + f = gdcm::File::New( ); //f->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW); f->SetFileName( fileName ); @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) std::cerr << "Sorry, " << fileName << " not a gdcm-readable " << "DICOM / ACR File" << std::endl; - delete f; + f->Delete(); return 1; } std::cout << " ... is readable " << std::endl; @@ -72,36 +72,36 @@ int main(int argc, char *argv[]) convert >> std::hex >> elem; 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->GetEntryValue(group, elem); + std::string dicom_tag_value = f->GetEntryString(group, elem); if (dicom_tag_value == gdcm::GDCM_UNFOUND) { gdcm::DictEntry *dictEntry = f->GetPubDict()->GetEntry( group, elem); std::cerr << "Image doesn't contain any tag: " << dictEntry->GetName() << std::endl; - delete f; + f->Delete(); return 1; } gdcm::DocEntry *dicom_tag_doc = f->GetDocEntry(group, elem); - gdcm::BinEntry *dicom_tag = dynamic_cast(dicom_tag_doc); + gdcm::DataEntry *dicom_tag = dynamic_cast(dicom_tag_doc); if( !dicom_tag ) - { - std::cerr << "Sorry BinEntry only please" << std::endl; //TODO support ValEntry - delete f; - return 1; - } + { + std::cerr << "Sorry DataEntry only please" << std::endl; + f->Delete(); + return 1; + } // Write out the data as a file: std::ofstream o(argv[4]); if( !o ) - { - std::cerr << "Problem opening file: " << argv[4] << std::endl; - delete f; - return 1; - } + { + std::cerr << "Problem opening file: " << argv[4] << std::endl; + f->Delete(); + return 1; + } o.write((char*)dicom_tag->GetBinArea(), dicom_tag->GetLength()); o.close(); - delete f; + f->Delete(); return 0; }