X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FAnonymizeNoLoad.cxx;h=6ffea195f9019c58e35a15ae63d51d1b8ffddb66;hb=98f9b12c49d30369af3fed4b7d6c41d7dd0ef1ae;hp=ca173a4c0b37fc3269623d5738a2b55d56e3eb4f;hpb=bad3d167a335f3c33678050e59d2e5d4e1b97bb7;p=gdcm.git diff --git a/Example/AnonymizeNoLoad.cxx b/Example/AnonymizeNoLoad.cxx index ca173a4c..6ffea195 100644 --- a/Example/AnonymizeNoLoad.cxx +++ b/Example/AnonymizeNoLoad.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: AnonymizeNoLoad.cxx,v $ Language: C++ - Date: $Date: 2005/07/13 13:48:56 $ - Version: $Revision: 1.5 $ + Date: $Date: 2005/08/28 17:26:31 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -28,26 +28,29 @@ int main(int argc, char *argv[]) { START_USAGE(usage) - "\n AnonymizeNoLoad :\n", - "Anonymize a gdcm-readable Dicom image even if pixels aren't gdcm readable", - " Warning : Warning : the image is overwritten", - " to preserve image integrity, use a copy.", - "usage: AnonymizeNoLoad {filein=inputFileName|dirin=inputDirectoryName}", - " [ { [noshadowseq] | [noshadow][noseq] } ] [debug]", - " inputFileName : Name of the (single) file user wants to anonymize", - " inputDirectoryName : user wants to anonymize *all* the files", - " within the (single Patient!) directory", - " noshadowseq: user doesn't want to load Private Sequences", - " noshadow : user doesn't want to load Private groups (odd number)", - " noseq : user doesn't want to load Sequences ", - " debug : user wants to run the program in 'debug mode' ", + "\n AnonymizeNoLoad :\n ", + "Anonymize a gdcm-readable Dicom image even if pixels aren't gdcm readable ", + " Warning : Warning : the image is overwritten ", + " to preserve image integrity, use a copy. ", + "usage: AnonymizeNoLoad {filein=inputFileName|dirin=inputDirectoryName} ", + " [rubout=listOfElementsToRubOut] ", + " [ { [noshadowseq] | [noshadow][noseq] } ] [debug] ", + " inputFileName : Name of the (single) file user wants to anonymize ", + " inputDirectoryName : user wants to anonymize *all* the files ", + " within the (single Patient!) directory ", + " listOfElementsToRubOut : group-elem,g2-e2,... (in hexa, no space) ", + " of extra Elements to rub out ", + " noshadowseq: user doesn't want to load Private Sequences ", + " noshadow : user doesn't want to load Private groups (odd number) ", + " noseq : user doesn't want to load Sequences ", + " debug : user wants to run the program in 'debug mode' ", FINISH_USAGE // ----- Initialize Arguments Manager ------ gdcm::ArgMgr *am = new gdcm::ArgMgr(argc, argv); - if (am->ArgMgrDefined("usage")) + if (am->ArgMgrDefined("usage") || argc == 1) { am->ArgMgrUsage(usage); // Display 'usage' delete am; @@ -62,11 +65,12 @@ int main(int argc, char *argv[]) if ( (fileName == 0 && dirName == 0) || - (fileName != 0 && dirName != 0) ) + (fileName != 0 && dirName != 0) ) { std::cout <ArgMgrGetXInt16Enum("rubout", &rubOutNb); + /* if unused Param we give up */ + if ( am->ArgMgrPrintUnusedLabels() ) + { + am->ArgMgrUsage(usage); + delete am; + return 0; + } + + delete am; // ------ we don't need Arguments Manager any longer ------ + gdcm::File *f; if ( fileName != 0 ) // ====== Deal with a single file ====== { // // Parse the input file. // - gdcm::File *f; f = new gdcm::File( ); f->SetLoadMode(loadMode); f->SetFileName( fileName ); - bool res = f->Load(); // gdcm::File::IsReadable() is no usable here, because we deal with // any kind of gdcm::Readable *document* // not only gdcm::File (as opposed to gdcm::DicomDir) - if ( !res ) + if ( !f->Load() ) { std::cout <AddAnonymizeElement(0x0010, 0x2154, "3615" ); + for (int ri=0; riAddAnonymizeElement((uint32_t)elemsToRubOut[2*ri], + (uint32_t)elemsToRubOut[2*ri+1],"*" ); + } + // Aware use will add new fields here // @@ -150,9 +170,8 @@ int main(int argc, char *argv[]) f->AnonymizeNoLoad(); - // No need to write the File : modif were done on disc ! - // File was overwritten ... - + // No need to write the file : modif were done on disc ! + // ( The Dicom file is overwritten ) std::cout <<"End AnonymizeNoLoad" << std::endl; // @@ -173,14 +192,11 @@ int main(int argc, char *argv[]) it != fileList.end(); ++it ) { - - gdcm::File *f; f = new gdcm::File( ); f->SetLoadMode(loadMode); f->SetFileName( it->c_str() ); - bool res = f->Load(); - if ( !res ) + if ( !f->Load() ) { delete f; continue; @@ -206,10 +222,18 @@ int main(int argc, char *argv[]) //f->AddAnonymizeElement( 0x0020, 0x000d, "9.99.999.9999" ); // Telephone f->AddAnonymizeElement(0x0010, 0x2154, "3615" ); - + + // deal with user defined Elements set + + for (int ri=0; riAddAnonymizeElement((uint32_t)elemsToRubOut[2*ri], + (uint32_t)elemsToRubOut[2*ri+1],"*" ); + } std::cout <<"Let's AnonymizeNoLoad " << it->c_str() << std::endl; // The gdcm::File remains untouched in memory + // The Dicom file is overwritten on disc f->AnonymizeNoLoad();