X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FAnonymizeDicomDir.cxx;h=47915d81559acc939d47c63382d39c8d0873beb1;hb=4695af60407895e5f0851ffcb9afdb138c9870f7;hp=f4ab3fe3dba629b8805e1892851bdec3dba31df8;hpb=998aa4a03f2f7e299226e84fbc7c0c02143f863e;p=gdcm.git diff --git a/Example/AnonymizeDicomDir.cxx b/Example/AnonymizeDicomDir.cxx index f4ab3fe3..47915d81 100644 --- a/Example/AnonymizeDicomDir.cxx +++ b/Example/AnonymizeDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: AnonymizeDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/06/07 14:41:47 $ - Version: $Revision: 1.3 $ + Date: $Date: 2005/07/12 14:56:48 $ + Version: $Revision: 1.6 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -70,6 +70,7 @@ void AnoNoLoad(gdcm::SQItem *s, std::fstream *fp, fp->write( v.c_str(), lgth ); } + int main(int argc, char *argv[]) { @@ -94,35 +95,36 @@ int main(int argc, char *argv[]) char *fileName = am->ArgMgrWantString("filein",usage); - delete am; // we don't need Argument Manager any longer + delete am; // --- we don't need Argument Manager any longer --- -// ============================================================ -// Read the input DICOMDIR -// ============================================================ - gdcm::File *f1 = new gdcm::File( fileName ); - if (!f1->IsReadable()) { + // Read the input DICOMDIR + gdcm::File *f; + f = new gdcm::File( ); + f->SetLoadMode(0); + f->SetFileName( fileName ); + bool res = f->Load(); + if ( !res ) + { std::cerr << "Sorry, " << fileName <<" not a gdcm-readable " << "file" <GetDocEntry(0x0004, 0x1220); + // Look for Directory record sequence + gdcm::DocEntry *e = f->GetDocEntry(0x0004, 0x1220); if ( !e ) { std::cout << "No Directory Record Sequence (0004,1220) found" <(e); if ( !s ) { std::cout << "Element (0004,1220) is not a Sequence ?!?" <GetNextSQItem(); + continue; } oss << patientNumber; @@ -167,7 +170,7 @@ int main(int argc, char *argv[]) // Telephone AnoNoLoad(tmpSI, fp, 0x0010, 0x2154, oss.str()); - // Aware use will add more Entries he wants to rubb out here + // Aware use will add here more Entries if he wants to rubb them out oss << ""; patientNumber++; @@ -178,9 +181,7 @@ int main(int argc, char *argv[]) fp->close(); - delete fp; - delete e; - delete f1; + delete f; return 0; }