+
+ //
+ // Parse the input file.
+ //
+ f = GDCM_NAME_SPACE::File::New( );
+ f->SetLoadMode(loadMode);
+ f->SetFileName( fileName );
+
+ // GDCM_NAME_SPACE::File::IsReadable() is no usable here, because we deal with
+ // any kind of GDCM_NAME_SPACE::Readable *document*
+ // not only GDCM_NAME_SPACE::File (as opposed to GDCM_NAME_SPACE::DicomDir)
+ if ( !f->Load() )
+ {
+ std::cout <<std::endl
+ << "Sorry, " << fileName <<" not a gdcm-readable "
+ << "DICOM / ACR Document"
+ << std::endl;
+ f->Delete();
+ return 1;
+ }
+ std::cout << fileName << " is readable " << std::endl;
+
+ //
+ // No need to load the pixels in memory.
+ // File will be overwritten
+ //
+
+ //
+ // Choose the fields to anonymize.
+ //
+
+ // Institution name
+ f->AddAnonymizeElement( 0x0008, 0x0080, "gdcm-Xanadoo Hospital" );
+ // Patient's name
+ f->AddAnonymizeElement( 0x0010, 0x0010, "gdcm^Fantomas" );
+ // Patient's ID
+ f->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
+ // Patient's Birthdate
+ f->AddAnonymizeElement( 0x0010, 0x0030,"11111111" );
+ // Patient's Adress
+ f->AddAnonymizeElement( 0x0010, 0x1040,"gdcm at Sing-sing.org" );
+ // Patient's Mother's Birth Name
+ f->AddAnonymizeElement( 0x0010, 0x1060,"gdcm^Vampirella" );
+ // Study Instance UID
+ f->AddAnonymizeElement( 0x0020, 0x000d, "9.99.999.9999" );
+ // Telephone
+ f->AddAnonymizeElement(0x0010, 0x2154, "3615" );
+
+ for (int ri=0; ri<rubOutNb; ri++)
+ {
+ printf("%04x,%04x\n",elemsToRubOut[2*ri], elemsToRubOut[2*ri+1]);
+ f->AddAnonymizeElement((uint32_t)elemsToRubOut[2*ri],
+ (uint32_t)elemsToRubOut[2*ri+1],"*" );
+ }
+
+ // Aware use will add new fields here
+
+ //
+ // Overwrite the file
+ //
+
+ std::cout <<"Let's AnonymizeNoLoad " << std::endl;
+
+ // The GDCM_NAME_SPACE::File remains untouched in memory
+
+ f->AnonymizeNoLoad();
+
+ // No need to write the file : modif were done on disc !
+ // ( The Dicom file is overwritten )
+ std::cout <<"End AnonymizeNoLoad" << std::endl;
+
+ //
+ // Remove the Anonymize list
+ //
+ f->ClearAnonymizeList();
+
+ f->Delete();
+ return 0;
+