Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/10/24 16:00:47 $
- Version: $Revision: 1.165 $
+ Date: $Date: 2005/11/04 15:26:22 $
+ Version: $Revision: 1.168 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
NewMeta();
}
-#ifndef GDCM_LEGACY_REMOVE
-/* *
- * \ brief Constructor Parses recursively the directory and creates the DicomDir
- * or uses an already built DICOMDIR, depending on 'parseDir' value.
- * @ param fileName name
- * - of the root directory (parseDir = true)
- * - of the DICOMDIR (parseDir = false)
- * @ param parseDir boolean
- * - true if user passed an entry point
- * and wants to explore recursively the directories
- * - false if user passed an already built DICOMDIR file
- * and wants to use it
- * @ deprecated use : new DicomDir() + [ SetLoadMode(lm) + ] SetDirectoryName(name)
- * or : new DicomDir() + SetFileName(name)
- */
-DicomDir::DicomDir(std::string const &fileName, bool parseDir ):
- Document( )
-{
- // At this step, Document constructor is already executed,
- // whatever user passed (either a root directory or a DICOMDIR)
- // and whatever the value of parseDir was.
- // (nothing is cheked in Document constructor, to avoid overhead)
-
- ParseDir = parseDir;
- SetLoadMode (LD_ALL); // concerns only dicom files
- SetFileName( fileName );
- Load( );
-}
-#endif
-
/**
* \brief Canonical destructor
*/
ClearPatient();
if ( MetaElems )
{
- delete MetaElems;
+ MetaElems->Delete();
}
}
{
// user passed '.' as Name
// we get current directory name
- char dummy[1000];
+ char dummy[1000]; // Hope 1000 is enough!
getcwd(dummy, (size_t)1000);
SetFileName( dummy ); // will be converted into a string
}
NewMeta();
- gdcmWarningMacro( "Parse directory and create the DicomDir : "
+ gdcmDebugMacro( "Parse directory and create the DicomDir : "
<< GetFileName() );
ParseDirectory();
}
{
if ( Filetype == Unknown )
{
- gdcmWarningMacro( "Wrong filetype");
+ gdcmErrorMacro( "Wrong filetype for " << GetFileName());
return false;
}
if ( !MetaElems )
DicomDirMeta *DicomDir::NewMeta()
{
if ( MetaElems )
- delete MetaElems;
+ MetaElems->Delete();
DocEntry *entry = GetFirstEntry();
if ( entry )
{
- MetaElems = new DicomDirMeta(true); // true = empty
+ MetaElems = DicomDirMeta::New(true); // true = empty
entry = GetFirstEntry();
while( entry )
if ( dynamic_cast<SeqEntry *>(entry) )
break;
- RemoveEntry(entry);
MetaElems->AddEntry(entry);
+ RemoveEntry(entry);
entry = GetFirstEntry();
}
}
else // after root directory parsing
{
- MetaElems = new DicomDirMeta(false); // false = not empty
+ MetaElems = DicomDirMeta::New(false); // false = not empty
}
MetaElems->SetSQItemNumber(0); // To avoid further missprinting
return MetaElems;
*/
DicomDirPatient *DicomDir::NewPatient()
{
- DicomDirPatient *p = new DicomDirPatient();
- AddPatientToEnd( p );
- return p;
+ DicomDirPatient *dd = DicomDirPatient::New();
+ AddPatientToEnd( dd );
+ return dd;
}
/**
cc!= Patients.end();
++cc)
{
- delete *cc;
+ (*cc)->Unregister();
}
Patients.clear();
}
break;
}
- f = new File( );
- f->SetLoadMode(LoadMode); // we allow user not to load Sequences, or Shadow
- // groups, or ......
+ f = File::New( );
+ f->SetLoadMode(LoadMode); // we allow user not to load Sequences,
+ // or Shadow groups, or ......
f->SetFileName( it->c_str() );
- /*int res = */f->Load( );
+ f->Load( );
-// if ( !f )
-// {
-// gdcmWarningMacro( "Failure in new gdcm::File " << it->c_str() );
-// continue;
-// }
-
if ( f->IsReadable() )
{
// Add the file to the chained list:
list.push_back(f);
- gdcmWarningMacro( "Readable " << it->c_str() );
+ gdcmDebugMacro( "Readable " << it->c_str() );
}
else
{
- delete f;
+ f->Delete();
}
count++;
}
itDoc!=list.end();
++itDoc)
{
- delete dynamic_cast<File *>(*itDoc);
+ dynamic_cast<File *>(*itDoc)->Delete();
}
}
if ( v == "IMAGE " )
{
- si = new DicomDirImage(true);
+ si = DicomDirImage::New(true);
if ( !AddImageToEnd( static_cast<DicomDirImage *>(si)) )
{
- delete si;
+ si->Delete();
si = NULL;
gdcmErrorMacro( "Add AddImageToEnd failed");
}
}
else if ( v == "SERIES" )
{
- si = new DicomDirSerie(true);
+ si = DicomDirSerie::New(true);
if ( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) )
{
- delete si;
+ si->Delete();
si = NULL;
gdcmErrorMacro( "Add AddSerieToEnd failed");
}
}
else if ( v == "VISIT " )
{
- si = new DicomDirVisit(true);
+ si = DicomDirVisit::New(true);
if ( !AddVisitToEnd( static_cast<DicomDirVisit *>(si)) )
{
- delete si;
+ si->Delete();
si = NULL;
gdcmErrorMacro( "Add AddVisitToEnd failed");
}
}
else if ( v == "STUDY " )
{
- si = new DicomDirStudy(true);
+ si = DicomDirStudy::New(true);
if ( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) )
{
- delete si;
+ si->Delete();
si = NULL;
gdcmErrorMacro( "Add AddStudyToEnd failed");
}
}
else if ( v == "PATIENT " )
{
- si = new DicomDirPatient(true);
+ si = DicomDirPatient::New(true);
if ( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) )
{
- delete si;
+ si->Delete();
si = NULL;
gdcmErrorMacro( "Add PatientToEnd failed");
}
{
// It was neither a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
// nor an 'IMAGE' SQItem. Skip to next item.
- gdcmWarningMacro( " -------------------------------------------"
+ gdcmDebugMacro( " -------------------------------------------"
<< "a non PATIENT/STUDY/SERIE/IMAGE SQItem was found : "
<< v);
{
case GDCM_DICOMDIR_IMAGE:
elemList = Global::GetDicomDirElements()->GetDicomDirImageElements();
- si = new DicomDirImage(true);
+ si = DicomDirImage::New(true);
if ( !AddImageToEnd(static_cast<DicomDirImage *>(si)) )
{
- delete si;
+ si->Delete();
gdcmErrorMacro( "Add ImageToEnd failed");
}
break;
case GDCM_DICOMDIR_SERIE:
elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements();
- si = new DicomDirSerie(true);
+ si = DicomDirSerie::New(true);
if ( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) )
{
- delete si;
+ si->Delete();
gdcmErrorMacro( "Add SerieToEnd failed");
}
break;
case GDCM_DICOMDIR_STUDY:
elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements();
- si = new DicomDirStudy(true);
+ si = DicomDirStudy::New(true);
if ( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) )
{
- delete si;
+ si->Delete();
gdcmErrorMacro( "Add StudyToEnd failed");
}
break;
case GDCM_DICOMDIR_PATIENT:
elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements();
- si = new DicomDirPatient(true);
+ si = DicomDirPatient::New(true);
if ( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) )
{
- delete si;
+ si->Delete();
gdcmErrorMacro( "Add PatientToEnd failed");
}
break;
case GDCM_DICOMDIR_META:
if ( MetaElems )
{
- delete MetaElems;
+ MetaElems->Delete();
gdcmErrorMacro( "MetaElements already exist, they will be destroyed");
}
elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements();
- MetaElems = new DicomDirMeta(true);
+ MetaElems = DicomDirMeta::New(true);
si = MetaElems;
break;
default:
tmpEl = it->Elem;
dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
- entry = DataEntry::New( dictEntry ); // Be sure it's never a DataEntry !
-
+ entry = DataEntry::New( dictEntry );
entry->SetOffset(0); // just to avoid further missprinting
if ( header )
}
else
{
- val = &(header->GetFileName().c_str()[path.length()]);
+ val = &(header->GetFileName().c_str()[path.length()+1]);
}
}
else
if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
{
- gdcmWarningMacro("GDCM_DICOMDIR_META ?!? should never print that");
+ gdcmDebugMacro("GDCM_DICOMDIR_META ?!? should never print that");
}
si->AddEntry(entry);
entry->Delete();