Program: gdcm
Module: $RCSfile: AnonymizeDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/07/12 14:44:09 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2005/10/25 14:52:26 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmSQItem.h"
#include "gdcmSeqEntry.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmDocument.h"
#include "gdcmFile.h"
if ( d == NULL)
return;
- if ( ! dynamic_cast<gdcm::ValEntry *>(d) )
+ if ( ! dynamic_cast<gdcm::DataEntry *>(d) )
return;
offset = d->GetOffset();
// ----- Initialize Arguments Manager ------
gdcm::ArgMgr *am = new gdcm::ArgMgr(argc, argv);
- if (am->ArgMgrDefined("usage"))
+ if (argc == 1 || am->ArgMgrDefined("usage"))
{
am->ArgMgrUsage(usage); // Display 'usage'
delete am;
char *fileName = am->ArgMgrWantString("filein",usage);
+ // if unused Param we give up
+ if ( am->ArgMgrPrintUnusedLabels() )
+ {
+ am->ArgMgrUsage(usage);
+ delete am;
+ return 0;
+ }
delete am; // --- we don't need Argument Manager any longer ---
-// Read the input DICOMDIR
+ // Read the input DICOMDIR
gdcm::File *f;
- f = new gdcm::File( );
+ f = gdcm::File::New( );
f->SetLoadMode(0);
f->SetFileName( fileName );
bool res = f->Load();
if ( !e )
{
std::cout << "No Directory Record Sequence (0004,1220) found" <<std::endl;;
- delete f;
- return 0;
+ f->Delete();
+ return 0;
}
gdcm::SeqEntry *s = dynamic_cast<gdcm::SeqEntry *>(e);
if ( !s )
{
std::cout << "Element (0004,1220) is not a Sequence ?!?" <<std::endl;
- delete f;
+ f->Delete();
return 0;
}
while(tmpSI)
{
d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
- if ( gdcm::ValEntry* valEntry = dynamic_cast<gdcm::ValEntry *>(d) )
+ if ( gdcm::DataEntry *dataEntry = dynamic_cast<gdcm::DataEntry *>(d) )
{
- v = valEntry->GetValue();
+ v = dataEntry->GetString();
}
else
{
- std::cout << "(0004,1430) not a ValEntry ?!?" << std::endl;
+ std::cout << "(0004,1430) not a DataEntry ?!?" << std::endl;
continue;
}
// Telephone
AnoNoLoad(tmpSI, fp, 0x0010, 0x2154, oss.str());
- // Aware use will add here more Entries if he wants to rubb them out
+ // Aware use will add here more Entries if he wants to rubb them out
oss << "";
patientNumber++;
fp->close();
- delete f;
+ delete fp;
+ f->Delete();
return 0;
}